To use a Swift package as an Xcode project, just open the Package.swift
directly. Xcode will create a workspace (in comments, I said a project, but it's a workspace) in the package's .swiftpm
directory. There won't be any project settings, because you do that by editing the Package.swift
file, and files are always sorted. Other than that, it's pretty much like working in an Xcode project, including debugging and testing.
Of course there are the other modes of using a package
You can just drag the Package.swift
file into your Xcode project, if it's a local package. You'll also need to add it as a dependency in your General settings, just as you would any framework. That's not the same as the "Add Package Dependency" feature. It's the same Project Settings
-> Target
-> Frameworks & Libraries
that you use for any traditional framework.
If you do it that way, the package is part of the Xcode project.
If the package is already under it's own git repo, Xcode will prompt you which repo you want to do things like "push" or whatever, though commit just applies to whatever repo the files being committed belong to... so if you change some app code and package code, and commit them both at the same time, the app code would go into the app's repo, and the package code would go to the package's repo.
If the package isn't under source control and you relocate it to your project folder, I think the project's repo will take responsibility for those sources, though you might have to explicitly check them in Xcode's commit (or git add
from the command line).
I'm not sure how it handles it, if it's in an unrelated folder and not in its own repo.
If it's a remote package, which is different, you need to add it as a package dependency. No getting around that for remote packages.