分发带有Swift包管理依赖项的iOS框架

huangapple go评论60阅读模式
英文:

Distributing an iOS framework with Swift package management dependencies

问题

We正在开发一个名为FramworkSDK的iOS框架,并希望将其作为二进制文件分发给客户。FrameworkSDK依赖于一个名为swift-GRPC的框架。我们使用Swift软件包管理器添加了这个依赖项。

目前,当我将FrameworkSDK的二进制版本添加到我的测试应用程序时,它会抛出类似于“无法找到模块x”的错误。错误引用的模块是包含在swift-GRPC软件包中的模块。

我假设,在构建FrameworkSDK时,所有依赖项都包含在捆绑包中,这样对吗?如果是这样,我做错了什么?

英文:

We are developing an iOS framework called FramworkSDK and would like to distribute it to our clients as a binary. The FrameworkSDK depends on a framework called swift-GRPC. We use the Swift package manager to add this dependency.

Currently, when I add the binary version of FrameworkSDK to my test app it throws errors like "unable to find module x". The modules that the errors are referencing are modules included in the swift-GRPC package.

I assume, when I build the FrameworkSDK all of the dependencies are included in the bundle, Is this correct? If so, what am I doing wrong?

答案1

得分: 5

以下是翻译好的部分:

无法在框架中依赖 Swift Package。这在 WWDC 2019 Talk Binary Frameworks 中有讨论。我已链接到依赖/权限讨论,而且在此链接的时间之后明确指出:

二进制框架不能依赖于 Packages。

因此,如果您需要依赖于该包,您可能需要以不同的方式设置它,以便您依赖于它。它需要作为兄弟依赖项提供给您,也可以通过不同的包管理器作为框架提供给您,或者您需要构建代码到您的模块中,就好像您拥有它一样。将其构建到您的模块中可能会很麻烦,对您来说需要更多工作,但如果这是用户不关心的实现细节,那么对用户来说这是最透明的方式。

英文:

You cannot depend on a Swift Package in a framework. This is discussed in the WWDC 2019 Talk Binary Frameworks. I have linked to the discussion of dependencies/entitlements and shortly after the time linked here it is specifically stated:

> binary frameworks cannot depend on on Packages.

So if you need to depend no the package you will likely need to set it up differently on how you depend on it. It will need to be a sibling dependency that is given to you also as a framework through a different package manager or you will need build the code in your module as if you owned it. Building it into your module can be nasty and more work for you but it is the most transparent for users if it is an implementation detail they don't care about.

huangapple
  • 本文由 发表于 2020年1月7日 01:05:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/59616179.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定