简体   繁体   English

从 XCFramework 创建 Swift 包:.bundle 应该是 xcframework 的一部分吗?

[英]Creating Swift Package from XCFramework: should .bundle be part of xcframework?

I'm trying to create a swift package from xcframework, the question is if the framework need to load certain resources from a .bundle file, should the bundle be part of the framework, ie.我正在尝试从 xcframework 创建一个 swift 包,问题是框架是否需要从 .bundle 文件加载某些资源,该包是否应该是框架的一部分,即。 xcframework? xc框架? I had the following files in the single zip file:我在单个 zip 文件中有以下文件:

MyPackage.xcframework
MyPackage.bundle

And uploaded it to a host server, in my Package.swift :并将其上传到我的Package.swift中的主机服务器:

targets: [
        .binaryTarget(name: "MyPackage", url: "HOST/MyPackage.xcframework.zip", checksum: "CHECKSUM")
    ]

I can add the Swift Package to my project and use it, but at runtime it cannot find the .bundle file.我可以将 Swift 包添加到我的项目并使用它,但在运行时它找不到.bundle文件。

I found someone having the same problem: https://devforum.zoom.us/t/bundling-the-zoom-sdk-within-a-swift-package/48400我发现有人有同样的问题: https ://devforum.zoom.us/t/bundling-the-zoom-sdk-within-a-swift-package/48400

Even having the .bundle file as dependency in the Package.swift , it doesn't work, unless the bundle file is manually copied into the project.即使将 .bundle 文件作为Package.swift中的依赖项,它也不起作用,除非将捆绑文件手动复制到项目中。

So my question is, should this bundle be part of the .xcframework file instead of being a standalone .bundle file along with the .xcframework file?所以我的问题是,这个包应该是 .xcframework 文件的一部分,而不是与 .xcframework 文件一起成为独立的 .bundle 文件吗? Or if there's something else I can do?或者,如果我还能做些什么?

Thanks!谢谢!

You can use the new approach introduced in Swift 5.3 for bundling resources with your swift package as described here .您可以使用 Swift 5.3 中引入的新方法将资源与您的 swift 包捆绑在一起,如此所述。

Currently, there are two rules that are supported: process rule and copy rule, process rule applies specific processing rules to your resource files depending on whether it is xib, storyboard etc.目前支持的规则有两种:处理规则和复制规则,处理规则根据是xib、storyboard等,对你的资源文件应用特定的处理规则。

In your case, you need to use copy rule to copy the .bundle resource in your app.在您的情况下,您需要使用复制规则来复制应用程序中的.bundle资源。 By default copy rule will copy your file to the root directory of your app, you can decide to provide path to a folder instead if you want to copy your file with specific folder structure.默认情况下,复制规则会将您的文件复制到应用程序的根目录,如果您想复制具有特定文件夹结构的文件,您可以决定提供文件夹的路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 Package.swift 文件转换为二进制 XCFramework - Turn Package.swift file into binary XCFramework 使用 Cocoapods 和 Swift Package 管理器分发 XCFramework - Distributing an XCFramework using both Cocoapods and Swift Package Manager XCFramework's.swiftinterface 在使用 Swift Package Manager 导入时会中断编译 - XCFramework's .swiftinterface breaks compile when imported with Swift Package Manager xcodebuild 使用嵌入式库创建 xcframework - xcodebuild creating xcframework with embedded libraries 您如何归档 Swift Package 依赖项以包含在您的 XCFramework 中以作为 Swift Package 进行二进制分发? - How do you archive Swift Package Dependencies to include in your XCFramework for binary distribution as a Swift Package? 如何将标头添加到 XCFramework package? - How can I add headers to an XCFramework package? 从 GoogleMobileAds.framework 移动到 xcframework 错误 - moving from GoogleMobileAds.framework to xcframework error 我应该在 Xcode 项目中嵌入 XCFramework(第三方)吗? - Should I embed XCFramework (third-party) in a Xcode project? XCFramework生成时如何处理swift动态框架中的可选依赖 - How to handle optinal dependency in swift dynamic framework while XCFramework generating 如何在 xcframework 生成中处理 swift protobuf(静态库)依赖 - How to handle swift protobuf(Static library) dependency in xcframework generation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM