Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vendored framework with dependencies cocoapods linking error

I need to ship a compiled framework - let's call it Abc.framework with cocoapods.

This framework has some dependencies - let's assume I need Nomosi and KeychainSwift.

Podfile:

platform :ios, '10.0'
use_frameworks!

target 'Abc' do
  pod "Nomosi", "0.1.2"
  pod "KeychainSwift", "18.0"
end

I'm able to build a fat framework using a script like this.

Podspec:

Pod::Spec.new do |s|
  s.name             = 'Abc'
  s.version          = '0.0.1'
  s.summary          = 'Abc description.'
  s.description      = 'Abc looong description.'
  s.homepage         = 'https://test.com'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'Author' => '[email protected]' }
  s.source           = { :git => 'https://github.com/test/this-is-not-a-repo.git', :tag => s.version.to_s }
  s.ios.deployment_target = '10.0'
  s.public_header_files = "Build/Abc.framework/Headers/*.h"
  s.source_files = "Build/Abc.framework/Headers/*.h"
  s.vendored_frameworks = 'Build/Abc.framework'
  s.dependency 'KeychainSwift', '18.0'
  s.dependency 'Nomosi', '0.1.2'
end

Now if I create a demo project using the local pod it compiles but there's a runtime crash:

dyld: Symbol not found: _$s6Nomosi15ServiceResponseP5parse4dataxSg10Foundation4DataV_tKFZTq
  Referenced from: /Users/mario/Library/Developer/CoreSimulator/Devices/DFF39FE4-F274-4E4E-9710-AB24B043CFB0/data/Containers/Bundle/Application/A9C811DE-19D6-4535-996B-B5F2D142D691/AbcDemo.app/Frameworks/Abc.framework/Abc

If the podspec points to the actual source code (instead of shipping the compiled fat framework) the app doesn't crash.

This is probably related to some linking error in the framework (@rpath?) but I really don't know how to fix it.

like image 256
Mario Avatar asked Oct 23 '25 15:10

Mario


1 Answers

The build script might need the option BUILD_LIBRARY_FOR_DISTRIBUTION=YES

I can only find minimal docs at https://xcodebuildsettings.com/:

Ensures that your libraries are built for distribution. For Swift, this enables support for library evolution and generation of a module interface file.

I'm assuming that the option should also make sure that all symbols that could be used by any random client library or app are properly exported.

like image 171
Paul Beusterien Avatar answered Oct 25 '25 05:10

Paul Beusterien