Xcode does not found symbols for architecture x86_64 using XCFrameworks
Asked Answered
S

1

6

Xcode (11.2.1 & 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's looks like xcodebuild always go to the ios-armv7_arm64 folder instead the ios-i386_x86_64-simulator one, Any ideas?

Thank you!

Shun answered 7/2, 2020 at 15:25 Comment(4)
Did you manage to solve this?Metrology
@Metrology there is a cocoapods issue looking foward to solve this. Link : github.com/CocoaPods/CocoaPods/issues/9525Shun
@LeandroFuryk did you manage to find a way out?Hekate
Same problem.I guess you have swift and objc file in mix?Sutra
M
0

Hey please generate with -sdk flag with this combination:

xcodebuild archive -workspace IVTNetworking.xcworkspace  -scheme IVTNetworking \
 -configuration Debug  -sdk iphoneos  \
 -archivePath '/Users/chitaranjans/Library/Developer/Xcode/Archives /IVTNetworking.framework-iphoneos.xcarchive' \
 SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES

This works fine as expected.

Mordecai answered 2/10, 2020 at 18:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.