Reputation: 239
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)
Upvotes: 17
Views: 10967
Reputation: 101
A new way(2022.11): Simply drag the local package repo to your main project Like this
Note: if you have that package open in another Xcode project you have to close it first.
By this way, Xcode will ignore the remote package in SPM. You can edit the local package repo directly and use it in main project.
Upvotes: 0
Reputation: 34461
Local Swift Package Manager(SPM)
Key point is: file://
+ git
which you can use it in URL
field
file://<path>
//e.g.
file:///Users/alex/Desktop/MyProject
Notes:
File -> Swift Packages -> Add Package Dependency
it is added into project -> Swift Packages
and implicit dependency
[About] is added to Frameworks, Libraries, and Embedded Content
File -> Swift Packages -> Update to Latest Package Versions
Product folder
<path_derived_data>/<randomizer>/Build/Products/Debug
//e.g.
/Users/alex/Library/Developer/Xcode/DerivedData/SPMExperiments-bmmqumztjedpekaajffnaegxzwzg/Build/Products/Debug
[Local CocoaPods]
[Local Carthage]
Upvotes: 2
Reputation: 2018
Yep, Xcode makes this rudimentary task unnecessary difficult.
The trick is simple, though: in the sheet that pops up when you select 'Add Package Dependency…', in the URL field, you can enter a file:// URL. e.g. drag the package's folder into that field, which will place the path in it - e.g. '/Users/me/Documents/myShinyPackage/', then stick 'file://' to the front of it, and you'll be able to proceed.
Addendum: as some folks note in the comments below, this is problematic if you share the project with others, unless you standardise on paths. For individual use, however, it's fine.
Upvotes: 2
Reputation: 1000
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
file://
Confirm that the minimum version is higher than the remote one.
Upvotes: 6
Reputation: 2959
This is the way I did it :
Upvotes: 17