Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FacebookCore fails to link because of FBSDKCoreKit bitcode errors

I'm trying to use Facebook SDK in Swift. It will compile and run in the Simulator and locally on my device. However, trying to Archive or build in the release configuration fails.

ld: bitcode bundle could not be generated because '/.../DerivedData/FacebookSwift-xyz/Build/Products/Release-iphoneos/FBSDKCoreKit.framework/FBSDKCoreKit' 
    was built without full bitcode. All frameworks and dylibs for bitcode must be 
    generated from Xcode Archive or Install build file '/.../DerivedData/FacebookSwift-xyz/Build/Products/Release-iphoneos/FBSDKCoreKit.framework/FBSDKCoreKit' 
    for architecture arm64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

How to reproduce

Download or clone the Facebook SDK in Swift project, edit the FacebookCore scheme to build the release configuration.

Run Carthage to pull down the dependancies, facebook-ios-sdk et al.

Set <code>FacebookCore</code> scheme to build the Release config

Building the project will now give the error; bitcode bundle could not be generated because '.../FBSDKCoreKit' was built without full bitcode

Project Settings

  • The FBSDKCoreKit target in the FBSDKCoreKit sub-project has "Enable Bitcode" set to "YES".
  • The FacebookCore target also has "Enable Bitcode" set to "YES".
  • The FacebookCore target has 2 target dependancies; Bolts and FBSDKCoreKit, both are the Dynamic framework versions.

Investigation

I have attempted to build the FBSDKCoreKit-Dynamic scheme (in Release config) and that succeeds. The resulting Framework has bitcode (as far as I can tell), running: otool -l "/path/to/framework-binary" | grep -c __LLVM returns 4.

Running file on the binary returns:

/.../FBSDKCoreKit.framework/FBSDKCoreKit: Mach-O universal binary with 2 architectures: [arm_v7:Mach-O dynamically linked shared library arm_v7] [arm64:Mach-O 64-bit dynamically linked shared library arm64]
/.../FBSDKCoreKit.framework/FBSDKCoreKit (for architecture armv7):  Mach-O dynamically linked shared library arm_v7
/.../Release-iphoneos/FBSDKCoreKit.framework/FBSDKCoreKit (for architecture arm64): Mach-O 64-bit dynamically linked shared library arm64

Tools etc

  • Xcode 9.4.1
  • facebook-sdk-swift is version 0.31
  • facebook-ios-sdk (Objective-C) is version 4.34
  • Carthage v0.30.1
  • Deployment target; iOS 8.0 for Facebook frameworks
  • Base SDK: iOS 11.4 (Latest iOS)
  • LLVM v9.0
like image 399
Richard Stelling Avatar asked Jul 03 '18 09:07

Richard Stelling


1 Answers

This has been an issue for quite a while now, I remember investigating it a few months back. Your problem lies - most likely - in the target OS version(8.0). In FBSDKCoreKit the bitcode flag is enabled from iOS11.0. You could try and turn off bitcode for the main target to let it compile. (Or bump up the targeted os version to 11 but I suppose that isn't an option)

like image 152
Andras M. Avatar answered Sep 28 '22 16:09

Andras M.