Xcode12打包SDK发布到cocoapods验证失败的解决方法

  • 错误信息如下
** BUILD FAILED **
The following build commands failed:
Ld /Users/xxx/Library/Developer/Xcode/DerivedData/
App-ffbcalrxowejfwejfwpfjwpoe/Build/Intermediate.noindex/App.build/
Release-iphonesimulator/App.build/Objects-normal/arm64/Binary/App normal arm64
  • 搜索到的解决方法
    https://github.com/CocoaPods/CocoaPods/issues/10065#issuecomment-694513007

My understanding of this issue is that the cocoapods validation step is trying to build a dummy Xcode project for all architecture types. In Xcode 12, Apple introduced support for Apple Silicon and it uses arm64 for the simulator. For iOS x86_64 is used for the simulator.
My pod does not yet support Apple Silicon and I explicitly do not bundle an arm64 architecture slice for the simulator in my binary. Therefore when cocoapods was performing its validation and running an xcodebuild for all architectures, it failed when building for arm64 simulator architecture.

The solution is to explicitly exclude the arm64 architecture slice for the simulator by adding the following to the podspec.
s.pod_target_xcconfig = {
    'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64'
  }
s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }

This will modify the pod and user build settings to exclude the arm64 architecture for the simulator. Most users will have Build For Active Architectures Only set to YES, so they won't see this. But if they don't this will prevent a build failure.

The long term solution is to use an XCFramework binary to distribute your pod because it will be able to bundle all architecture slices in the one binary.

你可能感兴趣的:(Xcode12打包SDK发布到cocoapods验证失败的解决方法)