How to install dependencies programmatically?

Hi. I have a project which requires 2 Swift Packages to be installed. I want to install these packages without opening Xcode, like CocoaPods.

In CocoaPods, you can do pod 'Package', '~> 3.0' in a Podfile.

What is the SwiftPM equivalent to that?

Replies

If you look in xcodebuild -help:
Code Block
-resolvePackageDependencies                              resolves any Swift package dependencies referenced by the project or workspace


This assumes the package is already added to the Xcode project in the past. Does that serve your needs?
No, @edford. What is the package wasn't added to the project. How do I add the package programmatically?
xcodebuild does not have any operations that modify an Xcode project file, such as to add the package. Please file an enhancement request for your needs through Feedback Assistant.