现有[iPhone App] XCode项目使用Swift Package Manager (SPM)(包含Swift + Objective C文件)

时间:2022-09-07 08:26:08

I am trying to create Library which I can use into my Existing XCode Project (iOS App). I am aware that Swift Package Manager now support generating Xcode project with command

我正在尝试创建一个库,可以用在我现有的XCode项目(iOS应用)中。我知道Swift包管理器现在支持用命令生成Xcode项目。

swift package generate-xcodeproj

But I am not creating new project. In my existing project having Objective C & Swift Files, How can I use newly created Swift Package?

但我并没有创建新的项目。在我现有的具有目标C & Swift文件的项目中,如何使用新创建的Swift包?

How to add Package.swift file to my current Project?

如何添加包。swift文件到我现在的项目?

2 个解决方案

#1


4  

As far as I know you can't use SPM right now within iOS apps.

据我所知,你现在不能在iOS应用中使用SPM。

You can use it in hosted environments for example if you are hosting a web application with Vapor on a Mac or on Linux.

您可以在托管环境中使用它,例如,如果您在Mac或Linux上托管具有蒸气的web应用程序。

#2


5  

To use Swift (v4) Package Manager with iOS you have to jump through a couple of hoops.

要使用iOS的快速(v4)包管理器,你必须跳过几个圈。

Basically,

基本上,

  1. Make a Package.swift for your app's dependencies
  2. 做一个计划。迅速为您的应用的依赖
  3. Use the output of swift package generate-xcodeproj, modified to work with iOS, as a subproject of your main App xcodeproj
  4. 使用swift包generate-xcodeproj的输出,修改为与iOS一起工作,作为主应用xcodeproj的子项目
  5. Link your dependency Frameworks as you normally would
  6. 像往常一样连接依赖框架

I have an example with reproduction steps

我有一个复制步骤的例子

#1


4  

As far as I know you can't use SPM right now within iOS apps.

据我所知,你现在不能在iOS应用中使用SPM。

You can use it in hosted environments for example if you are hosting a web application with Vapor on a Mac or on Linux.

您可以在托管环境中使用它,例如,如果您在Mac或Linux上托管具有蒸气的web应用程序。

#2


5  

To use Swift (v4) Package Manager with iOS you have to jump through a couple of hoops.

要使用iOS的快速(v4)包管理器,你必须跳过几个圈。

Basically,

基本上,

  1. Make a Package.swift for your app's dependencies
  2. 做一个计划。迅速为您的应用的依赖
  3. Use the output of swift package generate-xcodeproj, modified to work with iOS, as a subproject of your main App xcodeproj
  4. 使用swift包generate-xcodeproj的输出,修改为与iOS一起工作,作为主应用xcodeproj的子项目
  5. Link your dependency Frameworks as you normally would
  6. 像往常一样连接依赖框架

I have an example with reproduction steps

我有一个复制步骤的例子