xcodeswift-package-manager

How to develop several Swift Package Manager packages in Xcode?


I am developing the main app and a library (open source, forked but will go back into main repository) used by the app at the same time. I want to use Swift Package Manager and Xcode at the same time. What is the best setup in order to use the best of both worlds? Can I develop both in one workspace?

--- Edit ---

With the answer below of Alain Stulz could I make it like this: enter image description here Please note that the visuals only happen after Xcode restart. Thanks, Alain!


Solution

  • I'll describe the approach I've used before. I'm assuming you have the Swift Package available as source code in a folder, e.g. cloned using Git.

    1. Open your main app project
    2. Drag the root folder of the Swift Package onto your Xcode project
    3. Open the project overview, select your app target, and under "Frameworks, Libraries, and Embedded Content", add your library
    4. Import the library in any Swift file where you depend on it

    This will resolve and fetch all dependencies and still allow you to change source code in the library on the fly if you need to.