Skip to content

Commit

Permalink
add react-native 0.73 support (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kudo authored Jun 16, 2024
1 parent fc6c2a1 commit ca4e3fc
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rn-version: ['0.72', '0.71']
rn-version: ['0.73']
v8-android-variant:
[v8-android-jit, v8-android-jit-nointl, v8-android, v8-android-nointl]
# include:
Expand All @@ -35,11 +35,11 @@ jobs:
- uses: actions/checkout@v2
- uses: oven-sh/setup-bun@v1

- name: Use JDK 11
- name: Use JDK 17
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
java-version: '17'

- name: Restore yarn caches
uses: actions/cache@v2
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/expo-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ jobs:
- uses: actions/checkout@v2
- uses: oven-sh/setup-bun@v1

- name: Use JDK 11
- name: Use JDK 17
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
java-version: '17'

- name: Restore yarn caches
uses: actions/cache@v2
Expand All @@ -41,7 +41,7 @@ jobs:

- name: Generate TestApp
run: |
yarn create expo-app TestApp
yarn create expo-app -t blank@@sdk-50 TestApp
cd TestApp
yarn add v8-android-jit
yarn add file:../react-native-v8
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/expo-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
- uses: actions/checkout@v2
- uses: oven-sh/setup-bun@v1

- name: 🔨 Switch to Xcode 14.3.1
run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app

- name: Restore yarn caches
uses: actions/cache@v2
with:
Expand All @@ -36,7 +39,7 @@ jobs:

- name: Generate TestApp
run: |
yarn create expo-app TestApp
yarn create expo-app -t blank@@sdk-50 TestApp
cd TestApp
yarn add v8-ios
yarn add file:../react-native-v8
Expand All @@ -54,7 +57,7 @@ jobs:
- name: Run TestApp
working-directory: ../TestApp/ios
run: |
SIMUDID=$(xcrun simctl list devices available -j | jq -r '.devices."com.apple.CoreSimulator.SimRuntime.iOS-16-2"[] | select(.name=="iPhone 14 Pro") | .udid')
SIMUDID=$(xcrun simctl list devices available -j | jq -r '.devices."com.apple.CoreSimulator.SimRuntime.iOS-16-4"[] | select(.name=="iPhone 14 Pro") | .udid')
echo "Using simulator udid[${SIMUDID}]"
xcrun simctl boot ${SIMUDID}
xcrun simctl install booted ./build/Build/Products/Release-iphonesimulator/TestApp.app
Expand Down
2 changes: 1 addition & 1 deletion RNV8.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if ENV["REACT_NATIVE_OVERRIDE_VERSION"]
end
reactNativeTargetVersion = reactNativeVersion.split('.')[1].to_i

folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_CFG_NO_COROUTINES=1 -Wno-comma -Wno-shorten-64-to-32'

Pod::Spec.new do |s|
s.name = 'RNV8'
Expand Down
4 changes: 4 additions & 0 deletions plugin/build/withV8ExpoAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ function updateIosAppDelegate(contents) {
#define FOLLY_HAVE_PTHREAD 1
#endif
#ifndef FOLLY_CFG_NO_COROUTINES
#define FOLLY_CFG_NO_COROUTINES 1
#endif
#import <memory>
#import <React/RCTCxxBridgeDelegate.h>
#import <React/RCTJSIExecutorRuntimeInstaller.h>
Expand Down
4 changes: 4 additions & 0 deletions plugin/src/withV8ExpoAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ export function updateIosAppDelegate(contents: string): string {
#define FOLLY_HAVE_PTHREAD 1
#endif
#ifndef FOLLY_CFG_NO_COROUTINES
#define FOLLY_CFG_NO_COROUTINES 1
#endif
#import <memory>
#import <React/RCTCxxBridgeDelegate.h>
#import <React/RCTJSIExecutorRuntimeInstaller.h>
Expand Down
2 changes: 1 addition & 1 deletion scripts/gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def main():
patcher.add_v8_support()
patcher.add_vm_hint()
subprocess.run(
["npx", "react-native", "run-android", "--variant", "release", "--no-packager"]
["npx", "react-native", "run-android", "--mode", "release", "--no-packager"]
)


Expand Down
18 changes: 9 additions & 9 deletions scripts/lib/patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,21 @@ def _patch_app_gradle(self):
f.write(new_content)

def _patch_react_native_host(self):
main_app_files = glob.glob("android/**/MainApplication.java", recursive=True)
main_app_files = glob.glob("android/**/MainApplication.kt", recursive=True)
v8_block = """
@Override
protected com.facebook.react.bridge.JavaScriptExecutorFactory getJavaScriptExecutorFactory() {
return new io.csie.kudo.reactnative.v8.executor.V8ExecutorFactory(
getApplicationContext(),
getPackageName(),
com.facebook.react.modules.systeminfo.AndroidInfoHelpers.getFriendlyDeviceName(),
getUseDeveloperSupport());
override fun getJavaScriptExecutorFactory(): com.facebook.react.bridge.JavaScriptExecutorFactory {
return io.csie.kudo.reactnative.v8.executor.V8ExecutorFactory(
applicationContext,
packageName,
com.facebook.react.modules.systeminfo.AndroidInfoHelpers.getFriendlyDeviceName(),
useDeveloperSupport
)
}
"""
for file in main_app_files:
self._replace_file_content(
file,
r"(protected String getJSMainModuleName\(\) \{\n.*?\n.*?\}\n)",
r'(override fun getJSMainModuleName\(\): String = "index")',
"\\1" + v8_block,
re_flags=(re.DOTALL | re.MULTILINE),
)
Expand Down
9 changes: 8 additions & 1 deletion src/v8runtime/V8Inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@
#include <cxxreact/MessageQueueThread.h>
#include <condition_variable>
#include "v8-inspector.h"

#if REACT_NATIVE_TARGET_VERSION >= 73

#if __has_include(<React-jsinspector/jsinspector/InspectorInterfaces.h>)
#include <React-jsinspector/jsinspector/InspectorInterfaces.h>
#else
#include "jsinspector-modern/InspectorInterfaces.h"
#endif // __has_include(<React-jsinspector/jsinspector/InspectorInterfaces.h>)

namespace jsinspector = facebook::react::jsinspector_modern;
#else
#include "jsinspector/InspectorInterfaces.h"
namespace jsinspector = facebook::react;
#endif
#endif // REACT_NATIVE_TARGET_VERSION >= 73

namespace rnv8 {

Expand Down

0 comments on commit ca4e3fc

Please sign in to comment.