"ipatool failed with an exception: #<CmdSpec::NonZeroExitException:" on archiving with XCFramwork, Bitcode enabled

I am unable to archive the ipa when selecting "Rebuild from bitcode" export option, getting the following error

ipatool failed with an exception: #<CmdSpec::NonZeroExitException: $ /Applications/Xcode.app/Contents/Developer/usr/bin/bitcode-build-tool
-v -t /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
-

Note:- I checked all my dependency frameworks are of .xcframework, supporting Bitcode.

Could anyone help me here? Thanks in advance.


Solution 1:

We've got similar issue, which is described here. So long story short, there were LLVM instrumentation included, which prevents AppStore processing. I've written a whole blog about XCode 12 and BigSur issues with XCFramework.

To sum up, here is a few required steps to make sure while creating XCFramework for distribution:

  • Using archive builds is a MUST, release build isn't enough
  • BUILD_LIBRARY_FOR_DISTRIBUTION must be set to YES
  • SKIP_INSTALL must be set to NO
  • GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO to turn off GCC instrumentation and remove them from the binary
  • CLANG_ENABLE_CODE_COVERAGE = NO to turn off code coverage tools from the binary

Having all of the above helped to solve our preparing and distribution problem and hopefully save you some time if you happened to face same issues as we did.

Solution 2:

Got exact same issue,

ipatool failed with an exception: #<CmdSpec::NonZeroExitException: 
$ /Applications/Xcode.app/Contents/Developer/usr/bin/python3...
......

Status: pid 52712 exit 1
Stdout:
    SDK path: /Applications/Xcode.app/Contents/Developer/Platforms
/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.2.sdk

The reason it was generated was, I had bitcode enabled at production target but other targets ( share-extension, debug, share-extension-debug ) and project level bitcode was set to No.

When I enabled all, it worked for me.

Note that, all frameworks and binary I dependant on had bitcode present.