Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Local dependencies in XCode11 using SPM

Is it posible to integrate local dependencies with SPM in xcode 11, File > Swift Packages > Add Package dependency... It only seems to populate and let me select git repos hosted on bitbucket

I am just not sure if I am approaching the issue the correct way, maybe I should be using a Package.swift file instead? I have a lot of experience with Cocoapods but I would like to branch out and try other tools, especially if they are going to be supported in xcode as it seams SPM will be (Im using xcode11 beta 5)

like image 899
user6252584 Avatar asked Aug 09 '19 22:08

user6252584


People also ask

How do I create a local SPM package?

Select your project in the Project navigator, then select your app target and navigate to its General pane. Click the + button in the “Frameworks, Libraries, and Embedded Content” section, select the local package's library product, and add it as a dependency.

Can you add dependency to application package model?

Add a Package Dependency You can also navigate to your target's General pane, and in the “Frameworks, Libraries, and Embedded Content” section, click the + button, select Add Other, and choose Add Package Dependency.


2 Answers

This is the way I did it :

  • Drag and drop your package folder (in my example "DataStructures") from the finder directly into the Frameworks group of your target. You will see that the dropped item take a brown folder color (you can use the arrow to "get into it").
  • Go to your project target page, in the "Framework and Libraries" click the "+" button. Your package should show up in the "Workspace" area as a library.

enter image description here

like image 171
AirXygène Avatar answered Oct 14 '22 08:10

AirXygène


Xcode 12

If you have a remote version of your package already in the project and want to work on a local. There are a few extra steps...

1. Make sure your local package's version is higher than the remote version

If you don't do that, it will continue to fetch the remote package

  1. Select your project in Project Navigator
  2. In the main window select Swift Packages
  3. Select the package you want to replace with a local and remove it
  4. Go to File > Swift Packages > Add Package Dependency...
  5. Drag the your local package folder to the package search bar and add the prefix file://
  6. Click on Next

Confirm that the minimum version is higher than the remote one.

like image 25
D. Greg Avatar answered Oct 14 '22 06:10

D. Greg