Swift Package Manager Distribution
Adding via Xcodeβ
- File β Add Package Dependenciesβ¦
- Enter the repository URL:
https://github.com/5Exceptions-Mobile-Team/NCKit.git - Select version rule: Exact Version
1.1.1(recommended) - Choose target β Add Package
- In target General β Frameworks, Libraries, and Embedded Content β confirm NCKit is Embed & Sign
Adding via Package.swiftβ
// swift-tools-version: 5.9
import PackageDescription
let package = Package(
name: "YourApp",
platforms: [.iOS(.v16)],
dependencies: [
.package(
url: "https://github.com/5Exceptions-Mobile-Team/NCKit.git",
exact: "1.1.1"
)
],
targets: [
.target(
name: "YourApp",
dependencies: ["NCKit"]
)
]
)
Local Developmentβ
When developing with NCKit locally:
dependencies: [
.package(path: "../NCKit-iOS") // relative path to NCKit-iOS folder
]
How SPM Resolves NCKitβ
NCKit's Package.swift declares a single binary target:
.binaryTarget(
name: "NCKit",
path: "NCKit.xcframework" // local XCFramework, version-tagged
)
SPM checks out the git tag, finds the XCFramework at the declared path, and links it into your target. No compilation of NCKit source occurs.
Authentication for Private Repositoryβ
NCKit is a private repository. Xcode needs credentials to clone it.
Option A β GitHub SSH:
ssh://git@github.com/5Exceptions-Mobile-Team/NCKit.git
Ensure your SSH key is registered at GitHub.
Option B β HTTPS with token: Add to Xcode's account credentials (Xcode β Settings β Accounts) or set in Keychain.
Option C β netrc:
echo "machine github.com login YOUR_USERNAME password YOUR_TOKEN" >> ~/.netrc
chmod 600 ~/.netrc
CI/CD β SPM Resolutionβ
For GitHub Actions CI with a private NCKit repo:
- name: Resolve SPM packages
env:
GITHUB_TOKEN: ${{ secrets.PACKAGES_READ_TOKEN }}
run: |
git config --global url."https://${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
swift package resolve