Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bitcode bundle could not be generated for arm64

Tags:

xcode

ios

bitcode

I'm encountering a build error when I set 'Enable Bitcode' to 'YES' in the build settings of a project I'm currently working on. The error is:

ld: bitcode bundle could not be generated because '/Users/nick/Library/Developer/Xcode/DerivedData/PROJECTNAME-esksqmlmtpqewpbktcqeqloackeu/Build/Intermediates.noindex/PROJECT.build/Debug-iphoneos/PROJECTNAME.build/Objects-normal/arm64/main.o' was built without full bitcode. All object files and libraries for bitcode must be generated from Xcode Archive or Install build file '/Users/nick/Library/Developer/Xcode/DerivedData/PROJECTNAME-esksqmlmtpqewpbktcqeqloackeu/Build/Intermediates.noindex/PROJECT.build/Debug-iphoneos/PROJECTNAME.build/Objects-normal/arm64/main.o' for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

(I've redacted the project name to PROJECTNAME and a variant to PROJECT to post here.)

At first I though it could be due to one of the dependencies this project is using via Cocoapods but they all have 'Enable Bitcode' set to 'YES' and I'd expect to see the name of the offending library in the error message if that was the case. The project uses no frameworks other than those included via Cocoapods (and Apple frameworks).

I've tried deleting the derived data, restarting Xcode as well as clearing the build folder but the error persists.

I've also tried the '-fembed-bitcode-marker' solution as suggested for a similar problem here:

iOS library to BitCode

But I'm not building a static library but an app so perhaps unsurprising it made no difference.

The project is fairly large and has been developed since 2012 so includes Objective-C and Swift. It currently has iOS 8 as deployment target and 11.2 as base SDK. It's never had Bitcode enabled in any dev or production version in the past. We've got Bitcode enabled on similar but more recent projects. We're currently using Xcode 9.2 (9C40b).

I know I could set 'Enable Bitcode' to 'NO' for the project's build settings to 'fix' the error but I'd rather have bitcode enabled for the re-optimisations Apple can do once the binary is uploaded as mentioned here: Apple Docs - App Thinning

Am I missing a flag in the build settings that fixes this error or perhaps something else? Any advice is much appreciated!

Many thanks, Nick

like image 554
Nick Daly Avatar asked Feb 05 '23 02:02

Nick Daly


1 Answers

After updating to Xcode 10 we tried to generate a Bitcode bundle again for this project and (after trying different build configs) have been able to do so. The config that eventually worked for this project was:

For the Project's and Pod's Build Settings:

  • 'Enable Bitcode' set to 'YES'
  • Adding '-fembed-bitcode' to 'Other C Flags'
  • Adding 'BITCODE_GENERATION_MODE' with the value 'bitcode'

These settings were needed for Debug as well as Release. This is because Debug would throw the 'bitcode could not be generated' error (see original question) if we tried to use the '-fembed-bitcode-marker' or 'marker' flags.

We'd have preferred to use the 'marker' variants for Debug as it's quicker to compile but at least we now have something that works!

like image 108
Nick Daly Avatar answered Feb 11 '23 00:02

Nick Daly