Search code examples
swiftxcodecarthageswift-package-managerxcode11

How does SPM integrate with Xcode 10.2+?


I currently use Carthage for dependency management in Xcode projects. I'm giving Swift Package Manager a try, but it seems to want to build projects via command line only and with a specific file structure, not via Xcode.

I've added the Package.swift file, and if I'm starting a new project, I can get add the dependencies integrated via generating a new Xcode Project just fine:

swift package update
swift package generate-xcodeproj

But if I have an existing project, I don't want it to be overwritten.

Maybe I'm expecting a Carthage replacement and that's not what SPM is? It would be nice to get dependency management built into Xcode.


Solution

  • I found an answer to my own question. Rather than delete the question, I'll keep it here in the hopes it benefits others.

    Answer: Xcode 10 does not support Swift Packages. That feature is upcoming in Xcode 11 (in Beta 3 at the time of this note). And it looks slick!

    On Xcode 11, while on a project, you open up from the Menu: File > Swift Packages > Add Package Dependency. On the dialog prompt, you enter the Repository URL and which version, branch or commit you want to pull from. It then creates a Swift Package Dependencies section listing all your packages. Done!

    You can see a nice demo of it at RawWenderlich.com (5 minutes video).