To add any swiftpm package to an existing Xcode project:
- Navigate to "File" > "Swift Packages" > "Add Package Dependency ..."
- Under "Choose Package Repository", put
- For "Rules", the first two options are essentially equivalent for most users right now, because Swift Numerics isn't yet to version 1.0.0¹
- Add "Numerics" as a dependency for your target
- In your source file, write
To add a dependency to a SwiftPM project, add the following to the dependencies section in Package.swift:
.package(url: "https://github.com/apple/swift-numerics", from: "0.0.5"),
and then add
Numerics as a dependency for your target:
.target(name: "MyTarget", dependencies: [
.product(name: "Numerics", package: "swift-numerics"),
¹ If you are compiling with the nightly toolchain and want to experiment with
Float16, select "branch" and specify "swift-5.3" (but note: this branch will fail to compile with released versions of Swift, so do not use it for anything except for experimentation).