SolvedCocoaPods XCFrameworks slice selection fails in multiple ways
✔️Accepted Answer
@trevinwisaksana I had this same issue with the AppCenter Cocoapod today. I fixed it by removing an recursive path ($(SRCROOT)/**
) from the Framework Search Path in the target (though it could also be in the project) Build Settings.
The recursive path was causing XCode to add every folder into the Link step including (incorrectly) the architecture folders inside of the xcframework, and using those paths it would find the wrong architecture framework. You can tell if this is the case by looking at the Link step log
for paths similar to this:
-FPods/AppCenter/AppCenter-SDK-Apple/AppCenter.xcframework/ios-arm64_arm64e_armv7_armv7s
-FPods/AppCenter/AppCenter-SDK-Apple/AppCenter.xcframework/ios-arm64_i386_x86_64-simulator
-FPods/AppCenter/AppCenter-SDK-Apple/AppCenter.xcframework/ios-arm64_x86_64-maccatalyst
-FPods/AppCenter/AppCenter-SDK-Apple/AppCenter.xcframework/macos-arm64_x86_64
-FPods/AppCenter/AppCenter-SDK-Apple/AppCenter.xcframework/tvos-arm64
-FPods/AppCenter/AppCenter-SDK-Apple/AppCenter.xcframework/tvos-arm64_x86_64-simulator
Other Answers:
I believe this bug or at least a variation of it might still be occurring. I'm getting a build issue only on my Development configuration because Cocoapods is selecting the wrong slice of the XCFramework. This prevents me from building for a simulator but it works normally when building for a device.
It correctly selected the correct slice at first as shown on the logs. But then notice that it's still looking for the x86_64 architecture in the ios-arm64_armv7 folder.
missing required architecture x86_64 in file Pods/Crisp/Crisp.xcframework/ios-arm64_armv7/Crisp.framework/Crisp (2 slices)
I'm using Xcode 12.2 and Cocoapods 1.10 to generate this.
Report
What did you do?
Integrating a pod distributed as a xcframework.
What did you expect to happen?
The xcframework pod to be handled properly by Cocoapods and for the target to compile without errors.
What happened instead?
The shell script generated by copy_xcframework_script.rb does not handle all xcframeworks correctly.
Example 1
Given the following xcframework:
When compiling on a device or using the Any iOS Device destination. The pod's
copy_xcframework_script.rb
will select the simulator slice instead of the device slice.This leads to the following compilation error on the target:
Example 2
Given the following xcframework:
When compiling on a device or using the Any iOS Device destination. The pod's
copy_xcframework_script.rb
will fail to select a slice in the xcframework:As you can see, the slice
ios-arm64_armv7
contains all the architectures needed (armv7 arm64
). The script fails to select this slice due to the following regex:That regex fails to match the target architecture in the string
ios-arm64_armv7
. A possible fix for that regex is:"[_\-]${target_arch}([\/_\-]|$)"
Notes
In both examples, the xcframeworks were:
CocoaPods Environment
Stack
Installation Source
Plugins
Podfile
Project that demonstrates the issue
Example 1 - SampleXCFramework.zip
Example 2 - AppboyKit.xcframework.zip