bcardarella
(Brian Cardarella)
April 12, 2021, 12:23pm
1
If I have a separate Swift package that I am developing but not ready for publish but I want to try it out in a Swift app can I link that into my project locally or do I always have to push to a git repo and tag with a version to install?
byaruhaf
(Franklin Byaruhanga)
April 12, 2021, 1:05pm
2
You don't have to push to a git repo. There two ways to link to a package locally
Option 1:
The proper way to add a local Swift Package is via menu in Xcode:
Swift Packages -> Add Package Dependency...
And type the full URL pointing to your package folder, starting from file:// prefix (it is a local URL after all).
Take note, only the committed changes in the package propagate to the project builds. I.e. it behaves like a fully remote package, despite the fact that you can still edit its sources from the same Xcode project.
Option 2:
I eventually managed to do it.
Drag the package folder which contains the Package.swift into your Xcode project
Click the Plus button in the "Link Binary with Libraries" section, locate the package in the modal dialog, select the gray library icon inside the package, and add this one.
Build your Xcode project and move on to your next interesting task
Trouble is that Xcode lets you drag the brown package icon to the "Link Binary with Libraries" section of the "Build Phases" tab of you…