2

I am building an iOS Framework via a build script. It builds fine. When I include it to my project, archive it and try to publish it for Enterprise I get the following error in the logs

NSLocalizedDescription=Failed to verify bitcode in...

I am building via a script

xcodebuild -project "${PROJECT_FILE_PATH}" -target "${TARGET_NAME}" -configuration "${CONFIGURATION}" -sdk iphoneos BUILD_DIR="${BUILD_DIR}" OBJROOT="${OBJROOT}" BUILD_ROOT="${BUILD_ROOT}" CONFIGURATION_BUILD_DIR="${IPHONE_DEVICE_BUILD_DIR}/arm64" SYMROOT="${SYMROOT}" BITCODE_GENERATION_MODE=bitcode OTHER_CFLAGS="-fembed-bitcode" ARCHS='arm64' VALID_ARCHS='arm64' $ACTION

xcodebuild -project "${PROJECT_FILE_PATH}" -target "${TARGET_NAME}" -configuration "${CONFIGURATION}" -sdk iphoneos BUILD_DIR="${BUILD_DIR}" OBJROOT="${OBJROOT}" BUILD_ROOT="${BUILD_ROOT}"  CONFIGURATION_BUILD_DIR="${IPHONE_DEVICE_BUILD_DIR}/armv7" SYMROOT="${SYMROOT}" BITCODE_GENERATION_MODE=bitcode OTHER_CFLAGS="-fembed-bitcode" ARCHS='armv7 armv7s' VALID_ARCHS='armv7 armv7s' $ACTION

rm -rf "${UNIVERSAL_OUTPUTFOLDER}"
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework"

lipo -create  "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/arm64/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/armv7/${PROJECT_NAME}.framework/${PROJECT_NAME}" -output "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}"

defaults write "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/Info.plist" CFBundleSupportedPlatforms -array 'iPhoneOS'

The last line is there to change the key in the plist to iPhoneOS (I was getting another error without it).

I am enabling OTHER_CFLAGS="-fembed-bitcode" but I still get the error. Any ideas?

Mike M
  • 4,879
  • 5
  • 38
  • 58
  • Have you tried adding the BITCODE_GENERATION_MODE user defined build setting for your iOS target and setting its value to bitcode ? I had several problems building watchOS and tvOS frameworks with bitcode enabled and the BITCODE_GENERATION_MODE build setting fixed my issues. – iOSAddicted Oct 06 '16 at 12:28
  • Yep ;-( BITCODE_GENERATION_MODE=bitcode – Mike M Oct 06 '16 at 13:43
  • I see you build your target twice, one time for armv7 and armv7s and the other for arm64. Why wouldn't you just build it once for armv7 armv7s and arm64? Then you would not have to do a lipo -create to merge the 2 executables... Also, the 2nd time you build the BITCODE_GENERATION_MODE flag is not being passed. Is there any particular reason you could just not build it once? – iOSAddicted Oct 09 '16 at 17:48
  • To be honest I copied and modified the script, so I did not experiment a lot with it. What you say sounds reasonable but I do not think it has anything to do with bitcode support. – Mike M Oct 10 '16 at 07:20
  • So I am not sure that the 2nd build you do for armv7s is including bitcode. Would you mind adding the BITCODE_GENERATION_MODE flag to the second xcodebuild command as well and see what is the result? – iOSAddicted Oct 10 '16 at 12:54
  • @iOSAddicted Thanks for the suggestion, but I added it to no avail. – Mike M Oct 10 '16 at 13:15
  • 1
    I am having the same issue in iOS. When I build the Fat framework that contains all architectures, bitcode is missing for x86_64 and i386. I tried many different solutions and nothing works. Hopefully someone can come and solve the issue – iOSAddicted Oct 14 '16 at 01:58
  • 1
    I got a working solution. Since the FAT binaries being produced don't include bitcode for x86_64 and i386 you will have to strip those architectures when the consuming applications are exporting their ipa. I would suggest taking a look at the following link: https://www.mapbox.com/ios-sdk/#manual You will need to include the strip-framework.sh into your Framework and then make sure the consumer app adds the build-phases run script. You can find the script in the following link: https://github.com/realm/realm-cocoa/blob/master/scripts/strip-frameworks.sh – iOSAddicted Oct 14 '16 at 13:38
  • @MikeM where you able to solve this problem? – hariszaman Oct 12 '17 at 15:42
  • @hariszaman No, I've moved on from this. – Mike M Oct 13 '17 at 08:31

0 Answers0