From bfe4282811d53a98fccb564471062e4848df1505 Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Thu, 15 Jun 2023 12:27:32 -0700 Subject: [PATCH 1/2] Re-enable direct debugging with JSC on iOS 16.4+ (#37914) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37914 Restores https://github.com/facebook/react-native/pull/37874 (reverted earlier today), with fix for `JSCRuntime.cpp` build on Android. Changelog: None Reviewed By: cortinico Differential Revision: D46762984 fbshipit-source-id: 6d56f81b9d0c928887860993b2b729ed96c0734c --- packages/react-native/ReactCommon/jsc/JSCRuntime.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp b/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp index 7958519e683f6d..dd592007eeb591 100644 --- a/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp +++ b/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp @@ -398,6 +398,13 @@ JSCRuntime::JSCRuntime(JSGlobalContextRef ctx) stringCounter_(0) #endif { +#ifndef NDEBUG +#ifdef TARGET_OS_MAC + if (__builtin_available(macOS 13.3, iOS 16.4, tvOS 16.4, *)) { + JSGlobalContextSetInspectable(ctx_, true); + } +#endif +#endif } JSCRuntime::~JSCRuntime() { From 3c99afe8f229d8cea9056c8748bc49b968e6026f Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Thu, 17 Aug 2023 22:04:44 -0700 Subject: [PATCH 2/2] Guard `JSGlobalContextSetInspectable` behind a compile time check for Xcode 14.3+ (#39037) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: An earlier [change](https://github.com/facebook/react-native/commit/8b1bf058c4bcbf4e5ca45b0056217266a1ed870c) I made (that huntie resubmitted) only works on Xcode 14.3+ (See more info [here](https://github.com/react-native-community/discussions-and-proposals/discussions/687)). This change adds the appropriate compiler checks so that the change is compatible with Xcode 14.2 and earlier, and therefore cherry-pickable to 0.71 and 0.72. The check works by checking if iOS 16.4+ is defined, which is the closest proxy I could find for "Is this Xcode 14.3". ## Changelog: [IOS] [CHANGED] - Guard `JSGlobalContextSetInspectable` behind a compile time check for Xcode 14.3+ Pull Request resolved: https://github.com/facebook/react-native/pull/39037 Test Plan: I can't actually test on Xcode 14.2 (it won't launch on my MacBook 😢), but I made a similar [PR](https://github.com/microsoft/react-native-macos/pull/1848) in React Native macOS, whose CI checks run against Xcode 14.2 and I'm getting passing checks there. Reviewed By: huntie Differential Revision: D48414196 Pulled By: NickGerleman fbshipit-source-id: ba10a6505dd11d982cc56c02bf9f7dcdc104bbec --- packages/react-native/ReactCommon/jsc/JSCRuntime.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp b/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp index dd592007eeb591..523b1be36937ee 100644 --- a/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp +++ b/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp @@ -302,6 +302,9 @@ class JSCRuntime : public jsi::Runtime { #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0 #define _JSC_NO_ARRAY_BUFFERS #endif +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 160400 +#define _JSC_HAS_INSPECTABLE +#endif #endif #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) #if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_11 @@ -399,7 +402,7 @@ JSCRuntime::JSCRuntime(JSGlobalContextRef ctx) #endif { #ifndef NDEBUG -#ifdef TARGET_OS_MAC +#ifdef _JSC_HAS_INSPECTABLE if (__builtin_available(macOS 13.3, iOS 16.4, tvOS 16.4, *)) { JSGlobalContextSetInspectable(ctx_, true); }