4

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' => 'me@test-email.com' }
  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.

Mario
  • 470
  • 4
  • 9
  • 1
    I had very similar problem. This helped me: https://stackoverflow.com/questions/64657668/custom-framework-dyld-symbol-not-found-s11cryptoswift7paddingo5pkcs7ya2cmf – Juki Mar 27 '21 at 13:01

1 Answers1

2

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.

Paul Beusterien
  • 27,542
  • 6
  • 83
  • 139