Skip to content

Build xcframework#973

Open
pblazej wants to merge 13 commits intomainfrom
blaze/xcframework
Open

Build xcframework#973
pblazej wants to merge 13 commits intomainfrom
blaze/xcframework

Conversation

@pblazej
Copy link
Copy Markdown
Contributor

@pblazej pblazej commented Apr 21, 2026

This is quite tricky/manual process, as tools like https://github.com/segment-integrations/swift-create-xcframework won't work with newer SPM (that does not allow direct xcodeproj generation, required for archiving) 💀

Install https://github.com/mxcl/swift-sh to handle dependencies.

The ultimate test:

  • run ./scripts/xcframework.swift --local
  • you should be able to replace the package with binaries for every platform
image

Repo

This will land in https://github.com/livekit/client-sdk-swift-xcframework (with LICENSE, maybe copied README).

Safety

This is mostly additive, except LK_XCFRAMEWORK for internal imports.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 21, 2026

⚠️ This PR does not contain any files in the .changes directory.

pblazej and others added 9 commits April 21, 2026 12:02
Replace the manual .o collection + libtool approach with programmatic
Xcode project generation using tuist/xcodeproj. The generated project
includes all source files as a framework target with MACH_O_TYPE=mh_dylib,
producing proper dynamic .framework bundles in the archive — the same
approach used by major frameworks like Lottie.

Key changes:
- Generate .xcodeproj with all LiveKit sources and SPM dependencies
- Archive produces dynamic .framework (not static .a)
- Use -archive/-framework syntax for xcodebuild -create-xcframework
- Remove stageArtifacts, embedSwiftModules, libtool merging
- Add _LiveKitStub target in output Package.swift (SPM workaround)
- Gracefully handle per-platform failures instead of failing fast
- Capture stderr in exec() for better error diagnostics

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix dylib install name to use @rpath (fixes runtime loading)
- Add SwiftProtobuf as dependency in output Package.swift
- Replace _LiveKitStub with LiveKitTargets wrapper target
- Copy protobuf dependency line verbatim from Package.swift
- Exclude x86_64 for tvOS/visionOS simulators (missing in WebRTC)
- Always create zip (including --local mode)
- Use .build/ as default output dir, revert .gitignore
- Throw ValidationError instead of fatalError for missing deps

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Introduce PackageManifest struct to read Package.swift once
- Merge duplicate switch cases for .swift/.m file extensions
- Remove unused repoRoot parameter from addSources
- Simplify archive failure counting

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use @_implementationOnly import under LK_XCFRAMEWORK flag so the
ObjC helpers module is available at compile time but excluded from
the public .swiftinterface, which consumers cannot resolve.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pblazej pblazej force-pushed the blaze/xcframework branch from d9b009a to 52d3f71 Compare April 21, 2026 10:02
pblazej and others added 3 commits April 21, 2026 15:54
- Split generateFrameworkProject into smaller helpers
- Extract archiveAllPlatforms from run()
- Group generatePackageSwift params into OutputContext
- Move extractVersion into PackageManifest
- Suppress false-positive duplicate_imports in LKSampleHandler
- Add targeted swiftlint:disable for file_length, function_body_length

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ency

Replace @_implementationOnly with Swift 6 `internal import` for both
SwiftProtobuf and LKObjCHelpers under LK_XCFRAMEWORK flag. This keeps
both modules out of the .swiftinterface, removing the need for consumers
to depend on SwiftProtobuf.

- Update Makefile proto target to auto-apply internal import post-generation
- Remove SwiftProtobuf from output Package.swift stencil
- Remove protobufDependency from template context

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
internal import works in both SPM and xcframework builds, removing
the need for the LK_XCFRAMEWORK conditional around this import.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
],
targets: [
.target(
name: "LiveKitTargets",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's another variant of "stub" target - just to include some source files.

@pblazej pblazej marked this pull request as ready for review April 22, 2026 09:14
@pblazej pblazej requested a review from hiroshihorie April 22, 2026 09:14
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Required of ObjC files are in the same target, should be ignored in plain SPM builds.

Add section covering COCOAPODS, LK_XCFRAMEWORK, and LK_BENCHMARK
flags with their purpose and where they're set.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant