Skip to content

iOS Crash: com.facebook.react.runtime.JavaScript: EXC_BAD_ACCESS (code=1, address=0x17) #649

@DavidMarinCalleja

Description

@DavidMarinCalleja

Description

We are having trouble running a Swift project that uses an XCFramework generated from Rock. The React Native project generated as a Rock project has a native module with Nitro. When launching the project from XCode, it crashes at:

com.facebook.react.runtime.JavaScript: EXC_BAD_ACCESS (code=1, address=0x17)

// File: ReactInstance.cpp
runtime_->unstable_initializeOnJsThread();

Environment

  • Platform: iOS
    ├── @babel/core@7.28.5
    ├── @babel/preset-env@7.28.5
    ├── @babel/runtime@7.28.4
    ├── @callstack/react-native-brownfield@2.0.1
    ├── @react-native/babel-preset@0.81.1
    ├── @react-native/eslint-config@0.81.1
    ├── @react-native/metro-config@0.81.1
    ├── @react-native/typescript-config@0.81.1
    ├── @rock-js/platform-ios@0.11.12
    ├── @rock-js/plugin-brownfield-ios@0.11.12
    ├── @rock-js/plugin-metro@0.11.12
    ├── @rock-js/welcome-screen@0.11.12
    ├── @types/react-test-renderer@19.1.0
    ├── @types/react@19.2.7
    ├── babel-jest@29.7.0
    ├── eslint@8.57.1
    ├── jest@29.7.0
    ├── prettier@2.8.8
    ├── react-native-awesome-library@0.0.0 -> ./modules/awesome-library
    ├── react-native-nitro-modules@0.31.10
    ├── react-native@0.81.1
    ├── react-test-renderer@19.1.0
    ├── react@19.1.0
    ├── rock@0.11.12
    └── typescript@5.9.3

Steps taken to create the Rock React Native project

  • Create the Rock project npm create rock with this configuration:
    • What platforms do you want to start with? iOS
    • Which bundler do you want to use? Metro
    • Which plugins do you want to use? Brownfield iOS
    • What do you want to use as cache for your remote builds? None
    • Do you want to install dependencies? Yes
  • Create a native library npx create-react-native-library@latest awesome-library with this configuration:
    • Do you want to create a local library? Yes
    • Where do you want to create the library? modules/awesome-library
    • What do you want to name the npm package? react-native-awesome-library
    • What type of library do you want to develop? Nitro module
  • Install Cocoapods dependencies pod install --project-directory=ios
  • Update npm npm install
  • Inside the module folder cd modules/awesome-library install Nigrogen npx -y nitrogen .

I modify the code in App.tsx to use the native module with this code:

import React from 'react';
import { SafeAreaView, StyleSheet, Text, View } from 'react-native';
import WelcomeScreen from '@rock-js/welcome-screen';
import { multiply } from 'react-native-awesome-library';

export default function App() {
  const result = multiply(3, 8);

  return (
    <View style={styles.container}>
      <SafeAreaView style={styles.header}>
        <Text style={styles.text}>Result: {result}</Text>
      </SafeAreaView>
      <View style={styles.content}>
        <WelcomeScreen />
      </View>
    </View>
  );
}

// Here there is CSS style not copied in this example
  • Generate the XCFramework files with npx rock package:ios --scheme RockProjectDemoReact --configuration Release

Change in the Xcode Project that uses the XCFramework from the previous step

  • Once the XCFramework files have been successfully generated, I create a basic iOS project and use drag & drop to add the files to the section: Frameworks, Libraries, and Embedded
  • The structure containing the @main tag is created in this init:
        ReactNativeBrownfield.shared.bundle = ReactNativeBundle
        ReactNativeBrownfield.shared.startReactNative()
  • The structure shown in the view, modify the content with:
        VStack {
            ReactNativeView(moduleName: "RockProjectDemo")
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions