Short answer
Add a local package in Xcode by creating it with File > New > Package, or by choosing File > Add Package Dependencies and then Add Local. A local package lives in a folder with a Package.swift manifest and is part of the project, or it overrides a remote package of the same name. Attach the library product from Frameworks, Libraries, and Embedded Content. Do not invent a menu the docs do not name.
Last verified against the sources listed below.
Key takeaways
- File > New > Package creates a package inside the project. Before Xcode 15 that item is labeled Swift Package.
- Pick the Library template under Multiplatform when you want a package set up as a library.
- File > Add Package Dependencies, then Add Local, attaches a folder you already checked out.
- Leave the remote dependency in place. A local package with the same name overrides it until you remove the local copy.
- The version rule Apple recommends follows Semantic Versioning: major, minor, and patch.
How to add local package xcode is the set of menus Apple documents for a Swift package that sits on disk next to the app. Organizing your code with local packages starts with File > New > Package. A second page, for a package you already cloned, starts with File > Add Package Dependencies and the Add Local button.
Mobile app development is the wider job of building the app. A local package is how you split networking or utilities into a library without publishing it first.
Software development still includes the later choice to move that library into its own Git repository.
What counts as a local package?
A local package is a Swift package folder Xcode builds as part of the app project.
Apple’s organizing page says you use local packages so the package code stays in the same repository as the app. Good candidates it names are networking logic and utility source files. The package is described by Package.swift, the manifest. A standalone package page says that file declares the name, products, targets, and dependencies, and that it must begin with a swift-tools-version comment.
Source files live under Sources, in a subfolder named for the target. Tests live under Tests. Xcode includes the valid source files in that folder unless you list them yourself.
An app icon resizer is unrelated to the manifest. It only prepares the icon that ships beside the package in the app target.
How do you create one in the project?
Create the package from the File menu, choose the Library template, then add its product to the app target.
Apple’s organizing page lists these steps. The menu names below are copied from that page.
- Open the Xcode project. Select File > New > Package. On Xcode older than 15, the item is Swift Package.
- At the top of the template dialog, select Multiplatform, choose Library, and click Next. Other templates in that dialog set up other kinds of content.
- Choose a project and a group. Do not create a new Git repository when the app is already under version control. Then create the package.
- Move the code in the Project navigator and update the manifest. You may need to vend the code as a library product and declare targets.
- Select the project, select the app target, and open its General pane.
- Click the plus button in Frameworks, Libraries, and Embedded Content. Select the local package’s library product and add it.
The manifest sample on the standalone page declares a library product named MyLibrary and a target of the same name. Platforms in that sample are macOS, iOS, and tvOS minimums. Passing platforms does not limit the package to only those systems.
How do you add a folder you already have?
Point Xcode at the folder with Add Local. Leave the remote dependency in the project.
Use this path when a package is already a dependency and you need to edit it. Apple’s editing page says you cannot edit a package dependency in place. Add the same package as a local package, and do not remove the dependency.
The local package overrides the one with the same name. When you remove the local package, Xcode uses the dependency again.
The steps on that page are:
- Check out the package source from its Git repository. git clone clones a repository into a new directory and checks out an initial branch.
- Open the app’s Xcode project or workspace.
- Choose File > Add Package Dependencies.
- Click Add Local at the bottom of the package selection window.
- Select the folder that contains the package and click Add Package.
- Choose targets for the package products Xcode detects.
Build and run the app to verify the edits. When the change is in a later release, remove the local package and update the dependency to that version.
A remote package, by contrast, starts at File > Add Package Dependency on the adding-dependencies page. You can also open the target’s General pane, click the plus button in Frameworks, Libraries, and Embedded Content, choose Add Other, then Add Package Dependency. You then pick a version rule, a branch, or a commit.
How does the version rule work?
The version rule follows semantic versioning. Branch and commit are the other two requirements.
Semantic Versioning 2.0.0 says a normal version is major, minor, and patch. Major means an incompatible API change. Minor means backward compatible functionality. Patch means a backward compatible bug fix.
The words MUST and SHOULD in that spec are defined by RFC 2119. Apple says major versions tend to need code changes. The version requirement is the recommended way to add a remote dependency.
A branch requirement tracks a branch name. Apple suggests it when several packages are developed together and you are not publishing versions yet. A commit requirement pins one hash. The same page says that option is not recommended except in exceptional cases, because you stop receiving updates.
After Xcode resolves the package, you select products and add them to targets. The Swift Package Dependencies section in the Project navigator shows the package. The disclosure triangle shows the files as they exist on your Mac. File > Packages can update and resolve again.
For a package that depends on another local package, the standalone page says to use a function that takes a path. A remote dependency uses a function that takes a URL. The remote sample uses from: “1.0.0”. The page tells you to see Package.Dependency for every form, so paste from that symbol reference rather than from a truncated line.
What if the product does not appear?
Check the menu spelling, the library product, and whether a local folder is overriding a remote package.
| Symptom | Likely cause | What to check |
|---|---|---|
| File > New > Package is missing | Xcode is older than 15 | Use File > New > Swift Package, as that page states |
| Add Local is not on screen | You opened the remote URL flow | Use File > Add Package Dependencies, then Add Local |
| The plus list has no library | The manifest does not vend a library product | Declare a library product and a target, then rebuild |
| Edits to a remote package will not save | Dependencies are not edited in place | Add the folder as a local package and keep the dependency |
| Teammates resolve a different commit | Package.resolved was not committed | Commit the file under xcshareddata/swiftpm |
| A new Git repo appeared inside the app repo | Create Git repository was left on | Skip that checkbox when the app is already under version control |
To call the code, import the module that matches the library product. Apple’s sample imports MyLibrary and reads a property from that module. The import name is the product name, not the folder name, when those differ.
Remove a dependency from the Project Editor’s Packages Dependencies pane. Select it, click the minus button, and confirm Remove. Remove a local override only after the released version contains your fix.
Frequently asked questions
Which menu name is singular, and which is plural?
Apple uses both spellings, on different pages. Adding package dependencies to your app says File > Add Package Dependency, singular, and also describes the plus button, Add Other, then Add Package Dependency. Editing a package dependency as a local package says File > Add Package Dependencies, plural, then the Add Local button. Organizing your code with local packages uses File > New > Package, or Swift Package before Xcode 15. Use the label on the page that matches the job. A remote URL and a folder on disk are not the same command.
What does the version rule require?
The adding-dependencies page says the version rule requires Swift packages to conform to semantic versioning, and it points to Semantic Versioning 2.0.0. That specification says a normal version is MAJOR.MINOR.PATCH, three non-negative integers with no leading zeros. You increment major for an incompatible API change, minor for compatible functionality, and patch for a compatible bug fix. SemVer's requirement words are defined by RFC 2119. Branch and commit rules exist too. Apple calls the version rule the recommended way to add a remote package.
Where does Xcode store the resolved package versions?
When you add a package dependency, Xcode writes a Package.resolved file. Apple's page says it lists the Git commit each dependency resolved to, plus the checksum of each binary dependency, and that you should commit the file so the team shares those versions. The path it prints is inside the xcodeproj, under project.workspace/xcshareddata/swiftpm/Package.resolved. A local package that only lives in the app repository does not need that remote resolution. The file matters once a package is fetched from a URL.
Can one target mix Swift and Objective-C?
The standalone package page says a package can contain Swift, Objective-C, Objective-C++, C, or C++. An individual target cannot mix Swift with those C-family languages. Use two targets when you need both, one for the C family and one for Swift. Source files go in a Sources subfolder named for the target. Tests go in Tests. The manifest must start with the swift-tools-version comment and a version number, such as 5.3 in Apple's sample. Xcode offers completion while you edit that file.
How do you remove a package dependency?
Apple's adding-dependencies page gives three steps. Select the project in the Project Editor and open the Packages Dependencies pane. Select the package in the list. Click the minus button at the bottom and confirm with Remove. Removing a local override makes Xcode use the package dependency of the same name again. Do that after the fix is in a released version and you have updated the dependency. The File > Packages menu can also update and resolve versions without removing anything.
Sources
- Organizing your code with local packages · Apple Developer Documentation, 2026
- Adding package dependencies to your app · Apple Developer Documentation, 2026
- Editing a package dependency as a local package · Apple Developer Documentation, 2026
- Creating a standalone Swift package with Xcode · Apple Developer Documentation, 2026
- Semantic Versioning 2.0.0 · Semantic Versioning, 2026
- RFC 2119 · RFC Editor, 1997
- git-clone · Git, 2026