Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cocoapods wrapping around a static library without i386 architecture

Tags:

I am trying to write up a pod for a third party SDK, that is being distributed as a static library.

I've managed to get most of it working. However, I can't build the pod for simulator. It seems that the static library I am trying to include does not support i386 nor x86_64 architectures.

Running pod lib lint myPod.podsoec I get:

- 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)

I don't have access to the static lib's code. So I can't add the missing architectures.

I don't need to use the lib's functionality in the simulator. But I don't want to lose the possibility of building my apps to the simulator. Ultimately I need to run Unit Tests on the simulator.

Is there a way around this issue?

EDIT

Added the 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' => '[email protected]' }
  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
like image 317
Tiago Veloso Avatar asked Mar 07 '17 10:03

Tiago Veloso


1 Answers

There is no default way to restrict architures in cocoapods.

Option 1: make the linter ignore warnings and succeed with pod lib lint --allow-warnings

Option 2: Enforce building your pod only for non-Simulator archs by adding this to your podspec:

s.pod_target_xcconfig = { 'VALID_ARCHS' => 'arm64 armv7' }

This excludes i386 and x86_64 and should not be overridden by the client project. If the client project overrides this, you can also try

s.user_target_xcconfig = { 'VALID_ARCHS' => 'arm64 armv7' }

But this could lead to the linter not being able to compile the test project.

Reminder: overriding VALID_ARCHS is always a bad idea, you should only do this if you have a very good reason to do so. Not having the i386 / x86_64 slice of a vendored third party lib seems like one here.

See podspec doc for more info.

like image 187
Sven Driemecker Avatar answered Sep 25 '22 09:09

Sven Driemecker