为 swift 包管理器创建 Xcframework,它依赖于另一个 swift 包管理器

问题描述 投票:0回答:1

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 中。

ios swift swift-package-manager pubnub xcframework
1个回答
0
投票
根据

WWDC 2019 (416),二进制框架不能依赖 Swift 包。您可以尝试以下步骤:

    为您想要包含在
  1. 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

    根据上一步收到的结果创建最终的
  1. .xcframework
    。我必须添加 
    allow-for-internal-distribution
     标志来解决
    here提到的问题
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

    接下来,创建一个新的 Xcode 目标(选择
  1. Framework
     模板)并在 
    PubNub.xcframework
     部分下添加 
    Link Binary with Libraries
     作为依赖项。正如我在第一步中所做的那样,您可以为不同平台构建新创建的目标。
© www.soinside.com 2019 - 2024. All rights reserved.