Destination and profile settings in SPM generated Xcode project

I am making my first experiences with the Swift Package Manager, and there are two things that I noticed in the generated Xcode project.

This is what I did:

$ mkdir TestProject
$ cd TestProject
$ swift package init --type=executable
$ swift package generate-xcodeproj
$ open TestProject.xcodeproj

Then:

  • “Project -> Destination” is not set and the title bar shows “TestProject -> Martin's iPhone” as the active scheme. I have to set the destination to “My Mac” first, otherwise the compilation fails.

  • “Product -> Profile” does not work out of the box, because there is no executable selected in the Profile settings of the active scheme.

Shouldn't these settings be already present when the project is generated by the package manager? Am I overlooking something?

Thanks for any help.

If memory serves correct, both of these selections (active scheme and destination) have nothing to do with the generated project, and are instead components of user state (i.e. preferences, combined with how Xcode was last used.)

Regenerating the project (swift package generate-xcodeproj) will leave them however you last had them set.

Both destinations are (or at least could be) valid for a package. There is currently no way to restrict which platforms a package supports, but that is undergoing the evolution process right now. Probably you were working on a different iPhone project before you first opened the generated project?

A package could contain multiple executables—or none at all—, so there often is no logical default. I think if there is no existing selection from having Xcode open previously, then it just picks the first scheme alphabetically, which in your case was probably the package‐wide scheme, instead of the scheme for a particular executable.

1 Like
Terms of Service

Privacy Policy

Cookie Policy