im using xcode 13.2.1, MacOs Monterey version 12.2 (M1).
Im trying to compile my app with bitcode using xcode.
I have Bitcode-Enable = yes in both project and target.
I checked the build log and I have no warning stating I am using a framework/library that isn't compiled with bitcode so that's not the issue.
I archived the app and I also made sure to check the rebuild with bitcode option.
When I run the command otool -l my-cool-app } | grep LLVM it shows nothing (No bitcode section). What am I possibly doing wrong?
forgot to update, apparently Bitcode-Enable = yes is not enough.
you need to specify the correct flag to compile the bitcode.
this is the command line I used:
xcodebuild BITCODE_GENERATION_MODE=bitcode OTHER_CFLAGS="-fembed-bitcode" -target "${PROJECT_NAME}"
Related
I'm trying to update the FBAudienceNetwork lib on my app to 5.7.0. This specifies that the app must be built with Xcode 11. On my local environment it builds perfectly, but when I send it to build on my Jenkins environment, it fails with this error message
ld: in /Users/admin/jenkins-home/workspace//Pods/FBAudienceNetwork/Static/FBAudienceNetwork.framework/FBAudienceNetwork(FBANInterstitialAdAdapter.m.o),
could not parse object file /Users/admin/jenkins-home/workspace/topcraft-ios/proj.ios_mac/Pods/FBAudienceNetwork/Static/FBAudienceNetwork.framework/FBAudienceNetwork(FBANInterstitialAdAdapter.m.o):
'Invalid bitcode version (Producer: '1103.0.32.59.0_0' Reader: '1100.0.33.17_0')', using libLTO version 'LLVM version 11.0.0, (clang-1100.0.33.17)'
file '/Users/admin/jenkins-home/workspace//Pods/FBAudienceNetwork/Static/FBAudienceNetwork.framework/FBAudienceNetwork' for architecture arm64
I've been trying to tweak all possible Jenkins configurations to no avail, I've made sure that Jenkins is using Xcode 11 to build. Modules are enabled and bitcode is disabled for all build types. This is the build command being run
/Applications/Xcode-11.3.app/Contents/Developer" xcodebuild -scheme "CocoCraft-mobile" -configuration "Release"
-workspace ***.xcworkspace -archivePath "/Users/admin/jenkins-home/workspace/***/build/***.xcarchive" archive
Where else should I tweak so I can build successfully?
For anyone who happens across this to, FBAudienceNetwork now requires Xcode 11.6 to compile, and it will fail with that error for Xcode 11.3. So you need to update the Xcode version on your Jenkins
Basically I have built a compiled released framework and distributed it with cocoaPods. The problem is that then archiving this framework application gets the following error:
ld: bitcode bundle could not be generated because
'/Users/cagrialtay/Desktop/mucbirsebepler/ios/Flutter/Flutter.framework/Flutter'
was built without full bitcode. All frameworks and dylibs for bitcode
must be generated from Xcode Archive or Install build file
'/Users/cagrialtay/Desktop/mucbirsebepler/ios/Flutter/Flutter.framework/Flutter'
for architecture armv7 clang: error: linker command failed with exit
code 1 (use -v to see invocation) Search for Enable Bitcode setting
and set it to YES for Debug and Release modes.
Things I tried but had no luck
Enable Bitcode' set to 'YES' Adding '-fembed-bitcode' to 'Other C
Flags' Adding 'BITCODE_GENERATION_MODE' with the value 'bitcode' set
skip install to yes
I only need release version, so I did not built an universal framework, just release version... I would genuinely like to solve this issue, because it has been a nightmare for me..
I finally solved this.This error happened because of me . I develop my iOS application with flutter, so if you develop your iOS app in Flutter firstly you must build with flutter not Xcode
flutter clean
flutter build ios
then go
Xcode -> Product -> Destination -> Any iOS Device
Xcode-> Product -> Scheme -> choose scheme -> Runner
Xcode-> Product -> Archive
or
flutter clean
flutter build ipa
then
Xcode-> Product -> Archive
That happened to me too. Xcode 11, Flutter. I tried deleting the App on Simulator still did not work.
Open project folder
Go to ios file
Go to Runner Folder
Right click on "Launch Screen.storyboard"
Open with Xcode.
We are using HERE iOS SDK Premium Edition with Swift in Xcode 7.3 but when we try to exportArchive with the command:
xcodebuild -exportArchive -exportOptionsPlist exportOptions.plist -archivePath build/App.xcarchive -exportPath build
The exportArchive fails and we run into the error:
ld: bitcode bundle could not be generated because '<path to workspace>/HEREMaps/NMAKit.framework/NMAKit(NMAApplicationContext.o)' was built without full bitcode. All object files and libraries for bitcode must be generated from Xcode Archive or Install build for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Does Here maps support Swift with Xcode 7.3? Is there a project setting we need to set to get it to work?
We are able to run the app in simulator without issue.
Bitcode is a new feature introduces with Xcode 7.
Bitcode is an intermediate representation of a compiled program. Apps
you upload to iTunes Connect that contain bitcode will be compiled and
linked on the store. Including bitcode will allow Apple to re-optimize
your app binary in the future without the need to submit a new version
of your app to the store.
Reference AppThinning Documentation
From the error it seems that the HERE SDK is not bitcode enabled and in your project settings bitcode is enabled. For fixing the issue, there are two possible options:
Use bitcode enabled version of Here SDK (If the vendor provided a bitcode enabled version)
Disable the bitcode in your Build Settings
Xcode 7 introduces Bitcode, which is some sort of LLVM intermediate binary that means Apple's servers can recompile my app for different architectures without my involvement.
At Lookback, I distribute a static archive framework with our library. It seems that when you build with anything but a "Build & Archive", bitcode is not actually emitted into my library, and anyone who links with my library in their app and tries to do a Build & Archive with Bitcode enabled will get one of two warnings:
ld: 'Lookback(Lookback.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. (if lib is built with Xcode 6)
ld: warning: full bitcode bundle could not be generated because 'Lookback(Lookback.o)' was built only with bitcode marker. The library must be generated from Xcode archive build with bitcode enabled (Xcode setting ENABLE_BITCODE) (if lib is built with Xcode 7 with a normal xcodebuild)
I have a build script that builds a device+simulator universal binary, so I can't use Build & Archive, but rather, I run xcodebuild from commandline from my script. How can I make xcodebuild generate a proper bitcode-enabled library?
Bitcode is a compile-time feature (not a link-time feature) which means that every .o file should contain an extra section called __bitcode when built with bitcode. You can confirm whether your binary is bitcode-compatible by running otool -l (my .o or .a file) | grep __LLVM.
When you build normally, Xcode adds the build flag -fembed-bitcode-marker to any clang invocation. This seems to be some sort of 'this is where bitcode would go, if bitcode was enabled' thing, and doesn't actually enable bitcode.
When you "Build & Archive", this flag is replaced by -fembed-bitcode, which really does build a Bitcode-enabled binary.
There seems to be two ways to make xcodebuild use -fembed-bitcode:
Use the 'archive' action, as in xcodebuild -target LookbackSDK archive instead of xcodebuild -target LookbackSDK build. This has the side-effect of putting binaries in your Xcode Organizer instead of the build/ folder, though you can work around that by using -exportArchive -archivePath ./build (thanks #JensAyton)
Force usage of the flag by adding Other C Flags with OTHER_CFLAGS="-fembed-bitcode". Your xcodebuild invocation would look something like xcodebuild OTHER_CFLAGS="-fembed-bitcode" -target LookbackSDK build.
The latter is what I chose so that I don't have to change my build system, but it will generate warnings for every file, since now both -fembed-bitcode-marker and -fembed-bitcode are sent to clang. Luckilly the latter wins, generating a Bitcode-enabled library!
Resources
Apple DevForums: Bitcode and Assembly?
SO: iOS library to BitCode
With Xcode 8, I couldn't get OTHER_CFLAGS="-fembed-bitcode" to work. I kept running into something along the lines of was built without full bitcode. All frameworks and dylibs for bitcode must be generated from Xcode Archive or Install build when I tried to create an Archive build of an app containing my static framework.
What I was really looking for was this:
BITCODE_GENERATION_MODE=bitcode
I'm actually using a Run Script inside of an aggregate target, the full xcodebuild line looks like this (just for reference):
xcodebuild BITCODE_GENERATION_MODE=bitcode OTHER_CFLAGS="-fembed-bitcode" -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
Once you add bitcode support for the static lib, it won't be compatible with Xcode 6. The app won't archive.
I would like to clearly mention the setting for bitcode as #nevyn's answer confused me a little.
Go to Build settings, search for "custom compiler flags". Add -fembed-bitcode. This will build your lib with bitcode.
Select project
On Build Settings -> Other C flags, set Debug to -fembed-bitcode-marker and Release to -fembed-bitcode
On Build Settings, click on the + sign at the top to add a user-defined build setting with the name BITCODE_GENERATION_MODE, and set Debug to marker, Release to bitcode
Edit schema as Release
Then click the desired library. A file and get the build path.
Get the library form Release folder.
There are 2 compile errors in my project(Display in XCode).
But when I use xcodebuild to compile the project in terminal, only one compile error display
xxx$xcodebuild -sdk iphoneos -configuration Debug
....
....
[self updateAccountInfo];1
^
1 warning and 1 error generated.
Is it possible to make xcodebuild display all compile errors?
In the Xcode's Preference, in the General Tab, check the "Continue building after errors" option. asked here
What I need is to use xcodebuild do the same thing.
EDIT:
After thinking and researching these days, I think xcodebuild can't do this. It's different from xcode. When we use xcode to compile iOS project, xcode compile every .m by clang. So xcode has "Continue building after errors" feature
You need to set the Xcode preferences to do this (from Terminal.app):
$ defaults write com.apple.Xcode PBXBuildsContinueAfterErrors YES
for xCode 8:
$ defaults write com.apple.dt.Xcode IDEBuildingContinueBuildingAfterErrors 1
If you want to continue building after errors using the latest version of xcodebuild/xctool you will need to run them with -IDEBuildingContinueBuildingAfterErrors=YES.
Example:
xctool -project SampleProject.xcodeproj/ -scheme SampleProject -sdk iphonesimulator build -IDEBuildingContinueBuildingAfterErrors=YES
Looks like PBXBuildsContinueAfterErrors isn't supported anymore.
Also you can use defaults write com.apple.dt.Xcode to make this setting permanent. If you want to have a look how you current version of IDE is controlling that setting you can call defaults read com.apple.dt.Xcode and search for "errors" and "continue".