Binary Targets and XCFrameworks
Distributing closed-source code as XCFramework and consuming as a binary target.
Binary Targets and XCFrameworks is a free Swift Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Swift Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What is a Binary Target?
A binary target distributes a precompiled framework (XCFramework) instead of source code, protecting proprietary implementations.
// Package.swift:
.binaryTarget(
name: "ClosedSDK",
path: "Frameworks/ClosedSDK.xcframework"
)What is an XCFramework?
An XCFramework bundles multiple platform slices (iOS, macOS, simulator) into a single distributable archive.
// XCFramework structure:
// ClosedSDK.xcframework/
// ├── ios-arm64/
// ├── ios-arm64_x86_64-simulator/
// └── macos-arm64_x86_64/Creating an XCFramework
Build archives for each platform and combine them with xcodebuild -create-xcframework.
xcodebuild archive -scheme MySDK -destination "generic/platform=iOS" -archivePath ios.xcarchive SKIP_INSTALL=NO
xcodebuild archive -scheme MySDK -destination "generic/platform=iOS Simulator" -archivePath sim.xcarchive SKIP_INSTALL=NO
xcodebuild -create-xcframework \
-framework ios.xcarchive/Products/Library/Frameworks/MySDK.framework \
-framework sim.xcarchive/Products/Library/Frameworks/MySDK.framework \
-output MySDK.xcframeworkRemote Binary Target with Checksum
Reference a remotely hosted XCFramework zip with its SHA-256 checksum for integrity verification.
.binaryTarget(
name: "ClosedSDK",
url: "https://cdn.example.com/ClosedSDK-1.0.0.xcframework.zip",
checksum: "abc123def456..."
)Computing the Checksum
Use swift package compute-checksum to generate the SHA-256 checksum for the zip file.
swift package compute-checksum ClosedSDK-1.0.0.xcframework.zip
# Outputs: abc123def456...Using Binary Targets in App
Add the binary target as a dependency in another target's dependencies list, just like a source target.
.target(
name: "MyApp",
dependencies: [
.target(name: "ClosedSDK")
]
)Importing the XCFramework
Import the module in Swift code exactly like any other import.
import ClosedSDK
let result = ClosedSDK.ProcessData(input: myData)Privacy Manifest Requirements
Apple requires XCFrameworks distributed on the App Store to include a PrivacyInfo.xcprivacy manifest listing used APIs.
// ClosedSDK.xcframework/
// ├── ios-arm64/ClosedSDK.framework/
// │ └── PrivacyInfo.xcprivacy
// └── ...Debug vs Release Builds
When consuming an XCFramework, you cannot step through source in the debugger — you only see symbols. dSYM files can be bundled for crash symbolication.
// Distribute dSYMs alongside XCFramework for crash reporting:
// ClosedSDK-1.0.0.xcframework.zip
// ClosedSDK-1.0.0.dSYM.zipVersioning XCFrameworks
Use semantic versioning in the filename and SPM package version to ensure consumers can pin compatible versions.
// ClosedSDK-1.2.0.xcframework.zip
// In Package.swift:
// .package(url: "...", from: "1.2.0")XCFramework vs Source Packages
Use XCFramework for proprietary code, large precompiled SDKs, or C/C++ wrappers. Use source packages for open-source Swift code.
// XCFramework: proprietary analytics SDK, vendor-provided libraries
// Source: open-source Alamofire, SwiftUI componentsQuick Check
Why do you include a checksum when declaring a remote binary target in Package.swift?
Lesson Recap
Binary targets distribute precompiled XCFrameworks without source code. Build with xcodebuild -create-xcframework, host the zip, compute its checksum with swift package compute-checksum, and declare it in Package.swift. Include a PrivacyInfo.xcprivacy for App Store submission.
Frequently asked questions
Is the “Binary Targets and XCFrameworks” lesson free?
Yes — the full text of “Binary Targets and XCFrameworks” is free to read here on the web, and the Swift Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Swift Academy course, upgrade to CoddyKit PRO.
What will I learn in “Binary Targets and XCFrameworks”?
Distributing closed-source code as XCFramework and consuming as a binary target. You practise Swift Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Swift Academy?
No prior experience is required. Swift Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Binary Targets and XCFrameworks” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Swift Academy lesson?
Yes. Every Swift Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.