how to create Xcode project which will execute local swift package
Asked on 07/31/2024
1 search
To create an Xcode project that will execute a local Swift package, you can follow these steps:
-
Create a New Xcode Project:
- Open Xcode.
- Select "File" > "New" > "Project".
- Choose a template for your project (e.g., App, Command Line Tool, etc.).
- Click "Next" and provide the necessary details for your project.
-
Add a Swift Package:
- Select your project in the Project Navigator.
- Go to the "Package Dependencies" tab.
- Click the "+" button to add a new package.
- Enter the URL of the Swift package repository you want to add.
- Choose the version or branch you want to use.
- Click "Add Package".
-
Use the Swift Package in Your Project:
- Once the package is added, you can import it in your Swift files using the
import
statement. - For example, if your package is named
MyPackage
, you can useimport MyPackage
in your Swift files.
- Once the package is added, you can import it in your Swift files using the
-
Build and Run Your Project:
- You can now build and run your project as usual. The Swift package will be included in the build process.
For more detailed information on working with Swift packages in Xcode, you can refer to the session A Swift Tour: Explore Swift’s features and design (10:08).
Relevant Sessions
These sessions provide insights into using Swift packages, testing, and other essential Xcode features.

Xcode essentials
Edit, debug, commit, repeat. Explore the suite of tools in Xcode that help you iterate quickly when developing apps. Discover tips and tricks to help optimize and boost your development workflow.

Go small with Embedded Swift
Embedded Swift brings the safety and expressivity of Swift to constrained environments. Explore how Embedded Swift runs on a variety of microcontrollers through a demonstration using an off-the-shelf Matter device. Learn how the Embedded Swift subset packs the benefits of Swift into a tiny footprint with no runtime, and discover plenty of resources to start your own Embedded Swift adventure.

Meet Swift Testing
Introducing Swift Testing: a new package for testing your code using Swift. Explore the building blocks of its powerful new API, discover how it can be applied in common testing workflows, and learn how it relates to XCTest and open source Swift.