使用Cocoapods将通用iOS框架作为XCFrameworks分发

模块化iOS (Modular iOS)

With the introduction of XCFrameworks we are now able to distribute universal frameworks as XCFrameworks to our integrators. XCFrameworks have the following advantage over universal frameworks:

通过引入XCFrameworks,我们现在能够将通用框架作为XCFrameworks分发给我们的集成商。 与通用框架相比,XCFrameworks具有以下优势:

  1. It’s fully supported by Apple

    Apple完全支持
  2. It’s easier to build and maintain

    易于构建和维护

With Xcode 12 we are now able to distribute and consume XCFrameworks using Swift Package Manager(SPM). However many iOS app projects are using Cocoapods to manage dependencies. Cocoapods too supports the distribution and consumption of XCFramework.

使用Xcode 12,我们现在可以使用Swift Package Manager(SPM)分发和使用XCFrameworks 。 但是,许多iOS应用程序项目都使用Cocoapods管理依赖项。 Cocoapods也支持XCFramework的分发和使用。

Why should you distribute your framework as XCFramework through Cocoapods? Here are the main reasons:

为什么要通过Cocoapods将框架作为XCFramework分发? 主要原因如下:

  • Apple might drop support of universal frameworks in the future

    苹果未来可能会放弃对通用框架的支持
  • Can make it easier for for those transitioning from Cocoapods to SPM

    对于从Cocoapods过渡到SPM的人员来说可以更轻松

In this tutorial I will show how to distribute a universal iOS framework as XCFramework using Cocoapods.

在本教程中,我将展示如何使用Cocoapods将通用的iOS框架作为XCFramework分发。

I assume you are familiar with iOS frameworks, xcframeworks, iOS development and Swift. I also assume you are familiar with the basics of dependency management, Cocoapods and Git version control.

我假设您熟悉iOS框架 , xcframeworks ,iOS开发和Swift。 我还假设您熟悉依赖性管理, Cocoapods和Git版本控制的基础知识。

I have used Swift 5.2.4 and Xcode 11.5 whilst writing this article.

在撰写本文时,我使用了Swift 5.2.4和Xcode 11.5。

如何使用Cocoapods分发XCFrameworks (How to distribute XCFrameworks using Cocoapods)

In this section we’ll start by downloading a starter pack. The starter pack contains an iOS framework project and an iOS app. We’ll use the framework project to build an XCFramework which we’ll distribute through Cocoapods. In the next section we’ll use the iOS app to consume the XCFramework using Cocoapods.

在本节中,我们将从下载入门包开始。 该入门

你可能感兴趣的:(ios)