swift 和 xcode_带有Xcode 12和Swift Package Manager的现代模块化应用程序

本文介绍了如何利用Xcode 12和Swift Package Manager来构建现代的、模块化的应用程序。通过Swift包管理器,开发者可以更好地组织代码,实现更高效的合作和维护。
摘要由CSDN通过智能技术生成

swift 和 xcode

Last year, after Apple released the first beta of Xcode 11 with native support for Swift Package Manager (SPM) built in, I wrote a post on how we can leverage this to build modular apps with Swift Packages.

去年,在苹果发布了Xcode 11的第一个beta版本并内置对Swift Package Manager(SPM)的本机支持之后, 我写了一篇文章 ,介绍了如何利用它来利用Swift Packages构建模块化应用程序。

In it, I touted that it would make it possible to ditch Cocoapods as a dependency manager, but what we ran into quickly was a limitation with being unable to include resources in a Package, like colour assets, fonts, storyboards/xibs etc.

在其中,我吹捧说它有可能放弃Cocoapods成为依赖管理器,但是我们很快遇到的一个局限是无法在Package中包含资源,例如颜色资产,字体,情节提要/ xibs等。

Thankfully, Xcode 12 includes the latest version of SPM which now allows Packages to include any resources, by including a new static property on Bundle named .module. This Bundle instance references the current module, rather than just being able to reference the current target.

值得庆幸的是,Xcode 12包含了最新版本的SPM,该软件包现在允许Packages通过在Bundle名为.module的新静态属性来包含任何资源。 该Bundle实例引用当前模块 ,而不仅仅是能够引用当前目标

In this post, we’ll update our project from last year to include some assets which we can expose from the Package for use in any other module or target!

在这篇文章中,我们将从去年开始更新项目,以包括一些我们可以从Package中公开的资产,以用于任何其他模块或目标!

第1步 (Step 1)

To continue, first follow the steps in last year’s post, then come back here and we’ll carry on from there.

要继续,请先按照去年的帖子中的步骤进行操作 ,然后再回到此处,我们将在此继续进行。

NOTE: You’ll need to use Xcode 12 instead of Xcode 11. Since you’ll be using Xcode 12 and a new version of SPM, you may encounter some slight differences in how to set up a module from last year’s post.

注意:您将需要使用Xcode 12而不是Xcode11。由于您将使用Xcode 12和新版本的SPM,因此与去年的帖子相比,在设置模块方面可能会遇到一些细微的差异。

Notably, you’ll have to provide a package name as well as a product name when declaring dependencies in FantasticFeature. You can just use the same value for both.

值得注意的是, 在FantasticFeature中声明依赖项时 ,必须提供 程序

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值