Skip to content

Prototype: Swift Package Manager distribution (xcframework)#1486

Open
bmehta001 wants to merge 7 commits into
microsoft:mainfrom
bmehta001:bhamehta/spm-xcframework-prototype
Open

Prototype: Swift Package Manager distribution (xcframework)#1486
bmehta001 wants to merge 7 commits into
microsoft:mainfrom
bmehta001:bhamehta/spm-xcframework-prototype

Conversation

@bmehta001

@bmehta001 bmehta001 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Prototype: Swift Package Manager distribution (xcframework)

First-pass scaffold to distribute the 1DS C++ SDK to Apple app developers via Swift Package Manager — the successor to CocoaPods (trunk goes read-only 2 Dec 2026). There is no official in-repo podspec today, and the existing wrappers/swift/Package.swift is a local-build skeleton rather than a distributable package.

Approach

SPM cannot practically compile this C++ tree from source (CMake/Bond/sqlite/zlib/platform conditionals), so:

  • C++ core + Obj-C wrappers ship as a prebuilt MATTelemetry.xcframework (.binaryTarget). The Obj-C wrappers compile into libmat.a on Apple.
  • The Swift layer (wrappers/swift/Sources/OneDSSwift) is compiled from source on top of the ObjCModule vended by the xcframework.
  • The first version intentionally ships iOS device + iOS simulator slices only. Package.swift advertises .iOS(.v12) only until macOS / Catalyst / visionOS slices are added.

What's here

  • Package.swift — distributable SPM manifest: binaryTarget + OneDSSwift source target.
  • tools/apple/build-xcframework.sh — builds static libmat.a slices via build-ios.sh, combines simulator archs with lipo, and assembles MATTelemetry.xcframework with xcodebuild -create-xcframework.
  • tools/apple/module.modulemap + MATTelemetry-umbrella.h — vend the ObjCModule Clang module.
  • tools/apple/MATTelemetryAvailability.json — generated by the xcframework build and read by Package.swift so Swift source exclusions match the optional modules actually built into the binary.
  • .github/workflows/spm-release.yml — on a published vX.Y.Z.W release: build the xcframework on a macOS runner, upload it to the Release, pin the binaryTarget url:+checksum:, and push a 3-component SemVer tag (X.Y.Z) that SPM can resolve.
  • tools/apple/README.md — approach, build/consume, release wiring, and remaining TODOs.

Validation performed on macOS

Validated locally with Xcode on macOS:

  • ./build-ios.sh clean release arm64 iphonesimulator produced out/lib/libmat.a as a static archive and included Obj-C wrapper symbols.
  • tools/apple/build-xcframework.sh release succeeded.
  • Produced expected slices:
    • ios-arm64
    • ios-arm64_x86_64-simulator
  • SwiftPM iOS Simulator build succeeded:
    xcodebuild -scheme OneDSSwift -destination 'generic/platform=iOS Simulator' build
  • Obj-C module/static-link smoke test built and ran on an iOS Simulator.

Consume after a release

.package(url: "https://github.com/microsoft/cpp_client_telemetry.git", from: "3.10.161")

Remaining TODOs

  • Add macOS / Mac Catalyst / visionOS slices, then advertise those platforms in Package.swift.
  • Code-sign the xcframework before distribution.
  • Decide where the root Package.swift lives long-term, since it makes the repository an SPM package.
  • Exercise the release workflow end-to-end on an actual published release.

Companion to the official vcpkg port (C++ consumers) — SPM serves Apple app developers; the two are complementary.

bmehta001 and others added 4 commits June 18, 2026 01:54
First-pass scaffold to support Swift Package Manager on Apple platforms (the
successor to CocoaPods, whose trunk goes read-only Dec 2 2026; there is no
official in-repo podspec today).

SPM cannot practically compile the C++ tree (CMake/Bond/sqlite/zlib/platform
conditionals), so the compiled C++ core + Obj-C wrappers ship as a prebuilt
MATTelemetry.xcframework (.binaryTarget) and the thin Swift layer
(wrappers/swift/Sources/OneDSSwift) is compiled from source on top of the
Obj-C module the xcframework vends.

- Package.swift (root): binaryTarget (xcframework) + OneDSSwift source target;
  documents the path: -> url:+checksum: switch for releases.
- tools/apple/build-xcframework.sh: per-slice static libmat.a via build-ios.sh
  (iOS device + simulator), lipo, then xcodebuild -create-xcframework; emits a
  zip + SPM checksum.
- tools/apple/module.modulemap + MATTelemetry-umbrella.h: vend the `ObjCModule`
  Clang module the existing Swift sources already import.
- tools/apple/README.md: approach, build/consume steps, release wiring, and the
  macOS-validation TODOs (macOS/Catalyst slices, conditional modules, header
  flattening, signing).

