[英]Using Swift Package Manager (SPM) for Existing [iPhone App] XCode Project (Having Swift + Objective C Files)
I am trying to create Library which I can use into my Existing XCode Project (iOS App).我正在尝试创建可以用于现有 XCode 项目(iOS 应用程序)的库。 I am aware that Swift Package Manager now support generating Xcode project with command我知道 Swift Package Manager 现在支持使用命令生成 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?在我现有的具有 Objective C 和 Swift 文件的项目中,如何使用新创建的 Swift 包?
How to add Package.swift file to my current Project?如何将 Package.swift 文件添加到我当前的项目中?
To use Swift (v4) Package Manager with iOS you have to jump through a couple of hoops.要在 iOS 中使用 Swift (v4) 包管理器,您必须跳过几个环节。
Basically,基本上,
swift package generate-xcodeproj
, modified to work with iOS, as a subproject of your main App xcodeproj使用swift package generate-xcodeproj
的输出,修改为与 iOS 一起使用,作为主应用程序 xcodeproj 的子项目I have an example with reproduction steps我有一个复制步骤的例子
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 上使用 Vapor 托管 Web 应用程序。
Both other answers (Josh, T. Swifty) are outdated.其他两个答案(Josh,T. Swifty)都已过时。 You don't need to generate an xcodeproj
based off a Package.swift
, in fact, swift package generate-xcodeproj
is a deprecated command.您不需要基于Package.swift
生成xcodeproj
,事实上, swift package generate-xcodeproj
是一个不推荐使用的命令。
If you're making an app, just add your Swift Package in Xcode (in the project
> Swift Packages
tab).如果您正在制作应用程序,只需在 Xcode 中添加您的 Swift Package(在project
> Swift Packages
选项卡中)。 Only create a Swift.package
if you're making an executable or library, instead of an application for iOS, macOS, etc.如果您正在制作可执行文件或库,而不是适用于 iOS、macOS 等的应用程序,请仅创建Swift.package
。
The guide is: Adding Package Dependencies to Your App指南是: 向您的应用程序添加包依赖项
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.