Swift version: 5.10
Swift Package Manager is a tool that generates Swift projects then manages dependencies for them, and it’s commonly used if want to build your projects without Xcode. If you have Xcode installed then you already have the Swift Package Manager, but if you’re using Linux it will come with the Swift for Linux package from https://swift.org/.
You can create a new project using just one command, although make sure you run it in an empty directory because it creates files:
swift package init --type=executable
That will generate Sources/YourProject/main.swift for your code, plus Package.swift for dependencies, and more. Run swift build
to build your source code, then swift run
to execute it.
SPONSORED Alex is the iOS & Mac developer’s ultimate AI assistant. It integrates with Xcode, offering a best-in-class Swift coding agent. Generate modern SwiftUI from images. Fast-apply suggestions from Claude 3.5 Sonnet, o3-mini, and DeepSeek R1. Autofix Swift 6 errors and warnings. And so much more. Start your 7-day free trial today!
Sponsor Hacking with Swift and reach the world's largest Swift community!
Available from iOS
This is part of the Swift Knowledge Base, a free, searchable collection of solutions for common iOS questions.
Link copied to your pasteboard.