SPM make it easy to create, distribute, import and use a package. It is easier to create a package with an example app inside for use to pick up and for you to debug with.
Here are how-to steps:
Steps
- Assuming you have created a package already. Navigate to the path of your package, and make a group(e.g. DemoApp):
- Then create a new Project named DemoApp or whatever you like inside the new group.(Since it is more likely to manage the package via git outside, you may not want to check “create git repository” when creating the project).
- Go to File→Add File Dependencies…, and click “Add Local…” to add your package that contains this project.(If you are using Xcode 15, please jump to section “Xcode 15 adding local packages”)
- Done. Now you can import the package in this demo app. You can also rebuild to see what happened after you change the package’s source code locally.
Xcode 15 adding local packages
Xcode 15 will prevent and alert us if we want to add packages in the group which contains the project through SPM. Fortunately there is a roundabout way to tackle with the problem.
- In target’s “general” tab, add an embedded library(your package).
- In “Build Phases” tab, link your package.
- Done.
Loading Comments...