我公司中的某人创建了一个 swift package
sdk
,现在我被任命以 binary
方式将其发布给客户,以便最终客户这将使用 SDK
将无法看到它的源代码
。这就是SDK的构建方式:
xcode in xcode (ps构建文件夹是空的),
我从我的阅读中读取了我了解的主题 )我需要将文件导出到 xcframework
文件中。 指南都解释了如何从框架
而不是从我的情况下从 framework
。
但是,我遇到的绝大多数 发现这似乎完全像我需要的是 this 一个,但是我在第一个相关终端命令上出现错误=“ ./构建” 。这是我得到的主要错误行: XcodeBuild:错误:构建Swift软件包要求使用“ - 终止”选项提供目标。 “ -showdestinations”选项可用于列出可用目的地。
。为什么我需要指定目的地?我希望SDK适用于所有设备(iOS 13+)。我在网上搜索的论坛的非论坛帮助我解决了这个问题。
我还阅读了苹果的说明在这里,但对终端的困惑非常困惑在我的情况下,步骤2中的命令应该看起来像。有些领域是强制性的,有些不是吗?
任何帮助将不胜感激!!
Someone in my company created a Swift package
SDK
and now I was tasked to publish it for the customer in a binary
way so that the end customers that will use the SDK
will not be able to see the source code
of it. This is how the SDK is built:
the SDK in xcode (p.s. the build folder is empty)
From my reading on the subject I understand that I need to export the files into an XCFramework
file. However, the vast majority of guides I've encountered explain how to make this progress from a framework
, and not from a package
like in my case..
The only guide I found that seems exactly like what I need is this one, however I get an error right on the first relevant terminal command of xcodebuild -scheme [my scheme name] -sdk iphoneos -configuration Release ARCHS="arm64" BUILD_DIR="./Build"
. This is the main error line I get: xcodebuild: error: Building a Swift package requires that a destination is provided using the "-destination" option. The "-showdestinations" option can be used to list the available destinations.
. Why would I need to specify a destination? I want the SDK to work for all the devices (ios 13+). Non of the forums I searched in online helped me solve this.
I also read Apple's instructions here but got very confused about how the terminal command in step 2 is supposed to look like in my case. Are some of the fields mandatory and some are not?
Any help would be much appreciated!!
发布评论
评论(1)
假设您仅使用iOS,并且需要用于设备和模拟器架构的XCFramework,以便从Swift软件包中生成XCFramework,则需要:
.dynamic
(即.library(名称:“ foo”,type:.dynamic,targets:[“ foo”])
))模块
文件夹(如果有),将.xcarchive文件此处是基于一个bash脚本,基于一个bash脚本来自这个swift论坛post 从Swift软件包中创建XCFramework(就我而言,我的软件包在XCWorkspace中。我没有尝试作为独立软件包,不确定是否可以完成的):
根据需要更改输入参数:),但最重要的是替换
<您的项目名称>
and< workspace>
。当脚本结束时,您将在输出文件夹中看到3个文件:
您可以删除XCarchives,因为您不再需要它们(您还可以更新脚本以为您完成此操作)。
Assuming you are working with iOS only and you need an xcframework for both device and simulator architectures, in order to generate an XCFramework from a swift package you need to:
.dynamic
(i.e..library(name: "Foo", type: .dynamic, targets: ["Foo"])
)Modules
folders (if any) into the .xcarchive filesHere's a bash script, based on the one from this swift forums post, to create an XCFramework from a swift package (in my case, I have my package inside an xcworkspace. I didn't try it as a standalone package, not sure if that can be done):
Change the input parameters as needed :), but most importantly replace
<Your project name>
and<your workspace>
.When the script ends, you will see 3 files in the output folder:
You can remove the xcarchives, as you won't need them anymore (you can also update the script to do that for you).