Swift Packages 101
A note about package creation in Swift & Xcode.
File -> New -> Swift Package
- Create package for current project and current target.
- Drag package's files to Sources/PackageName folder.
- Move whole package's folder to desktop with Option key pressed to create a copy.
- Open Package.swift: now it is a separate project which can be put under version control and used in other projects.
Swift Package could be uploaded as either public or private repo. Versioning is important, the common is:
The following steps assume the Package is uploaded to Github.
File -> Swift Packages -> Add Package Dependency
- Copy link to package. For private package copy SSH link.
- Connect and enjoy.
In order to switch between local/remote packages drag desktop's version of package back to project, and Xcode should automatically switch from remote package version to local one.
When local changes were done, go back to remote by deleting local version of package from the project.
In comparison to Cocoapods, Swift Packages are much easier to create, use and edit.