Berry Blue
Berry Blue

Reputation: 16482

How to have a Swift package and iOS target in the same project?

I was watching a WWDC video and they have a Swift Package and Swift app in the same project. How do you create that in Xcode? If I create a new Swift Package, I'm not able to add another target in the project.

enter image description here

Upvotes: 0

Views: 604

Answers (1)

kakaiikaka
kakaiikaka

Reputation: 4487

That was tricky, at first I thought It was created by adding a local swift package. Then I discovered the created structure does not look like your screen capture.

So after research I found it was actually a xcworkspace that joined the swift Package and app together.

How to create it? First you should create a normal swift package in Xcode with File -> New -> Packages

Then you are going to drag the xcodeproj file of the MyApp to the top of Xcode's left panel. You will be asked if you want to create a xcworkspace? just check yes.

I have uploaded to code to github, take a look at this repo

enter image description here

Upvotes: 1

Related Questions