facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
117.2k stars 24.1k forks source link

Symbol not found: (_JSGlobalContextSetInspectable) #44077

Open master96 opened 3 months ago

master96 commented 3 months ago

Description

When trying to run release built on iOS 15.8.2. App crashes as soon as it starts.

I was able to find issue in https://forums.developer.apple.com/forums/thread/749534

Note - We have react-native-firebase integration which requires to use static framework bundling.

I am assuming following check in /node_modules/react-native/ReactCommon/jsc/JSCRuntime.cpp isnt working

 if (__builtin_available(macOS 13.3, iOS 16.4, tvOS 16.4, *)) {
    JSGlobalContextSetInspectable(ctx_, true);
  }

i get following error

dyld[1327]: Symbol not found: (_JSGlobalContextSetInspectable)
  Referenced from: '/private/var/containers/Bundle/Application/1867E253-BC84-4E34-BE05-EA20CAF16CD3/ProviderApp.app/ProviderApp'
  Expected in: '/System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore'
Message from debugger: killed

I got it working for now updating it to following bit in -> /node_modules/react-native/ReactCommon/jsc/JSCRuntime.cpp

  #if ( __OSX_AVAILABLE_STARTING(MAC_NA, IPHONE_16_4))
      JSGlobalContextSetInspectable(ctx_, true);
#endif

Steps to reproduce

  1. Change scheme to release in XCode
  2. Run it on iOS =< 15.8.2

React Native Version

0.72.12

Affected Platforms

Runtime - iOS

Output of npx react-native info

System:
  OS: macOS 14.2.1
  CPU: (12) arm64 Apple M2 Pro
  Memory: 186.39 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.18.2
    path: ~/.nvm/versions/node/v18.18.2/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.nvm/versions/node/v18.18.2/bin/yarn
  npm:
    version: 10.2.2
    path: ~/.nvm/versions/node/v18.18.2/bin/npm
  Watchman:
    version: 2023.12.04.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11076708
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.12
    wanted: 0.72.12
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: false
  newArchEnabled: false

Stacktrace or Logs

dyld[1327]: Symbol not found: (_JSGlobalContextSetInspectable)
  Referenced from: '/private/var/containers/Bundle/Application/1867E253-BC84-4E34-BE05-EA20CAF16CD3/ProviderApp.app/ProviderApp'
  Expected in: '/System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore'
Message from debugger: killed

Reproducer

-

Screenshots and Videos

No response

github-actions[bot] commented 3 months ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
hash3r commented 2 months ago

@master96 thanks for reporting. The crash will be fixed with the PR #44185

cipolleschi commented 2 months ago

Added cherry pick requests:

The fix with the next release of each RN patch version

linaia commented 2 months ago

I've tryed the fix for 0.72.10 -> when I build with XCode 15.3 (15E204a), same than @master96 , I have the following error :

/..../node_modules/react-native/ReactCommon/jsc/JSCRuntime.cpp:406:7 Use of undeclared identifier '__AVAILABILITY_INTERNALIPHONE_16_4'

linaia commented 2 months ago

Here is the patch that worked for me :

diff --git a/node_modules/react-native/ReactCommon/jsc/JSCRuntime.cpp b/node_modules/react-native/ReactCommon/jsc/JSCRuntime.cpp
index 523b1be..c667741 100644
--- a/node_modules/react-native/ReactCommon/jsc/JSCRuntime.cpp
+++ b/node_modules/react-native/ReactCommon/jsc/JSCRuntime.cpp
@@ -403,11 +403,13 @@ JSCRuntime::JSCRuntime(JSGlobalContextRef ctx)
 {
 #ifndef NDEBUG
 #ifdef _JSC_HAS_INSPECTABLE
-  if (__builtin_available(macOS 13.3, iOS 16.4, tvOS 16.4, *)) {
+#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 16400
+  if (__builtin_available(macOS 13.3, iOS 16.4, tvOS 16.4, *))
     JSGlobalContextSetInspectable(ctx_, true);
   }
 #endif
 #endif
+#endif
 }

 JSCRuntime::~JSCRuntime() {
linaia commented 2 months ago

FYI according to apple support, heree is the documentation for running code on a specific platform or OS version :

https://developer.apple.com/documentation/xcode/running-code-on-a-specific-version/

cipolleschi commented 1 month ago

cc. @Saadnajmi

Saadnajmi commented 1 month ago

Here is the patch that worked for me :

diff --git a/node_modules/react-native/ReactCommon/jsc/JSCRuntime.cpp b/node_modules/react-native/ReactCommon/jsc/JSCRuntime.cpp
index 523b1be..c667741 100644
--- a/node_modules/react-native/ReactCommon/jsc/JSCRuntime.cpp
+++ b/node_modules/react-native/ReactCommon/jsc/JSCRuntime.cpp
@@ -403,11 +403,13 @@ JSCRuntime::JSCRuntime(JSGlobalContextRef ctx)
 {
 #ifndef NDEBUG
 #ifdef _JSC_HAS_INSPECTABLE
-  if (__builtin_available(macOS 13.3, iOS 16.4, tvOS 16.4, *)) {
+#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 16400
+  if (__builtin_available(macOS 13.3, iOS 16.4, tvOS 16.4, *))
     JSGlobalContextSetInspectable(ctx_, true);
   }
 #endif
 #endif
+#endif
 }

 JSCRuntime::~JSCRuntime() {

__MAC_OS_X_VERSION_MAX_ALLOWED >= 16400 means you're checking that you're compiling for an Xcode version that supports macOS 16.4+.. which doesn't exist (the latest is macOS 14). So it just ifdefs the code out, which means that direct debugging with JavascriptCore is broken for iOS 16.4+. This is currently the case with the latest fixes to React Native. The "proper" fix AFAIK is to weak link JacascriptCore. I have a fix for cocoapods out (https://github.com/facebook/react-native/pull/39549) but I'm not sure it will get merged due to other issues. If you aren't using JSC and are using Hermes, then I suppose it doesn't matter if you keep the ifdef in.

jenskuhrjorgensen commented 3 weeks ago

The fix for this was patched to all version of RN >= 0.72: https://github.com/facebook/react-native/commit/ae4c62a933f7ffcfe4be8a3499fb6e1cbe7f1c43