Skip to content

[v0.77] RCTInstance.mm compilation error on x86_64: cannot initialize BOOL from 'id' type #2767

@schjoth

Description

@schjoth

Environment

react-native -v: 0.77.3
react-native-macos version: 0.77.7
npm ls react-native-macos:
node -v: 22.18.0
npm -v: x
yarn --version: x
xcodebuild -version: 
Xcode 16.4
Build version 16F6

Steps to reproduce the bug

run xcodebuild from the terminal with ONLY_ACTIVE_ARCH=NO.

Expected Behavior

Expect react-native-macos to compile fine on both intel and arm based macs.

Actual Behavior

Failing on x86_64 based machines.

Reproducible Demo

No response

Additional context

Summary

When building react-native-macos 0.77.7 for x86_64 architecture (e.g., with ONLY_ACTIVE_ARCH=NO), compilation fails in RCTInstance.mm due to an implicit type conversion that is invalid on x86_64 but works on arm64.

Environment

  • react-native-macos version: 0.77.7
  • Xcode version: 16.4
  • Apple clang version: 17.0.0
  • Target architecture: x86_64 (universal build)

Error

ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm:527:26: error: cannot initialize a parameter of type 'BOOL' (aka 'signed char') with an rvalue of type 'id _Nullable'
                         isFatal:errorData[@"isFatal"]
                                 ^~~~~~~~~~~~~~~~~~~~~

Root Cause

On x86_64, BOOL is defined as signed char, which does not allow implicit conversion from id type. On arm64, BOOL is defined as bool (C++ bool type), which has more lenient conversion rules and allows the implicit conversion.

The problematic code at line 527:

isFatal:errorData[@"isFatal"]

Suggested Fix

Explicitly convert the id to BOOL using boolValue:

isFatal:[errorData[@"isFatal"] boolValue]

Workaround

Apply the following patch to ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm:

@@ -524,7 +524,7 @@
                             name:errorData[@"name"]
                   componentStack:errorData[@"componentStack"]
                      exceptionId:error.id
-                         isFatal:errorData[@"isFatal"]
+                         isFatal:[errorData[@"isFatal"] boolValue]
                        extraData:errorData[@"extraData"]]) {
     JS::NativeExceptionsManager::ExceptionData jsErrorData{errorData};
     id<NativeExceptionsManagerSpec> exceptionsManager = [_turboModuleManager moduleForName:"ExceptionsManager"];

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions