Xcode does not found symbols for architecture x86_64 using XCFrameworks

Xcode (11.3.1) is having issues to found x86_64 architecture symbols while using XCFrameworks. The problem is that the architecture is inside the XCFramework, but first let me show you how the framework was created.


To generate the XCFramework I made two Archives:

  1. For iOS:
    xcodebuild archive -scheme MyPod -target MyPod -destination="iOS" -archivePath build/ios.xcarchive -derivedDataPath /tmp/iphoneos -sdk iphoneos SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
  2. For iOS Simulator:
    xcodebuild archive -scheme MyPod -target MyPod -destination="iOS Simulator" -archivePath build/iossimulator.xcarchive -derivedDataPath /tmp/iphoneos -sdk iphonesimulator SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES


Then I generated the XCFramework:

     xcodebuild -create-xcframework -framework      ./build/ios.xcarchive/Products/Library/Frameworks/MyPod.framework -framework      ./build/iossimulator.xcarchive/Products/Library/Frameworks/MyPod.framework -output      xcframework/MyPod.xcframework


Here is the XCFramework created where we can see the two architectures: XCFramework preview


Once it was created, I distributed it by Cocoapods (1.9.0.beta.3). So my .podspec looks like:


     s.subspec "Vendored" do |framework|
          framework.vendored_framework = 'xcframework/MyPod.xcframework'
     end


Then I consumed it in another project, and when compiling, it fails because it can't find the architecture for the simulator (on devices it works)

The log I got is the following:


ld: warning: ignoring file /Path/To/MyProject/Pods/MyPod/xcframework/MyPod.xcframework/ios-armv7_arm64/MyPod.framework/MyPod, missing required architecture x86_64 in file /Path/To/MyProject/Pods/MyPod/xcframework/MyPod.xcframework/ios-armv7_arm64/MyPod.framework/MyPod (2 slices) Undefined symbols for architecture x86_64: "_OBJC_CLASS_$MyPod", referenced from: objc-class-ref in SomeClass.o ld: symbol(s) not found for architecture x86_64


It looks like xcodebuild always go to the

ios-armv7_arm64
folder instead the
ios-i386_x86_64-simulator
one, any ideas?


Thank you!

Accepted Reply

The destination arguments should be -destination "generic/platform=iOS" and -destination "generic/platform=iOS Simulator". Here is the documentation with this info. Also, test integrating the XCFramework into another project without involving CocoaPods to determine if they are contributing to this issue.

Replies

The destination arguments should be -destination "generic/platform=iOS" and -destination "generic/platform=iOS Simulator". Here is the documentation with this info. Also, test integrating the XCFramework into another project without involving CocoaPods to determine if they are contributing to this issue.

Thank you for the answer!


I tried again without using Cocoapods y it works!

I am facing similar issue with XCode 12.2 for my custom framework. I tried by specifying -destination. Still result is same.
Generated XCFramework don't have x86_64 architecture symbols.