本文介绍了具有Pod依赖项的XCFramework的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的目标是创建一个隐藏我们内部代码并向客户提供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不编译pod框架.我们收到类似未找到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' => '[email protected]' }
    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

发布广告连播后,客户可以使用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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-20 04:05