Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Install Package in Xcode via Swift Package Manager

I'm working on a project in Xcode and am attempting to install and use the CryptoSwift package via the Swift Package Manager.

I read the documentation on SPM, but I don't see instructions on how to invoke the SPM through Xcode.

The examples often refer to calling $ swift build. Does this mean that the SPM is only accessible from the command line? And if so, where exactly am I supposed to create the Package.swift file?

I'm reasonably familiar with Xcode, but I don't really understand the meaning of the build settings part of a project, or how Swift modules are used.

EDIT: This question was originally asked for Xcode 7.2, which shipped with Swift 2.1.1. Will gladly accept answers that explain how to do this with current/future versions of Xcode.

like image 631
m81 Avatar asked Dec 16 '15 22:12

m81


People also ask

How do I install Swift package manager?

To create a new Swift package, open Xcode and select File > New > Swift Package. Choose a name and select a file location. Select “Create Git repository on my Mac” to put your package under version control. On completion, the Swift package opens in Xcode and looks similar to a standard Xcode project.

How do I open a Swift package in Xcode?

Open your app's Xcode project or workspace. Select the Swift package's folder in Finder and drag it into the Project navigator. This action adds your dependency's Swift package as a local package to your project.

Where is package Swift Xcode?

Starting with Xcode 11, Swift packages can now be directly added and imported into an app project using Xcode's new Swift Packages option, which is located within the File menu.


1 Answers

Swift Package Manager now support generating Xcode project with

swift package generate-xcodeproj 

as mentioned in this answer, but this only works when developing a library, or a command line tool. Not (yet) for (iOS/OS X) graphical application developer:

Note that at this time the Package Manager has no support for iOS, watchOS, or tvOS platforms.

Note:

  • It might not work well if there is a space in your package name, i.e. change "App Store" to "AppStore".
like image 125
Franklin Yu Avatar answered Sep 25 '22 12:09

Franklin Yu