NOT yet validated on macOS -- needs a mac with Xcode to run the build and adjust
the static-lib path / header layout.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds .github/workflows/spm-release.yml: on a published 4-component release
(vX.Y.Z.W), a macOS-runner job builds MATTelemetry.xcframework, uploads it to
the Release, computes the SPM checksum, rewrites the Package.swift binaryTarget
from path: to url:+checksum:, and pushes a 3-component SemVer tag (X.Y.Z) that
Swift Package Manager can resolve (the SDK's own 4-component tags are not valid
SemVer, so SPM ignores them).

Also documents the parallel-tag consumption (`from: "3.10.161"`) and the release
flow in tools/apple/README.md. Mirrors the vcpkg-release-bump pattern.

NOT yet validated -- needs the prototype merged (so Package.swift exists at the
release tag) and a macOS runner; the build script itself still needs a first
run on a mac.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy objc_begin/end support headers into the flattened xcframework Headers directory and mirror the existing Swift wrapper optional-module source exclusions in the root package manifest.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Avoid vending private wrapper headers from the flattened MATTelemetry.xcframework Headers directory, which otherwise triggers incomplete umbrella warnings when ObjCModule is imported.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bmehta001 bmehta001 marked this pull request as ready for review June 18, 2026 22:29
@bmehta001 bmehta001 requested a review from a team as a code owner June 18, 2026 22:29
@bmehta001 bmehta001 requested a review from Copilot June 18, 2026 22:30
@bmehta001 bmehta001 self-assigned this Jun 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prototypes distributing the 1DS C++ SDK to Apple developers via Swift Package Manager by shipping the C++ core + Obj-C wrappers as a prebuilt MATTelemetry.xcframework binary target, with the Swift wrapper layer (OneDSSwift) compiled from source on top.

Changes:

  • Add a distributable root Package.swift using an SPM binaryTarget plus the existing Swift sources.
  • Add Apple tooling to build and package MATTelemetry.xcframework (modulemap + umbrella header + build script).
  • Add a GitHub Actions workflow to build/upload the xcframework on release and publish an SPM-resolvable SemVer tag.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Package.swift New root SPM manifest for distributing OneDSSwift backed by a binary xcframework.
tools/apple/build-xcframework.sh Script to build per-slice libmat.a, assemble an xcframework, zip it, and compute SPM checksum.
tools/apple/module.modulemap Declares the ObjCModule Clang module for Swift to import from the xcframework.
tools/apple/MATTelemetry-umbrella.h Umbrella header listing Obj-C wrapper headers to export via the modulemap.
tools/apple/README.md Documentation of the approach, local build steps, and release wiring/TODOs.
.github/workflows/spm-release.yml Release automation: build xcframework, upload to Release, rewrite manifest to url+checksum, and tag for SPM.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Package.swift
Comment thread Package.swift Outdated
Comment thread tools/apple/build-xcframework.sh
Comment thread tools/apple/MATTelemetry-umbrella.h Outdated
bmehta001 and others added 2 commits June 18, 2026 17:47
Generate the ObjC umbrella and availability manifest from the modules built into the xcframework, read that manifest from Package.swift, and guard Swift type aliases for optional modules.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Drive Swift source exclusions and ObjC umbrella optional imports from the modules actually built into MATTelemetry.xcframework, remove unsupported macOS package advertising, and add Apple system linker settings for the static binary target.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comment thread Package.swift Outdated
Comment on lines +118 to +124
.linkedFramework("CFNetwork"),
.linkedFramework("CoreFoundation"),
.linkedFramework("Foundation"),
.linkedFramework("IOKit"),
.linkedFramework("Network"),
.linkedFramework("SystemConfiguration"),
.linkedFramework("UIKit"),
Comment thread tools/apple/build-xcframework.sh Outdated
"sanitizer": $has_sanitizer
}
EOF
cp "$OUT/MATTelemetryAvailability.json" "$ROOT/tools/apple/MATTelemetryAvailability.json"
Remove macOS package advertising until a macOS slice exists, add iOS linker settings for the static xcframework, and avoid repeating build tool setup for each slice.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Comment thread tools/apple/README.md
Comment on lines +3 to +6
**Status: prototype / not yet validated on macOS.** This is a first-pass scaffold
for distributing the 1DS C++ SDK to Apple app developers via **Swift Package
Manager (SPM)**, the successor to CocoaPods (the CocoaPods trunk goes read-only
on 2 Dec 2026, and there is no official in-repo podspec today).
Comment on lines +20 to +21
# NOTE: this is a first-pass scaffold. It has NOT been executed on macOS yet;
# validate on a mac and adjust the static-lib path / header flattening as needed.
Comment on lines +43 to +48
has_dataviewer=false
has_privacyguard=false
has_sanitizer=false
[[ -d "$ROOT/lib/modules/dataviewer" ]] && has_dataviewer=true
[[ -d "$ROOT/lib/modules/privacyguard" ]] && has_privacyguard=true
[[ -d "$ROOT/lib/modules/sanitizer" ]] && has_sanitizer=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants