Reputation: 251
I am making a xcframework. In my framework project, I have added cocoa pods like Alamofire, Realm, and more. When I integrate my xcframework in my application, the application crashes showing following error:
dyld: Symbol not found: _$s9Alamofire10HTTPMethodO3getyA2CmFWC
Referenced from: /private/var/containers/Bundle/Application/E81F9FBA-3876-4959-B675-B89A4EC0257A/BykesPod.app/Frameworks/MYFRAMEWORK.framework/MYFRAMEWORK
Expected in: /private/var/containers/Bundle/Application/E81F9FBA-3876-4959-B675-B89A4EC0257A/DEMOAPP.app/Frameworks/Alamofire.framework/Alamofire
in /private/var/containers/Bundle/Application/E81F9FBA-3876-4959-B675-B89A4EC0257A/DEMOAPP.app/Frameworks/MYFRAMEWORK.framework/MYFRAMEWORK
dyld: launch, loading dependent libraries
DYLD_LIBRARY_PATH=/usr/lib/system/introspection
DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
Following is the pod file of my framework project
target 'MYFRAMEWORK' do
project './MYFRAMEWORK.xcodeproj'
pod 'Realm'
pod 'RealmSwift'
pod 'Alamofire', '~> 4.8'
pod 'MBProgressHUD','1.1.0'
pod 'SwiftyJSON'
end
I have added following dependencies in my podspec file:
s.dependency "Realm"
s.dependency "RealmSwift"
s.dependency "Alamofire","~> 4.8.2"
s.dependency "MBProgressHUD","~> 1.1.0"
s.dependency "SwiftyJSON"
Following is the pod file of my demo application:
target 'DEMOAPP' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
pod 'PODNAME'
end
Following are the commands from which I am making xcframeworks
xcodebuild archive -workspace MYFRAMEWORK.xcworkspace -scheme MYFRAMEWORK -sdk iphoneos -archivePath "archives/0/ios_device.xcarchive" BUILD_LIBRARY_FOR_DISTRIBUTION=YES SKIP_INSTALL=NO
xcodebuild archive -workspace MYFRAMEWORK.xcworkspace -scheme MYFRAMEWORK -sdk iphonesimulator -archivePath "archives/0/ios_simulators.xcarchive" BUILD_LIBRARY_FOR_DISTRIBUTION=YES SKIP_INSTALL=NO
xcodebuild -create-xcframework -framework archives/0/ios_device.xcarchive/Products/Library/Frameworks/MYFRAMEWORK.framework -framework archives/0/ios_simulators.xcarchive/Products/Library/Frameworks/MYFRAMEWORK.framework -output build/MYFRAMEWORK.xcframework
Note: My code xcode version is 12.4
Upvotes: 2
Views: 1730
Reputation: 13600
Solution to this problem is to enable following option in Target Build setting
Build Libraries for distribution
Note: If you are distributing Project/Library/Framework and it contains/depends on Cocoapods
add following script into your destination Project where framework is integrated.
This script enables Build Libraries for distribution
for all installing Cocoapod
dependencies.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end
Upvotes: 1
Reputation: 251
Currently, the solution I found was to make the "Build Libraries for distribution" flag true in the Pods project of my application. See attached screenshot.
Upvotes: 0