Cocoapods 环绕一个没有 i386 架构的静态库

Tia*_*oso 5 ios cocoapods

我正在尝试为作为静态库分发的第三方 SDK 编写一个 pod。

我已经设法让它大部分工作。但是,我无法为模拟器构建 pod。我试图包含的静态库似乎不支持i386也不支持x86_64架构。

运行pod lib lint myPod.podsoec我得到:

- NOTE | [iOS] xcodebuild: ld: warning: ignoring file libMyLib.a, missing required architecture x86_64 in file libMyLib.a (3 slices)
- NOTE | [iOS] xcodebuild: ld: warning: ignoring file libMyLib.a, missing required architecture i386 in file libMyLib.a (3 slices)
Run Code Online (Sandbox Code Playgroud)

我无权访问静态库的代码。所以我不能添加缺少的架构。

我不需要在模拟器中使用 lib 的功能。但我不想失去将我的应用程序构建到模拟器的可能性。最终我需要在模拟器上运行单元测试。

有没有办法解决这个问题?

编辑

添加了 podspec

Pod::Spec.new do |s|
  s.name             = 'myPod'
  s.version          = '0.1'
  s.summary          = 'A basic wrapper around a Cool SDK.'
  s.description      = <<-DESC
  A basic wrapper around a Cool SDK.

  A library for audio watermarking
                       DESC

  s.homepage         = 'My HomePage'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'Tiago Veloso' => 'tiago.veloso@email.com' }
  s.source           = { :git => 'myPrivateRepo', :tag => s.name.to_s + '-' + s.version.to_s }
  s.platform         = :ios

  s.ios.deployment_target = '8.0'

  s.source_files           = 'Classes/**/*.{h,m}','include/*.h'
  s.public_header_files    = 'Classes/**/*.h','include/*.h'
  s.ios.vendored_libraries = 'Vendored/libMyLib.a'
  s.frameworks             = 'System Frameworks'
end
Run Code Online (Sandbox Code Playgroud)

Sve*_*ker 4

在 cocoapods 中没有默认的方式来限制架构。

选项 1:使用pod lib lint --allow-warnings让 linter 忽略警告并成功

选项 2:通过将以下内容添加到 podspec 中,强制仅为非模拟器架构构建 pod:

s.pod_target_xcconfig = { 'VALID_ARCHS' => 'arm64 armv7' }
Run Code Online (Sandbox Code Playgroud)

这不包括 i386 和 x86_64,并且不应被客户端项目覆盖。如果客户端项目覆盖了这个,你也可以尝试

s.user_target_xcconfig = { 'VALID_ARCHS' => 'arm64 armv7' }
Run Code Online (Sandbox Code Playgroud)

但这可能会导致 linter 无法编译测试项目。

提醒:覆盖 VALID_ARCHS 始终是一个坏主意,只有在有充分理由的情况下才应该这样做。没有供应的第三方库的 i386 / x86_64 片段似乎在这里。

有关更多信息,请参阅podspec 文档。