Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Incorporate Swift Package Manager to an Existing Xcode Project?

Tags:

xcode

swift

I already have a working Xcode project for a MacOS App. However, I would like to add a Swift framework from Github using Swift Package Manager.

I ran "swift package init" inside the project folder. Then I updated Package.swift file. Then I ran "swift package resolve".

However, it still complains no such module when I try to build.

Since I already have a working project, if I run "swift package generate-xcodeproj", it messes up the folder structure as well as removing the storyboard.

How can I tell Xcode to use the module that swift package manager downloaded into the project?

Thank you!

like image 833
jl303 Avatar asked Oct 26 '25 05:10

jl303


1 Answers

The generated Xcode project from SPM is different from your app's Xcode project/workspace.

You should generate that Xcode project in another directory eg. "Dependencies".

Then drag it into your app's, and add the linked framework. I have written a full step-by-step.

like image 69
samwize Avatar answered Oct 29 '25 07:10

samwize