我们的目标是创建一个框架来隐藏我们的内部代码并向我们的客户提供 SDK.我们已经考虑创建满足我们要求的 XCFramework.互联网上也建议使用伞形框架,但大多建议避免这种方法.我们的框架依赖于我们通过 Pods 使用的一些第三方库.
Our goal is to create a framework that hides our internal code and provide SDK to our customers. We have thought of creating XCFramework which fulfills our requirement. Umbrella framework is also suggested over the internet but mostly suggested to avoid that approach. Our Framework is dependent on some third-party libraries which we are using via Pods.
问题:XCFramework 不编译 pods 框架.我们收到类似未找到 Xyz(Pod) 模块"的错误.即使我们从客户端添加 pod,它也不起作用.
创建XCFramework的代码如下
Code to create XCFramework is as bellow
1) 为 iOS 平台创建存档
xcodebuild archive -workspace ABC.xcworkspace
-scheme ABC
-sdk iphoneos
-archivePath "./archives/ios_devices.xcarchive"
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
SKIP_INSTALL=NO
2) 为 iOS-Simulator 平台创建存档
xcodebuild archive -workspace ABC.xcworkspace
-scheme ABC
-sdk iphonesimulator
-archivePath "./archives/ios_simulators.xcarchive"
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
SKIP_INSTALL=NO
3) 从档案中创建 XCFramework
xcodebuild -create-xcframework
-framework ./archives/ios_devices.xcarchive/Products/Library/Frameworks/ABC.framework
-framework ./archives/ios_simulators.xcarchive/Products/Library/Frameworks/ABC.framework
-output build/ABC.xcframework
我们成功获得了 ABC XCFramework,但依赖项不包含在 XCFramework 中.有什么解决办法吗?或者有什么方法可以将框架搜索路径设置为客户端?或任何替代方法?
We got ABC XCFramework successfully but dependencies are not included in XCFramework. Any solution for this? or Is there any way where we can set framework search path to client-side? or Any alternate approach?
你可以创建一个pod并发布它.
You can create a pod and publish it.
检查 https://guides.cocoapods.org/making/making-a-cocoapod.html
带有 XCFramework + 第三方依赖的示例 Podspec 文件
Sample Podspec file with XCFramework + Third party dependency
Pod::Spec.new do |s|
s.name = 'XCFrameworkTest' # Name for your pod
s.version = '0.0.1'
s.summary = 'Sample Spec'
s.homepage = 'https://www.google.com'
s.author = { 'Sample' => 'sample@sample.com' }
s.license = { :type => "MIT", :text => "MIT License" }
s.platform = :ios
# change the source location
s.source = { :http => 'http://localhost:8080/XCFrameworkTest.zip' }
s.ios.deployment_target = '10.0'
s.ios.vendored_frameworks = 'XCFrameworkTest.xcframework' # Your XCFramework
s.dependency 'PromisesSwift', '1.2.8' # Third Party Dependency
end
发布 pod 后,客户可以使用 cocopods 获取我们的框架.
After you publish your pod, Customer can use cocopods to get our framework.
在客户的 Podfile 中
In Customer's Podfile
pod 'XCFrameworkTest' #Your pod name
这篇关于具有 Pod 依赖项的 XCFramework的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!