Skip to main content
Code samples

Swift Package Manager Distribution

Adding via Xcode​

  1. File β†’ Add Package Dependencies…
  2. Enter the repository URL:
    https://github.com/5Exceptions-Mobile-Team/NCKit.git
  3. Select version rule: Exact Version 1.1.1 (recommended)
  4. Choose target β†’ Add Package
  5. 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