Cannot initialize Babylon Native with Expo

Hi all,

I’m encountering an issue while integrating BabylonJS into a React Native Expo app. Here’s a brief overview:

  1. Setup:
    I created the app using npx create-expo-app@latest and installed the @babylonjs/react-native package.
    I followed the usage details from the npm package documentation and implemented the following component:
import { StyleSheet } from "react-native";
import { EngineView, useEngine } from "@babylonjs/react-native";
import { Engine, Scene, Camera } from "@babylonjs/core";
import { useEffect, useState } from "react";

export default function HomeScreen() {
  const engine = useEngine();
  const [camera, setCamera] = useState<Camera>();

  useEffect(() => {
    if (engine) {
      const scene = new Scene(engine);
      scene.createDefaultCamera(true);
      setCamera(scene.activeCamera!);
      // Setup the scene!
    }
  }, [engine]);

  return (
    <>
      <EngineView style={{ flex: 1 }} camera={camera} />
    </>
  );
}
  1. Package.json:

Here is my package.json file:

{
  "name": "react-native-expo-babylon",
  "main": "expo-router/entry",
  "version": "1.0.0",
  "scripts": {
    "start": "expo start",
    "reset-project": "node ./scripts/reset-project.js",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "test": "jest --watchAll",
    "lint": "expo lint"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@babylonjs/react-native": "^1.8.6",
    "@expo/vector-icons": "^14.0.2",
    "@react-navigation/bottom-tabs": "^7.2.0",
    "@react-navigation/native": "^7.0.14",
    "expo": "~52.0.43",
    "expo-blur": "~14.0.3",
    "expo-constants": "~17.0.8",
    "expo-font": "~13.0.4",
    "expo-haptics": "~14.0.1",
    "expo-linking": "~7.0.5",
    "expo-router": "~4.0.20",
    "expo-splash-screen": "~0.29.22",
    "expo-status-bar": "~2.0.1",
    "expo-symbols": "~0.2.2",
    "expo-system-ui": "~4.0.9",
    "expo-web-browser": "~14.0.2",
    "react": "18.3.1",
    "react-dom": "18.3.1",
    "react-native": "0.76.9",
    "react-native-gesture-handler": "~2.20.2",
    "react-native-permissions": "^5.3.0",
    "react-native-reanimated": "~3.16.1",
    "react-native-safe-area-context": "4.12.0",
    "react-native-screens": "~4.4.0",
    "react-native-web": "~0.19.13",
    "react-native-webview": "13.12.5"
  },
  "devDependencies": {
    "@babel/core": "^7.25.2",
    "@types/jest": "^29.5.12",
    "@types/react": "~18.3.12",
    "@types/react-test-renderer": "^18.3.0",
    "jest": "^29.2.1",
    "jest-expo": "~52.0.6",
    "react-test-renderer": "18.3.1",
    "typescript": "^5.3.3"
  },
  "private": true
}
  1. Troubleshooting Attempt:
    Based on community discussions, I added the following line to the AppDelegate.mm file to disable remote debugging:
[self.bridge.devSettings setIsDebuggingRemotely:NO];

However, this didn’t resolve the issue.

  1. Environment:
  • Xcode version: 16.3
  • Simulator: iPhone 16 Pro (iOS 18.3.1)

Has anyone encountered a similar issue or could provide insights into what might be wrong with my setup? Any help would be greatly appreciated!

cc @BabylonNative

@babylonjs/react-native-iosandroid-0-71 package is missing in package.json
Also, ReactNative is supported up to 0.73

More details on this page : GitHub - BabylonJS/BabylonReactNative: Build React Native applications with the power of Babylon Native

3 Likes

Hello again,

I have started clean and didn’t use neither Expo nor BabylonReactNativeSample, but looks like I have a different problem. I’ll try to be more concise.

  1. Cloned the BabylonReactNative repo and started from scratch. (Not Sample repo)
  2. Navigated to Apps/Playground/0.71 and ran npm install. There, package.json has "@babylonjs/react-native-iosandroid": "file:../../../Modules/@babylonjs/react-native-iosandroid"
  3. Due to a checksum error on pod install, modified Apps/Playground/0.71/node_modules/react-native/third-party-podspecs/boost.podspec with the following (jfrog URL in http is not working):
  spec.source = { :http => 'https://sourceforge.net/projects/boost/files/boost/1.76.0/boost_1_76_0.tar.bz2',
                  :sha256 => 'f0397ba6e982c4450f27bf32a2a83292aba035b827a5623a14636ea583318c41' }
  1. Navigated to Apps/Playground/0.71/ios and ran pod install
  2. Navigated to Apps/Playground/0.71 and ran npm run ios
  3. While building, I have this error

— xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:iOS Simulator, id:C56A23C8-DDAB-48A9-9C11-E7048628CE43, OS:18.3.1, name:iPhone 13 }
{ platform:iOS Simulator, id:C56A23C8-DDAB-48A9-9C11-E7048628CE43, OS:18.3.1, name:iPhone 13 }
** BUILD FAILED **

The following build commands failed:
CompileC /Users/user/Library/Developer/Xcode/DerivedData/Playground-aonxzexzrtimmlfepjqopxzscbqk/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RCT-Folly.build/Objects-normal/arm64/json.o /Users/user/repos/BabylonReactNative/Apps/Playground/0.71/ios/Pods/RCT-Folly/folly/json.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target ‘RCT-Folly’ from project ‘Pods’)
Building workspace Playground with scheme Playground and configuration Debug
(2 failures)
]

Node.js v20.17.0

I am using an iPhone 13 simulator (OS 18.3, XCode 16.2 16C5032a)

Thank you very much for being around :heart:

Note: There is also this warning

/Users/user/repos/BabylonReactNative/Apps/Playground/0.71/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target ‘IPHONEOS_DEPLOYMENT_TARGET’ is set to 11.0, but the range of supported deployment target versions is 12.0 to 18.2.99. (in target ‘react-native-slider’ from project ‘Pods’)
/Users/user/repos/BabylonReactNative/Apps/Playground/0.71/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target ‘IPHONEOS_DEPLOYMENT_TARGET’ is set to 11.0, but the range of supported deployment target versions is 12.0 to 18.2.99. (in target ‘libevent’ from project ‘Pods’)
/Users/user/repos/BabylonReactNative/Apps/Playground/0.71/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target ‘IPHONEOS_DEPLOYMENT_TARGET’ is set to 11.0, but the range of supported deployment target versions is 12.0 to 18.2.99. (in target ‘YogaKit’ from project ‘Pods’)

Tried replacing all lines IPHONEOS_DEPLOYMENT_TARGET = 11.0 in Apps/Playground/0.71/ios/Pods/Pods.xcodeproj/project.pbxproj with 18.2 but that only cleared the warning, the error above is unaffected.

**Expo Note: ** Installing Babylon native-iosandroid package and tweaking did not result a succesful build, so this time I tried again with Babylon Native playground app.