酢ろぐ!

カレーが嫌いなスマートフォンアプリプログラマのブログ。

Xcode 13.3でアプリバイナリのexportに失敗する問題

昨日、App StoreにてXcode 13.3がリリースされた。早速アップデートしたところ、Bitriseにて特定のアプリで下記のようなエラーが発生した。コンパイル自体は問題なくその後のアーカイブの段階で失敗している。

error: exportArchive: ipatool failed with an exception: #<CmdSpec::NonZeroExitException: $ /Applications/Xcode-13.3.Release.Candidate.app/Contents/Developer/usr/bin/python3 /Applications/Xcode-13.3.Release.Candidate.app/Contents/Developer/usr/bin/bitcode-build-tool -v -t /Applications/Xcode-13.3.Release.Candidate.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin --sdk /Applications/Xcode-13.3.Release.Candidate.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.4.sdk -o /var/folders/ds/8lz3xw2s09jfp13nlv1tpgjc0000gn/T/ipatool20220315-7746-1lue8qz/thinned-out/arm64/Payload/MY_APPLICATION.app/Frameworks/libswift_Concurrency.dylib --generate-dsym /var/folders/ds/8lz3xw2s09jfp13nlv1tpgjc0000gn/T/ipatool20220315-7746-1lue8qz/thinned-out/arm64/Payload/MY_APPLICATION.app/Frameworks/libswift_Concurrency.dylib.dSYM --strip-swift-symbols /var/folders/ds/8lz3xw2s09jfp13nlv1tpgjc0000gn/T/ipatool20220315-7746-1lue8qz/thinned-in/arm64/Payload/MY_APPLICATION.app/Frameworks/libswift_Concurrency.dylib

ローカルPCで試したところAdHocバイナリのexportでも同じエラーが発生した。

f:id:ch3cooh393:20220316101638p:plain

エラー内容から Swift concurrency に起因する問題だと理解できればよかったのだが、いろんなアプリでBuild Settingsを変更して差異を確認することになった。最終的には現象が異なるが「IllustailがiOS14で起動しない(解決) - CatHand Blog」と同様に Swift concurrency のバックポートにおける問題ではないかと判明した。

結論としては、本件はXcode 13.3における既知の不具合である。

Known Issues

Exporting an app that uses Swift’s concurrency features from an archive with bitcode might fail when the app targets iOS 13.0 – iOS 14.7, watchOS 6.0 – watchOS 7.6, or tvOS 13.0 – 14.7. (89271047)

Workaround: Either uncheck the box Rebuild from bitcode when exporting the app from an archive or disable bitcode (iOS only).

Xcode 13.3 Release Notes

iOS 15.0以下(iOS 13.0〜14.7)が、Deployment target に含まれているアプリ内で Swift concurrency を利用している場合にバイナリのexportに失敗してしまう。

Swift concurrencyを使用しているライブラリをインポートしていても同様なようで、アプリ内DBとしてRealmを使っているがアプリ内コードとしてSwift concurrencyを使っていない ptcgnote でも Enable Bitcode を ON にしたままではAdHocバイナリのexportに失敗してしまった。

解決策としては「Enable bitcodeをNOにする」か「deployment targetをiOS 15以上にあげる」のどちらかになりそうだ。