Add a local Swift Package to your project with Swift PM

In SwiftPM, you may want to add a local Swift Package to your project. For example, if you want to work with projects and dependent packages in a single repository (mono repo).

According to Swift PM Lead Developer's Answer, drag a package into your project It's OK if you drop and drop it, but at least it didn't work in my environment (although this answer is "the way it should be", so I think it will be resolved in a future update).

This article summarizes the current workaround in my environment (2020/11/15).

environment

procedure

  1. Make the Swift Package you want to add into your local git repository. This git repository will be deleted later, so it doesn't matter how you do it (git init; git add.; git commit -m "init" )
  2. Place the Swift Package directory you want to add somewhere in your project folder.
  3. Drag and drop the Swift Package directory you want to add into your Xcode project.
  4. From the Xcode menu, go to [File]-[Swift Package]-[Add Package Dependency] and specify the path of the relevant Swift Package. It is in the form of "file: // + full path". For example, file: /// Users / n / d / expProject / expdat / swiftPackage.
  5. Correct the path. Open .pbxproj as a text file and search for file: // Then find the path specified in 4. and replace it with a relative path. For example, ./expdat/swiftPackage.
  6. Remove the .git directory from the Swift Package directory.

At the time of 4., the addition to the project has already been completed, but it can only be handled locally, and it will not be possible to push with Git or the like. In order to solve it, we are following the steps of 5. and 6..

that's all.

Recommended Posts

Add a local Swift Package to your project with Swift PM
Add packages to your project with Swift PM
Convert a string to a character-by-character array with swift
Transition to a view controller with Swift WebKit
Add a project in any folder with Gradle
Add a subview to your animation layer using lottie-ios
Refusing to install package with name "webpack" under a package
[Swift 5] Note: Add Core Data to an existing project
Port C code with a lot of typecasts to Swift
Add a shadow to the Swift Button (and also the circle)
I want to add a browsing function with ruby on rails
[Swift] Create a project with Xcode (ver 12.1) and display "Hello, World!"
How to add columns to a table
[Rails] Creating a new project with rails new
Make a Christmas tree with swift
[Swift] How to send a notification
How to make a Maven project
Create a Maven project with a command
[iOS] I tried to make a processing application like Instagram with Swift
How to add local jar to maven pom.xml
Add foreign key to column with migrate
How to add a new hash / array
Install the package with npm install / yarn add
[Swift] Easy to implement modal with PanModal
[Swift5] How to create a splash screen
Add scripts to distributions created with gradle
How to get the ID of a user authenticated with Firebase in Swift
Until you run a Java program with the AWS SDK local to Windows
From creating a Spring Boot project to running an application with VS Code