altool --upload-package bitcode-build-tool internal error (iOS app)

On: MacBook M1, MacOS 12.4, Xcode 13.4.1 (the issue was present in the previous Xcode version too).

When executing (for an iOS app): "xcrun altool --upload-package ...", I've started getting (it didn't happen before) this error sequentially 28 times:

2022-06-07 07:58:57.740 *** Error: /Applications/Xcode.app/Contents/Developer/usr/bin/bitcode-build-tool, terminated with status: 2 2022-06-07 07:58:57.740 *** Error: /Applications/Xcode.app/Contents/Developer/usr/bin/bitcode-build-tool (2): bitcode-build-tool internal error Traceback (most recent call last):  File "/Applications/Xcode.app/Contents/Developer/usr/bin/bitcode-build-tool", line 10, in   bitcode_build_tool_main(sys.argv)  File "/Applications/Xcode.app/Contents/Developer/usr/bin/../lib/bitcode_build_tool/main.py", line 65, in main   env.initState(args)  File "/Applications/Xcode.app/Contents/Developer/usr/bin/../lib/bitcode_build_tool/buildenv.py", line 160, in initState   self.logger.debug("SDK path: {}".format(self.sdk)) AttributeError: 'BuildEnvironment' object has no attribute 'sdk'

After the errors are printed the upload-package starts the upload – though it no longer will show the upload progress – and eventually finishes without issue. I added some debug prints in buildenv.py and sure enough the args has "sdk_path=None".

Anyone else experiencing this? Any ideas on how to fix it?

Answered by sesingh in 728507022

After updating to Xcode 14 I'm no longer getting this error message and the upload time is back down to ~120 seconds for me (when the error occurred upload time was ~400 seconds).

One thing I did notice too in Xcode 14 is that it appears that "xcrun altool --upload-package" is in debug b/c it is printing out a lot of debug-like text.

I'm going to mark this as answered b/c this is no longer an issue for me after upgrading to Xcode 14.

Yes we're experiencing exactly the same error since a while.

Same here!

Same here after going to Monterey

Hey @sesingh,

What version of the Command Line Tools are you using with Xcode?

Are you modifying your IPA file after archiving in any capacity? What are you export options set as? The Xcode verbose logs contain tons of errors that have not been resolved over the years so the Bitcode errors could be legit or misleading.

What is the exit code of altool when you get the error? You can get it by running the below command.

echo $?

Hopefully we can find a clue to correct the issue.

Happy coding!

2022-06-14 19:06:41.060 *** Error: /Applications/Xcode.app/Contents/Developer/usr/bin/bitcode-build-tool (2): bitcode-build-tool internal error
Traceback (most recent call last):

  File "/Applications/Xcode.app/Contents/Developer/usr/bin/bitcode-build-tool", line 10, in <module>

    bitcode_build_tool_main(sys.argv)

  File "/Applications/Xcode.app/Contents/Developer/usr/bin/../lib/bitcode_build_tool/main.py", line 65, in main

    env.initState(args)

  File "/Applications/Xcode.app/Contents/Developer/usr/bin/../lib/bitcode_build_tool/buildenv.py", line 159, in initState

    self.logger.debug("SDK path: {}".format(self.sdk))

AttributeError: 'BuildEnvironment' object has no attribute 'sdk'

same error. When I just call altool there is no any erroneous output.

Experiencing same issue, any solutions?

Issue solved, try to update command line tools by typing softwareupdate --install -a

No change in my status: % softwareupdate --install -a Software Update Tool

Finding available software No updates are available.

Same here any update or fix ?

softwareupdate didn't help me either. Anybody?

I experienced the same thing, but after killing altool process by using Activity Monitor, the problem disappears.

I reinstalled Command Line Tools for Xcode 13.4 and it worked, the link is here: https://developer.apple.com/download/all/?q=Command%20Line%20Tools%20for%20Xcode%2013.4

For me it could not find otool-classic. Stack overflow suggested copying otool-classic to the expected place and I was able to run the command after that.

xcrun --find otool-classic                                                                                                                                
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool-classic

cp /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool-classic /Applications/Xcode.app/Contents/Developer/usr/bin 

Actually, it seems in my last reply it worked because of coincidence, I still get some errors when running the command again, just not always. The command finished successfully what it was supposed to do in spite of the bitcode-build-tool errors.

Accepted Answer

After updating to Xcode 14 I'm no longer getting this error message and the upload time is back down to ~120 seconds for me (when the error occurred upload time was ~400 seconds).

One thing I did notice too in Xcode 14 is that it appears that "xcrun altool --upload-package" is in debug b/c it is printing out a lot of debug-like text.

I'm going to mark this as answered b/c this is no longer an issue for me after upgrading to Xcode 14.

altool --upload-package bitcode-build-tool internal error (iOS app)
 
 
Q