iOS framework开发模拟器编译报错:Pods中的库架构不全

527 阅读1分钟

出现问题的环境: framework的 .podspec中配置了'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' 使用Pods集成上述framework,在真机正常编译,在M1芯片模拟器编译出现错误:

Pods中的xxx.framework building for iOS Simulator-x86_64 but attempting to link with file built for iOS Simulator-arm64

此时应该修改Pods.xcodeproj中的targets设置,依次将各实际target的 ONLY_ACTIVE_ARCH 设置为 NO,也可以在集成该framework的podfile最后追加如下设置:

post_install **do** |installer|
  installer.pods_project.targets.each **do** |target|
    target.build_configurations.each **do** |config|
      config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
    end
  end
end

即可解决模拟器编译错误。