indyfromoz
indyfromoz

Reputation: 3763

Cocoapod depedency in a XCFramework distributed as a Cocoapod

I have a XCFramework Xcode project that includes -

  1. Some code which provides some APIs implemented the SDK (the "SuperSDK"),
  2. An "Internal" (closed-source) XCFramework,
  3. A XCFramework of a third-party (A) SDK, and,
  4. Another third-party (B) SDK added a Cocoapod dependency.

A Podfile specifies the third-party (B) SDK Cocoapod dependency. I use the XCWorkspace generated via pod install to create the XCFramework. The Podfile for SuperSDK.xcodeproj is setup as -

target 'SuperSDK' do
  use_frameworks!

  pod 'ThirdPartyBSDK'
end

SuperSDK XCFramework shipped as a zipped distribution

The SuperSDK.xcframework is distributed as a Cocoapod. The Podspec looks like so -

Pod::Spec.new do |s|
  s.name             = 'SuperSDK'
  s.version          = '0.1.0'
  s.summary          = 'Super SDK'


  s.description      = 'SuperSDK Cocoapod'

  s.homepage         = 'https://supersdk.com'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'SuperSDK' => '[email protected]' }
  s.source           = { :http =>  'file://' + __dir__ + '/SuperSDK.zip', :type => 'zip' }
  s.xcconfig         = { 'FRAMEWORK_SEARCH_PATHS' => '"$(PODS_ROOT)/SuperSDK/**"' }
  s.module_name = 'SuperSDK'

  s.ios.deployment_target = '14.0'

  s.dependency 'ThirdPartyBSDK'

  s.vendored_frameworks = 'SuperSDKPod/Frameworks/SuperSDK.xcframework', 'SuperSDKPod/Frameworks/Internal.xcframework', 'SuperSDKPod/Frameworks/ThirdPartyA.xcframework'

end

The Cocoapod of "SuperSDK" is added to a simple iOS app project using Cocoapods with a Podfile -

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'ios' do
  use_frameworks!

  pod 'SuperSDK', :path => '../pod/SuperSDK.podspec'

  # Pods for ios

  target 'iosTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'iosUITests' do
    # Pods for testing
  end

end

The iOS app compiles and is loaded in the Simulator where it crashes with a dyld error -

dyld[29662]: Symbol not found: _$s12ThirdPartyBSDK0A0C09setTelemetryA6Server3urlySS_tKFTj
  Referenced from: <26968490-638C-3390-9E3E-0DDEC07ACA87> /Users/alpha/Library/Developer/CoreSimulator/Devices/0451AD73-E1EC-4568-8BD5-227DFA87FB90/data/Containers/Bundle/Application/331216E1-417E-4790-B037-B037B9B27D35/Demo Prod Debug.app/Frameworks/SuperSDK.framework/SuperSDK
  Expected in:     <3709E85E-A65D-39CE-ABE4-1BC07F9CD0F4> /Users/alpha/Library/Developer/CoreSimulator/Devices/0451AD73-E1EC-4568-8BD5-227DFA87FB90/data/Containers/Bundle/Application/331216E1-417E-4790-B037-B037B9B27D35/Demo Prod Debug.app/Frameworks/ThirdPartyBSDK.framework/ThirdPartyBSDK
Message from debugger: killed

In the current setup, do I need to build the source files of ThirdPartyBSDK.xcframework and include it as a vendored_frameworks specified via the Podspec of SuperSDK?

Upvotes: 0

Views: 189

Answers (1)

narek.sv
narek.sv

Reputation: 1575

First, make sure you properly generate the SuperSDK.xcframework with this xcodebuild -create-xcframework ... command and link all dependencies.

Then you don't need to specify any further dependencies in your podspec. It should look like something like this:

Pod::Spec.new do |s|
  s.name             = "SuperSDK"
  s.version          = "0.1.0"
  s.summary          = "Super SDK"
  s.description      = "SuperSDK Cocoapod"
  s.homepage         = "https://supersdk.com"
  s.license          = { :type => "MIT", :file => "LICENSE" }
  s.author           = { "SuperSDK" => "[email protected]" }
  s.source           = { :http => "URL_TO_YOUR_ZIP/SuperSDK.zip" }
  s.vendored_frameworks = "SuperSDKPod/Frameworks/SuperSDK.xcframework"
  s.platform = :ios
  s.ios.deployment_target = "14.0"

end

Upvotes: 0

Related Questions