Skip to content

fix: macOS xcframework build script bugs (single-arch linkage failure) - #196

Merged
madadam merged 3 commits into
masterfrom
apple-framework-packaging
Sep 30, 2026
Merged

madadam merged 3 commits into
masterfrom
apple-framework-packaging

Conversation

@panfilov-vladislav

Copy link
Copy Markdown
Collaborator

Summary

  • build-xcframework.sh crashed with "unbound variable" on stock macOS
    bash 3.2 whenever a target array (e.g. sim_libs) was empty, which
    happens with the default config.sh (iOS simulator targets disabled).
    "${arr[@]}" under set -u is treated as unbound in bash <4.4; switched
    to the bash-3.2-safe "${arr[@]+"${arr[@]}"}" expansion.
  • build-xcframework-macos.sh only built the host architecture, producing
    a single-slice xcframework. Xcode links a universal (arm64 + x86_64)
    binary by default, so this caused "Undefined symbols for architecture
    x86_64" at link time for consumers of OuisyncLibFFI. Now builds both
    macOS targets and lipos them into a universal static lib.
  • fix: load Ouisync framework instead of dylib in Flutter tests on macOS

Vlad Panfilov and others added 2 commits September 28, 2026 10:05
The Dart bindings switched to loading OuisyncService.framework on packaged
apps, but the test path detection still tried to load the old dylib. Update
the FLUTTER_TEST case to use the prebuilt framework in the Dart package
directory (ouisync/bindings/dart/darwin/OuisyncService.framework) for
macOS tests, matching the packaged app behavior.

Fixes tests failing with: Failed to load dynamic library
'libouisync_service.dylib': dlopen(...) (no such file)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
build-xcframework.sh expanded empty target arrays (e.g. sim_libs when
iOS simulator targets are disabled in config.sh) with "${arr[@]}" under
set -u, which macOS's stock bash 3.2 treats as an unbound variable
instead of an empty expansion. Use the bash-3.2-safe
"${arr[@]+"${arr[@]}"}" idiom instead.

build-xcframework-macos.sh only built the host architecture, producing
a single-slice xcframework. Xcode links a universal (arm64 + x86_64)
binary by default, so this caused "Undefined symbols for architecture
x86_64" at link time. Build both macOS targets and lipo them into a
universal static lib instead.
Swift codegen emitted `return .{case}` for unit variants, which the
compiler silently resolves to Optional.none whenever the enum itself
has a case named `none` (e.g. Response.none), causing decode failures.
Use `return .some(.{case})` to disambiguate.

Also export MACOSX_DEPLOYMENT_TARGET=13.0 before building the Rust
static lib so its object files match the Xcode project's deployment
target instead of the host SDK's version, avoiding linker warnings.
@madadam
madadam merged commit c0bf876 into master Sep 30, 2026
11 checks passed
@madadam
madadam deleted the apple-framework-packaging branch September 30, 2026 06:53
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