Skip to content

Instantly share code, notes, and snippets.

@phranck
Created June 10, 2022 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phranck/9b8621d3ab12e2a8cc3b52b66ee55845 to your computer and use it in GitHub Desktop.
Save phranck/9b8621d3ab12e2a8cc3b52b66ee55845 to your computer and use it in GitHub Desktop.
Apple Q&A on Devtools and Swift Lounge

MY QUESTION: We are developing a brand new SwiftUI app. Among other things, this includes 3 Swift packages, which were integrated via "Add local...". When developing, this works great for all developers, because these packages are all in the same place in the filesystem (outside the actual project). The repositories of these 3 packages are private GitHub repos. How do we need to set up both Xcode and Xcode Cloud with these 3 private repo packages to make it work? How can Xcode Cloud access these 3 packages if they were only added locally to the project?

APPLE: In order for Xcode Cloud to have access to the three packages, the Xcode project that uses them needs to have URL references the repositories in which those packages reside. That will cause Xcode Cloud to check them out after checking out the main repository and before building.

You can still work with those packages locally by putting locally checked-out references to them in the same workspace as the main project in the local file system. If the workspace contains a local checkout of a package, it will shadow a remote dependency of the same name. In this way you can work with the three package dependencies locally, but have Xcode Cloud check them out from repositories.

When committing changes to the main project you will want to make sure to also push any required changes to the three packages as well, and if needed, to create new tags for the main project to pull. You may find it easiest to use branch dependencies for the packages if they are always developed together with the main project and not used from other projects.

The article at https://developer.apple.com/documentation/xcode/editing-a-package-dependency-as-a-local-package has some more information about local editing workflows.

ME: Oh, thanks Anders! I wasn't aware that I could use both local and URL references to the packages. That sounds good. I guess the references must be git@github.com: ... URLs, right?

APPLE: Yes, it's a bit subtle, but can be a very flexible way to work with dependencies. The dependency URLs can be any remote dependencies that Swift Package Manager supports, either https:// or git@.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment