Skip to content

Conversation

@kraenhansen
Copy link
Collaborator

@kraenhansen kraenhansen commented Feb 11, 2026

Fixes #353 and #280.

Merging this PR will:

  • Add support for versioned framework when building for Darwin.

@kraenhansen kraenhansen self-assigned this Feb 11, 2026
@kraenhansen kraenhansen added Apple 🍎 Anything related to the Apple platform (iOS, macOS, Cocoapods, Xcode, XCFrameworks, etc.) CMake RN Our `cmake` wrapping CLI Host 🏡 Our `react-native-node-api-modules` package Ferric 🦀 MacOS 💻 Anything related to the Apple MacOS platform or React Native MacOS support labels Feb 11, 2026
@kraenhansen
Copy link
Collaborator Author

@cursor please review this

@cursor
Copy link

cursor bot commented Feb 11, 2026

Based on my review of the Pull Request, here's my assessment:

PR Review: Add support for versioned darwin framework

Summary

This PR implements versioned Apple framework bundle support for Darwin/macOS targets, addressing a previously noted TODO. The changes are well-structured and follow Apple's documented framework anatomy conventions.

Changes Reviewed

1. packages/host/src/node/prebuilds/apple.ts (+140 lines)

  • Good refactoring: extracted common logic into writeInfoPlist, writeFrameworkInfoPlist, and updateLibraryInstallName helper functions
  • Changed API from versioned: boolean to kind: "flat" | "versioned" - cleaner, more explicit
  • createVersionedFramework correctly implements the Apple framework bundle structure with Versions/A/, Versions/Current symlink, and Resources/Headers symlinks

2. packages/ferric/src/targets.ts (+60 lines)

  • Added comprehensive Apple target parsing with parseAppleTargetName()
  • Proper type guards (isAppleArchitecture, isAppleOperatingSystem, isAppleVariant)
  • Clean separation of architecture, OS, and variant components

3. packages/ferric/src/build.ts (~25 net lines)

  • Refactored combineAppleLibraries to return OS metadata along with paths
  • Logic now correctly routes darwin targets to versioned frameworks

4. packages/cmake-rn/src/platforms/apple.ts (+1 line)

  • Simple API update from versioned: true to kind: "versioned"

Issues Found

Bug in createFlatFramework (line 98 in apple.ts):

  await updateLibraryInstallName(libraryName, libraryName, frameworkPath);

The first argument should be newLibraryPath (the full path to the binary), not libraryName. Compare with the versioned framework implementation which correctly passes the path:

  await updateLibraryInstallName(
    path.join("Versions", VERSIONED_FRAMEWORK_VERSION, libraryName),
    libraryName,
    frameworkPath,
  );

The updateLibraryInstallName function signature is:

async function updateLibraryInstallName(binaryPath: string, libraryName: string, cwd: string)

So for flat frameworks, line 98 should be:

await updateLibraryInstallName(libraryName, libraryName, frameworkPath);

Wait, looking more carefully - since cwd is set to frameworkPath, and libraryName is just the filename (not a full path), this should actually work because install_name_tool will resolve libraryName relative to frameworkPath. However, this is inconsistent with the versioned framework call which uses a relative path. The behavior is correct but could be clearer.

Minor Suggestions

  1. Consider adding tests for createVersionedFramework - even a basic structure validation would be valuable given the complexity of the symlink setup.

  2. Type inconsistency: In build.ts, paths.length == 1 uses == while other comparisons use ===. Should be consistent:

        } else if (paths.length == 1) {

Overall Assessment

Approve with minor fixes. The implementation is solid and follows Apple conventions correctly. The refactoring improves code organization and the new parseAppleTargetName utility is well-designed.

The main item to address is the == vs === consistency issue. The rest of the code is clean and the changeset is appropriately scoped.

Open in Cursor Open in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Apple 🍎 Anything related to the Apple platform (iOS, macOS, Cocoapods, Xcode, XCFrameworks, etc.) CMake RN Our `cmake` wrapping CLI Ferric 🦀 Host 🏡 Our `react-native-node-api-modules` package MacOS 💻 Anything related to the Apple MacOS platform or React Native MacOS support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assemble a versioned framework bundle for MacOS

2 participants