[英]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.