IOS:我正在创建自己的 swift 包管理器。因为我对 PubNub SDK 有依赖。
dependencies: [
.package(url: "https://github.com/pubnub/swift.git", from: "7.0.0")
]
现在的要求是为具有依赖关系的 swift 包管理器创建 xcframework。在xcframework中如何添加pubnub依赖?
我尝试使用第三方库创建xcframework: https://github.com/unsignedapps/swift-create-xcframework当
我在 xcode 项目中使用这个 xcframwork,它给 PubNub 带来错误。所以似乎它没有被添加到 xcframwework 中。
WWDC 2019 (416),二进制框架不能依赖 Swift 包。您可以尝试以下步骤:
PubNub
中的每个平台构建
.xcframework
目标。以下是如何在
iOS
配置中分别对
iOS Simulator
和
Debug
执行此操作的示例。您可以通过代码签名重复相同的步骤进行
Release
配置。
# iOS Simulator
xcodebuild -target PubNub -scheme PubNub -configuration Debug -arch x86_64 -arch arm64 -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES -derivedDataPath build
# iOS devices
xcodebuild -target PubNub -scheme PubNub -configuration Debug -arch arm64 -sdk iphoneos ONLY_ACTIVE_ARCH=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES -derivedDataPath build
xcodebuild -create-xcframework -framework build/Build/Products/Debug-iphoneos/PubNub.framework -framework build/Build/Products/Debug-iphonesimulator/PubNub.framework -output PubNub.xcframework -allow-internal-distribution
Framework
模板)并在
PubNub.xcframework
部分下添加
Link Binary with Libraries
作为依赖项。正如我在第一步中所做的那样,您可以为不同平台构建新创建的目标。