Skip to content

Instantly share code, notes, and snippets.

@Kudo
Created December 16, 2022 07:26
Show Gist options
  • Save Kudo/7448c733f12e700c7fbed76251fa3553 to your computer and use it in GitHub Desktop.
Save Kudo/7448c733f12e700c7fbed76251fa3553 to your computer and use it in GitHub Desktop.
expo sdk 47 + react-native 0.71
diff --git a/node_modules/expo/android/build.gradle b/node_modules/expo/android/build.gradle
index bd98c80..52bb7f3 100644
--- a/node_modules/expo/android/build.gradle
+++ b/node_modules/expo/android/build.gradle
@@ -121,10 +121,12 @@ android {
srcDirs += new File(project.buildDir, generatedFilesSrcDir)
def rnVersion = getRNVersion()
- if (rnVersion >= versionToNumber(0, 69, 0)) {
+ if (rnVersion >= versionToNumber(0, 71, 0)) {
srcDirs += "src/reactNativeHostWrapper"
+ } else if (rnVersion >= versionToNumber(0, 69, 0)) {
+ srcDirs += "src/reactNativeHostWrapper69"
} else if (rnVersion >= versionToNumber(0, 67, 0)) {
- srcDirs += "src/reactNativeHostWrapper68"
+ srcDirs += "src/reactNativeHostWrapper67"
} else {
srcDirs += "src/reactNativeHostWrapper64"
}
diff --git a/node_modules/expo/android/src/main/java/expo/modules/ReactNativeHostWrapperBase.kt b/node_modules/expo/android/src/main/java/expo/modules/ReactNativeHostWrapperBase.kt
index ef8a0fb..b417af8 100644
--- a/node_modules/expo/android/src/main/java/expo/modules/ReactNativeHostWrapperBase.kt
+++ b/node_modules/expo/android/src/main/java/expo/modules/ReactNativeHostWrapperBase.kt
@@ -46,11 +46,6 @@ open class ReactNativeHostWrapperBase(
.firstOrNull() ?: invokeDelegateMethod("getJavaScriptExecutorFactory")
}
- @Suppress("DEPRECATION")
- override fun getUIImplementationProvider(): com.facebook.react.uimanager.UIImplementationProvider {
- return invokeDelegateMethod("getUIImplementationProvider")
- }
-
override fun getJSIModulePackage(): JSIModulePackage? {
val userJSIModulePackage = invokeDelegateMethod<JSIModulePackage?>("getJSIModulePackage")
return JSIModuleContainerPackage(userJSIModulePackage)
diff --git a/node_modules/expo/android/src/reactNativeHostWrapper64/expo/modules/ReactNativeHostWrapper.kt b/node_modules/expo/android/src/reactNativeHostWrapper64/expo/modules/ReactNativeHostWrapper.kt
index 670f395..55605df 100644
--- a/node_modules/expo/android/src/reactNativeHostWrapper64/expo/modules/ReactNativeHostWrapper.kt
+++ b/node_modules/expo/android/src/reactNativeHostWrapper64/expo/modules/ReactNativeHostWrapper.kt
@@ -11,4 +11,9 @@ class ReactNativeHostWrapper(
override fun getRedBoxHandler(): RedBoxHandler? {
return invokeDelegateMethod("getRedBoxHandler")
}
+
+ @Suppress("DEPRECATION")
+ override fun getUIImplementationProvider(): com.facebook.react.uimanager.UIImplementationProvider {
+ return invokeDelegateMethod("getUIImplementationProvider")
+ }
}
diff --git a/node_modules/expo/android/src/reactNativeHostWrapper68/expo/modules/ReactNativeHostWrapper.kt b/node_modules/expo/android/src/reactNativeHostWrapper67/expo/modules/ReactNativeHostWrapper.kt
similarity index 86%
rename from node_modules/expo/android/src/reactNativeHostWrapper68/expo/modules/ReactNativeHostWrapper.kt
rename to node_modules/expo/android/src/reactNativeHostWrapper67/expo/modules/ReactNativeHostWrapper.kt
index 1dfbe21..7bbb585 100644
--- a/node_modules/expo/android/src/reactNativeHostWrapper68/expo/modules/ReactNativeHostWrapper.kt
+++ b/node_modules/expo/android/src/reactNativeHostWrapper67/expo/modules/ReactNativeHostWrapper.kt
@@ -34,4 +34,9 @@ class ReactNativeHostWrapper(
override fun getRedBoxHandler(): RedBoxHandler? {
return invokeDelegateMethod("getRedBoxHandler")
}
+
+ @Suppress("DEPRECATION")
+ override fun getUIImplementationProvider(): com.facebook.react.uimanager.UIImplementationProvider {
+ return invokeDelegateMethod("getUIImplementationProvider")
+ }
}
diff --git a/node_modules/expo/android/src/reactNativeHostWrapper69/expo/modules/ReactNativeHostWrapper.kt b/node_modules/expo/android/src/reactNativeHostWrapper69/expo/modules/ReactNativeHostWrapper.kt
new file mode 100644
index 0000000..9c5a1cf
--- /dev/null
+++ b/node_modules/expo/android/src/reactNativeHostWrapper69/expo/modules/ReactNativeHostWrapper.kt
@@ -0,0 +1,42 @@
+package expo.modules
+
+import android.app.Application
+import com.facebook.react.ReactNativeHost
+import com.facebook.react.ReactPackageTurboModuleManagerDelegate
+import com.facebook.react.common.SurfaceDelegateFactory
+import com.facebook.react.devsupport.DevSupportManagerFactory
+import com.facebook.react.devsupport.interfaces.RedBoxHandler
+
+class ReactNativeHostWrapper(
+ application: Application,
+ host: ReactNativeHost
+) : ReactNativeHostWrapperBase(application, host) {
+ override fun getDevSupportManagerFactory(): DevSupportManagerFactory? {
+ return reactNativeHostHandlers
+ .asSequence()
+ .mapNotNull { it.devSupportManagerFactory }
+ .firstOrNull() as DevSupportManagerFactory?
+ ?: invokeDelegateMethod("getDevSupportManagerFactory")
+ }
+
+ override fun getReactPackageTurboModuleManagerDelegateBuilder(): ReactPackageTurboModuleManagerDelegate.Builder? {
+ return invokeDelegateMethod("getReactPackageTurboModuleManagerDelegateBuilder")
+ }
+
+ override fun getShouldRequireActivity(): Boolean {
+ return host.shouldRequireActivity
+ }
+
+ override fun getSurfaceDelegateFactory(): SurfaceDelegateFactory {
+ return host.surfaceDelegateFactory
+ }
+
+ override fun getRedBoxHandler(): RedBoxHandler? {
+ return invokeDelegateMethod("getRedBoxHandler")
+ }
+
+ @Suppress("DEPRECATION")
+ override fun getUIImplementationProvider(): com.facebook.react.uimanager.UIImplementationProvider {
+ return invokeDelegateMethod("getUIImplementationProvider")
+ }
+}
diff --git a/node_modules/expo-modules-autolinking/scripts/ios/cocoapods/sandbox.rb b/node_modules/expo-modules-autolinking/scripts/ios/cocoapods/sandbox.rb
index 968159b..15849fb 100644
--- a/node_modules/expo-modules-autolinking/scripts/ios/cocoapods/sandbox.rb
+++ b/node_modules/expo-modules-autolinking/scripts/ios/cocoapods/sandbox.rb
@@ -34,8 +34,8 @@ module Pod
patched_spec = Specification.from_json(spec_json.to_json)
- # Patch `ReactCommon.podspec` to define module
- elsif name == 'ReactCommon'
+ # Patch podspecs to define module
+ elsif ['ReactCommon', 'React-RCTAppDelegate'].include? name
spec_json = JSON.parse(podspec.to_pretty_json)
spec_json['pod_target_xcconfig']['DEFINES_MODULE'] = 'YES'
patched_spec = Specification.from_json(spec_json.to_json)
diff --git a/node_modules/expo-modules-core/ExpoModulesCore.podspec b/node_modules/expo-modules-core/ExpoModulesCore.podspec
index 626b33f..df44aee 100644
--- a/node_modules/expo-modules-core/ExpoModulesCore.podspec
+++ b/node_modules/expo-modules-core/ExpoModulesCore.podspec
@@ -1,8 +1,21 @@
require 'json'
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
+
+reactNativeVersion = '0.0.0'
+begin
+ reactNativeVersion = `node --print "require('react-native/package.json').version"`
+rescue
+ reactNativeVersion = '0.0.0'
+end
+if ENV["REACT_NATIVE_OVERRIDE_VERSION"]
+ reactNativeVersion = ENV["REACT_NATIVE_OVERRIDE_VERSION"]
+end
+
+REACT_NATIVE_MINOR_VERSION = reactNativeVersion.split('.')[1].to_i
+
fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
-fabric_compiler_flags = '-DRN_FABRIC_ENABLED'
+fabric_compiler_flags = '-DRN_FABRIC_ENABLED -DRCT_NEW_ARCH_ENABLED'
folly_version = '2021.07.22.00'
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
@@ -20,24 +33,44 @@ Pod::Spec.new do |s|
s.static_framework = true
s.header_dir = 'ExpoModulesCore'
+ header_search_paths = [
+ # EXJavaScriptRuntime -> Hermes
+ '"$(PODS_ROOT)/boost"',
+ '"$(PODS_ROOT)/DoubleConversion"',
+ '"$(PODS_ROOT)/RCT-Folly"',
+ '"${PODS_ROOT}/Headers/Public/React-hermes"',
+ '"${PODS_ROOT}/Headers/Public/hermes-engine"',
+
+ # EXAppDelegateWrapper -> RCTAppDelegate -> RCTCxxBridgeDelegate
+ '"${PODS_ROOT}/Headers/Private/React-Core"',
+
+ # similar to https://github.com/facebook/react-native/commit/c4b51e8d7, review this when we drop SDK 47
+ '"$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging"',
+ '"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers"',
+ ]
+
# Swift/Objective-C compatibility
s.pod_target_xcconfig = {
'USE_HEADERMAP' => 'YES',
'DEFINES_MODULE' => 'YES',
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17',
'SWIFT_COMPILATION_MODE' => 'wholemodule',
- 'HEADER_SEARCH_PATHS' => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers\"",
+ 'HEADER_SEARCH_PATHS' => header_search_paths.join(' '),
+ "FRAMEWORK_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes\"",
'OTHER_SWIFT_FLAGS' => "$(inherited) #{fabric_enabled ? fabric_compiler_flags : ''}"
}
s.user_target_xcconfig = {
"HEADER_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/ExpoModulesCore/Swift Compatibility Header\" \"$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers\"",
}
+ compiler_flags = folly_compiler_flags + ' ' + "-DREACT_NATIVE_MINOR_VERSION=#{REACT_NATIVE_MINOR_VERSION}"
+
s.dependency 'React-Core'
s.dependency 'ReactCommon/turbomodule/core'
+ s.dependency 'React-RCTAppDelegate' if REACT_NATIVE_MINOR_VERSION >= 71
if fabric_enabled
- s.compiler_flags = folly_compiler_flags + ' ' + fabric_compiler_flags
+ compiler_flags << ' ' << fabric_compiler_flags
s.dependency 'React-RCTFabric'
s.dependency 'RCT-Folly', folly_version
@@ -55,8 +88,9 @@ Pod::Spec.new do |s|
exclude_files.append('ios/Fabric/')
exclude_files.append('common/cpp/fabric/')
end
- s.exclude_files = exclude_files
+ s.exclude_files = exclude_files
+ s.compiler_flags = compiler_flags
s.private_header_files = ['ios/**/*+Private.h', 'ios/**/Swift.h']
s.test_spec 'Tests' do |test_spec|
diff --git a/node_modules/expo-modules-core/android/CMakeLists.txt b/node_modules/expo-modules-core/android/CMakeLists.txt
index f235a94..be075cf 100644
--- a/node_modules/expo-modules-core/android/CMakeLists.txt
+++ b/node_modules/expo-modules-core/android/CMakeLists.txt
@@ -6,7 +6,7 @@ set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 17)
set(PACKAGE_NAME "expo-modules-core")
set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
-set(ignoreMe "${PROJECT_BUILD_DIR} ${REACT_ANDROID_BUILD_DIR} ${REACT_ANDROID_DIR} ${HERMES_HEADER_DIR}")
+set(ignoreMe "${PROJECT_BUILD_DIR} ${REACT_ANDROID_BUILD_DIR} ${REACT_NATIVE_TARGET_VERSION} ${REACT_ANDROID_DIR} ${HERMES_HEADER_DIR}")
if (${NATIVE_DEBUG})
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
@@ -72,8 +72,6 @@ if (NOT LIBRN_DIR)
file(GLOB LIBRN_DIR "${REACT_NATIVE_SO_DIR}")
endif ()
-file(GLOB libfbjni_include_DIRS "${BUILD_DIR}/fbjni-*-headers.jar/")
-
# tests
if(${UNIT_TEST})
@@ -100,81 +98,33 @@ else()
set(JSEXECUTOR_INCLUDE "")
endif()
+# find libraries
+
+find_library(LOG_LIB log)
+
+find_package(ReactAndroid REQUIRED CONFIG)
+
+find_package(fbjni REQUIRED CONFIG)
# includes
+get_target_property(INCLUDE_reactnativejni
+ ReactAndroid::reactnativejni
+ INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(
${PACKAGE_NAME}
PRIVATE
- "${REACT_NATIVE_DIR}/React"
- "${REACT_NATIVE_DIR}/React/Base"
- "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni"
- "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react"
+ ${INCLUDE_reactnativejni}/react
+
+ # header only imports from turbomodule, e.g. CallInvokerHolder.h
"${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react/turbomodule"
- "${REACT_NATIVE_DIR}/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni"
- "${REACT_NATIVE_DIR}/ReactCommon"
- "${REACT_NATIVE_DIR}/ReactCommon/react/nativemodule/core"
- "${REACT_NATIVE_DIR}/ReactCommon/callinvoker"
- "${REACT_NATIVE_DIR}/ReactCommon/jsi"
+
"${BUILD_DIR}/third-party-ndk/boost/boost_${BOOST_VERSION}"
- "${BUILD_DIR}/third-party-ndk/double-conversion"
- "${BUILD_DIR}/third-party-ndk/folly"
- "${libfbjni_include_DIRS}"
"${COMMON_DIR}"
"${JSEXECUTOR_INCLUDE}"
"${SRC_DIR}/fabric"
)
-# find libraries
-
-find_library(LOG_LIB log)
-
-if(${REACT_NATIVE_TARGET_VERSION} LESS 69)
- find_library(
- FOLLY_LIB
- folly_json
- PATHS ${LIBRN_DIR}
- NO_CMAKE_FIND_ROOT_PATH
- )
-else()
- find_library(
- FOLLY_LIB
- folly_runtime
- PATHS ${LIBRN_DIR}
- NO_CMAKE_FIND_ROOT_PATH
- )
-endif()
-
-find_library(
- FBJNI_LIB
- fbjni
- PATHS ${LIBRN_DIR}
- NO_CMAKE_FIND_ROOT_PATH
-)
-
-find_library(
- JSI_LIB
- jsi
- PATHS ${LIBRN_DIR}
- NO_CMAKE_FIND_ROOT_PATH
-)
-
-find_library(
- REACT_NATIVE_JNI_LIB
- reactnativejni
- PATHS ${LIBRN_DIR}
- NO_CMAKE_FIND_ROOT_PATH
-)
-
-find_library(
- REACT_NATIVE_MODULES_CORE
- react_nativemodule_core
- PATHS ${LIBRN_DIR}
- NO_CMAKE_FIND_ROOT_PATH
-)
-
-#reactnativejni
-
# linking
target_compile_options(
@@ -190,12 +140,12 @@ target_link_libraries(
${PACKAGE_NAME}
CommonSettings
${LOG_LIB}
- ${FBJNI_LIB}
- ${JSI_LIB}
- ${JSEXECUTOR_LIB}
- ${REACT_NATIVE_JNI_LIB}
- ${FOLLY_LIB}
- ${REACT_NATIVE_MODULES_CORE}
+ fbjni::fbjni
+ ReactAndroid::jsi
+ ReactAndroid::reactnativejni
+ ReactAndroid::folly_runtime
+ ReactAndroid::react_nativemodule_core
android
+ ${JSEXECUTOR_LIB}
${NEW_ARCHITECTURE_DEPENDENCIES}
)
diff --git a/node_modules/expo-modules-core/android/ExpoModulesCorePlugin.gradle b/node_modules/expo-modules-core/android/ExpoModulesCorePlugin.gradle
index cc6d298..237e8e9 100644
--- a/node_modules/expo-modules-core/android/ExpoModulesCorePlugin.gradle
+++ b/node_modules/expo-modules-core/android/ExpoModulesCorePlugin.gradle
@@ -13,3 +13,203 @@ class KotlinExpoModulesCorePlugin implements Plugin<Project> {
ext.applyKotlinExpoModulesCorePlugin = {
apply plugin: KotlinExpoModulesCorePlugin
}
+
+// [BEGIN] Remove when we drop SDK 47
+abstract class ExtractReactNativeAARTask extends DefaultTask {
+ @Input
+ abstract Property<String> getBuildType()
+
+ @Input
+ abstract Property<String> getReactNativeDir()
+
+ @TaskAction
+ def taskAction() {
+ def suffix = buildType.get() == 'Debug' ? '-debug' : '-release'
+ def rnAARs = project.fileTree("${reactNativeDir.get()}/android").matching { include "**/react-native/**/*${suffix}.aar" }
+ if (rnAARs.isEmpty()) {
+ rnAARs = project.fileTree("${reactNativeDir.get()}/android").matching { include "**/react-native/**/*.aar" }
+ }
+ if (rnAARs.any()) {
+ // node_modules/react-native has a .aar, extract headers
+ if (rnAARs.size() > 1) {
+ logger.error("More than one React Native AAR file has been found:")
+ rnAARs.each {println(it) }
+ throw new GradleException("Multiple React Native AARs found:\n${rnAARs.join("\n")}" +
+ "\nRemove the old ones and try again")
+ }
+ }
+ def rnAAR = rnAARs.singleFile
+ def file = rnAAR.absoluteFile
+ def packageName = file.name.tokenize('-')[0]
+ project.copy {
+ from project.zipTree(file)
+ into "${project.buildDir}/${packageName}"
+ include "jni/**/*"
+ }
+ }
+}
+
+class LegacyReactNativeLibsExtractionPlugin implements Plugin<Project> {
+ void nativeBuildDependsOn(project, dependsOnTask, buildTypesIncludes) {
+ def buildTasks = project.tasks.findAll { task ->
+ def taskName = task.name
+ if (taskName.contains("Clean")) { return false }
+ if (taskName.contains("externalNative") || taskName.contains("CMake") || taskName.contains("generateJsonModel")) {
+ if (buildTypesIncludes == null) { return true }
+ for (buildType in buildTypesIncludes) {
+ if (taskName.contains(buildType)) { return true }
+ }
+ }
+ return false
+ }
+ buildTasks.forEach { task -> task.dependsOn(dependsOnTask) }
+ }
+
+ void apply(Project project) {
+ def REACT_NATIVE_BUILD_FROM_SOURCE = project.findProject(":ReactAndroid") != null
+ def REACT_NATIVE_DIR = REACT_NATIVE_BUILD_FROM_SOURCE
+ ? project.findProject(":ReactAndroid").getProjectDir().parent
+ : new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, project.rootDir).text.trim()).parent
+
+ def reactProperties = new Properties()
+ new File("$REACT_NATIVE_DIR/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
+ def FOLLY_VERSION = reactProperties.getProperty("FOLLY_VERSION")
+ def BOOST_VERSION = reactProperties.getProperty("BOOST_VERSION")
+ def DOUBLE_CONVERSION_VERSION = reactProperties.getProperty("DOUBLE_CONVERSION_VERSION")
+ def REACT_NATIVE_VERSION = System.getenv("REACT_NATIVE_OVERRIDE_VERSION") ?: reactProperties.getProperty("VERSION_NAME")
+ def REACT_NATIVE_TARGET_VERSION = REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
+
+ def isNewArchitectureEnabled = project.findProperty("newArchEnabled") == "true"
+ def customDownloadsDir = System.getenv("REACT_NATIVE_DOWNLOADS_DIR")
+ def downloadsDir = customDownloadsDir ? new File(customDownloadsDir) : new File("$buildDir/downloads")
+ def thirdPartyNdkDir = new File("${project.buildDir}/third-party-ndk")
+ def reactNativeThirdParty = new File("$REACT_NATIVE_DIR/ReactAndroid/src/main/jni/third-party")
+
+ def createNativeDepsDirectories = project.tasks.findByName('createNativeDepsDirectories') ?: project.tasks.register('createNativeDepsDirectories') {
+ downloadsDir.mkdirs()
+ thirdPartyNdkDir.mkdirs()
+ }
+
+ def extractReactNativeAARRelease = project.tasks.register('extractReactNativeAARRelease', ExtractReactNativeAARTask) {
+ reactNativeDir = REACT_NATIVE_DIR
+ buildType = 'Release'
+ }
+ def extractReactNativeAARDebug = project.tasks.register('extractReactNativeAARDebug', ExtractReactNativeAARTask) {
+ reactNativeDir = REACT_NATIVE_DIR
+ buildType = 'Debug'
+ }
+
+ def packageReactNdkDebugLibs = project.tasks.register("packageReactNdkDebugLibs", Copy) {
+ dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
+ from("$REACT_NATIVE_DIR/ReactAndroid/src/main/jni/prebuilt/lib")
+ into("${project.buildDir}/react-ndk/exported")
+ }
+ def packageReactNdkReleaseLibs = project.tasks.register("packageReactNdkReleaseLibs", Copy) {
+ dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
+ from("$REACT_NATIVE_DIR/ReactAndroid/src/main/jni/prebuilt/lib")
+ into("${project.buildDir}/react-ndk/exported")
+ }
+
+ // [BEGIN] Extra libs
+ def downloadDoubleConversion = project.tasks.create('downloadDoubleConversion', project.Download) {
+ dependsOn(createNativeDepsDirectories)
+ src("https://github.com/google/double-conversion/archive/v${DOUBLE_CONVERSION_VERSION}.tar.gz")
+ onlyIfNewer(true)
+ overwrite(false)
+ dest(new File(downloadsDir, "double-conversion-${DOUBLE_CONVERSION_VERSION}.tar.gz"))
+ }
+
+ def prepareDoubleConversion = project.tasks.register('prepareDoubleConversion', Copy) {
+ dependsOn(downloadDoubleConversion)
+ from(project.tarTree(downloadDoubleConversion.dest))
+ from("$reactNativeThirdParty/double-conversion/Android.mk")
+ include("double-conversion-${DOUBLE_CONVERSION_VERSION}/src/**/*", "Android.mk")
+ filesMatching("*/src/**/*", { fname -> fname.path = "double-conversion/${fname.name}" })
+ includeEmptyDirs = false
+ into("$thirdPartyNdkDir/double-conversion")
+ }
+
+ def downloadFolly = project.tasks.create('downloadFolly', project.Download) {
+ dependsOn(createNativeDepsDirectories)
+ src("https://github.com/facebook/folly/archive/v${FOLLY_VERSION}.tar.gz")
+ onlyIfNewer(true)
+ overwrite(false)
+ dest(new File(downloadsDir, "folly-${FOLLY_VERSION}.tar.gz"))
+ }
+
+ def prepareFolly = project.tasks.register('prepareFolly', Copy) {
+ dependsOn(downloadFolly)
+ from(project.tarTree(downloadFolly.dest))
+ from("$reactNativeThirdParty/folly/Android.mk")
+ include("folly-${FOLLY_VERSION}/folly/**/*", "Android.mk")
+ eachFile { fname -> fname.path = (fname.path - "folly-${FOLLY_VERSION}/") }
+ // Fixes problem with Folly failing to build on certain systems. See
+ // https://github.com/software-mansion/react-native-reanimated/issues/1024
+ def follyReplaceContent = '''
+ ssize_t r;
+ do {
+ r = open(name, flags, mode);
+ } while (r == -1 && errno == EINTR);
+ return r;
+ '''
+ filter { line -> line.replaceAll("return int\\(wrapNoInt\\(open, name, flags, mode\\)\\);", follyReplaceContent) }
+ includeEmptyDirs = false
+ into("$thirdPartyNdkDir/folly")
+ }
+ // [END] Extra libs
+
+ project.afterEvaluate {
+ if (REACT_NATIVE_BUILD_FROM_SOURCE) {
+ nativeBuildDependsOn(project, ":ReactAndroid:copyReleaseJniLibsProjectOnly", ["Release", "RelWithDebInfo"])
+ nativeBuildDependsOn(project, ":ReactAndroid:copyDebugJniLibsProjectOnly", ["Debug"])
+ } else {
+ nativeBuildDependsOn(project, extractReactNativeAARRelease, ["Release", "RelWithDebInfo"])
+ nativeBuildDependsOn(project, extractReactNativeAARDebug, ["Debug"])
+ }
+
+ def extraLibs = project.extensions.extraProperties.has('extraLegacyReactNativeLibs')
+ ? project.extensions.extraProperties.get('extraLegacyReactNativeLibs')
+ : []
+ extraLibs.each {
+ nativeBuildDependsOn(project, project.tasks.named(it), null)
+ }
+
+ if (isNewArchitectureEnabled) {
+ def preDebugBuild = project.tasks.named('preDebugBuild')
+ def preReleaseBuild = project.tasks.named('preReleaseBuild')
+ preDebugBuild.configure {
+ dependsOn(packageReactNdkDebugLibs)
+ }
+ preReleaseBuild.configure {
+ dependsOn(packageReactNdkReleaseLibs)
+ }
+
+ // Due to a bug inside AGP, we have to explicitly set a dependency
+ // between configureCMake* tasks and the preBuild tasks.
+ // This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
+ project.tasks.named('configureCMakeDebug').configure {
+ dependsOn(preDebugBuild)
+ }
+ project.tasks.named('configureCMakeRelWithDebInfo').configure {
+ dependsOn(preReleaseBuild)
+ }
+ def reactNativeArchitectures = project.getProperties().get("reactNativeArchitectures")?.split(",") ?: ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
+
+ reactNativeArchitectures.each { architecture ->
+ project.tasks.named("configureCMakeDebug[${architecture}]")?.configure {
+ dependsOn("preDebugBuild")
+ }
+ project.tasks.named("configureCMakeRelWithDebInfo[${architecture}]")?.configure {
+ dependsOn("preReleaseBuild")
+ }
+ }
+ }
+ }
+ }
+}
+
+ext.applyLegacyReactNativeLibsExtractionPlugin = {
+ apply plugin: LegacyReactNativeLibsExtractionPlugin
+}
+
+// [END] Remove when we drop SDK 47
diff --git a/node_modules/expo-modules-core/android/build.gradle b/node_modules/expo-modules-core/android/build.gradle
index ed28486..84d9390 100644
--- a/node_modules/expo-modules-core/android/build.gradle
+++ b/node_modules/expo-modules-core/android/build.gradle
@@ -59,14 +59,12 @@ def REACT_NATIVE_DIR = REACT_NATIVE_BUILD_FROM_SOURCE
: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).parent
def REACT_NATIVE_SO_DIR = REACT_NATIVE_BUILD_FROM_SOURCE
? Paths.get(findProject(":ReactAndroid").getProjectDir().toString(), "build", "intermediates", "library_*", "*", "jni")
- : "${buildDir}/react-native-0*/jni"
+ : "${buildDir}/react/jni"
def reactProperties = new Properties()
file("$REACT_NATIVE_DIR/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
-def FOLLY_VERSION = reactProperties.getProperty("FOLLY_VERSION")
def BOOST_VERSION = reactProperties.getProperty("BOOST_VERSION")
-def DOUBLE_CONVERSION_VERSION = reactProperties.getProperty("DOUBLE_CONVERSION_VERSION")
def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
if (REACT_NATIVE_VERSION.startsWith("0.0.0-")) {
// react-native nightly build published as `0.0.0-20221002-2027-2319f75c8` form, but its semantic is latest
@@ -130,7 +128,6 @@ if (USE_HERMES) {
}
// END HERMES
-
def isNewArchitectureEnabled = findProperty("newArchEnabled") == "true"
// Creating sources with comments
@@ -217,7 +214,11 @@ android {
externalNativeBuild {
cmake {
- path "CMakeLists.txt"
+ if (REACT_NATIVE_TARGET_VERSION >= 71) {
+ path "CMakeLists.txt"
+ } else {
+ path "legacy/CMakeLists.txt"
+ }
}
}
@@ -260,11 +261,6 @@ android {
}
}
- configurations {
- extractHeaders
- extractJNI
- }
-
lintOptions {
abortOnError false
}
@@ -309,8 +305,6 @@ dependencies {
implementation 'com.facebook.react:react-native:+'
compileOnly 'com.facebook.fbjni:fbjni:0.2.2'
- extractHeaders 'com.facebook.fbjni:fbjni:0.2.2:headers'
- extractJNI 'com.facebook.fbjni:fbjni:0.2.2'
testImplementation 'androidx.test:core:1.4.0'
testImplementation 'junit:junit:4.13.1'
@@ -344,148 +338,12 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
}
-// UTILS
-task createNativeDepsDirectories() {
+def createNativeDepsDirectories = project.tasks.findByName('createNativeDepsDirectories') ?: project.tasks.register('createNativeDepsDirectories') {
downloadsDir.mkdirs()
thirdPartyNdkDir.mkdirs()
}
-// END UTILS
-
-// JNI
-def extractReactNativeAAR = { buildType ->
- def suffix = buildType == 'Debug' ? '-debug' : '-release'
- def rnAARs = fileTree(REACT_NATIVE_DIR).matching { include "**/react-native/**/*${suffix}.aar" }
- if (rnAARs.isEmpty()) {
- rnAARs = fileTree(REACT_NATIVE_DIR).matching { include "**/react-native/**/*.aar" }
- }
- if (rnAARs.any()) {
- // node_modules/react-native has a .aar, extract headers
- if (rnAARs.size() > 1) {
- logger.error("More than one React Native AAR file has been found:")
- rnAARs.each {println(it) }
- throw new GradleException("Multiple React Native AARs found:\n${rnAARs.join("\n")}" +
- "\nRemove the old ones and try again")
- }
- }
- def rnAAR = rnAARs.singleFile
- def file = rnAAR.absoluteFile
- def packageName = file.name.tokenize('-')[0]
- copy {
- from zipTree(file)
- into "$buildDir/$file.name"
- include "jni/**/*"
- }
-}
-
-task extractReactNativeAARRelease {
- doLast {
- extractReactNativeAAR('Release')
- }
-}
-
-task extractReactNativeAARDebug {
- doLast {
- extractReactNativeAAR('Debug')
- }
-}
-
-
-task extractAARHeaders {
- doLast {
- configurations.extractHeaders.files.each {
- def file = it.absoluteFile
- copy {
- from zipTree(file)
- into "$buildDir/$file.name"
- include "**/*.h"
- }
- }
- }
-}
-
-task extractJNIFiles {
- doLast {
- configurations.extractJNI.files.each {
- def file = it.absoluteFile
- copy {
- from zipTree(file)
- into "$buildDir/$file.name"
- include "jni/**/*"
- }
- }
- }
-}
-// END JNI
-
-// BOOST
-task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) {
- def srcUrl = REACT_NATIVE_TARGET_VERSION >= 69
- ? "https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION.replace("_", ".")}/source/boost_${BOOST_VERSION}.tar.gz"
- : "https://github.com/react-native-community/boost-for-react-native/releases/download/v${BOOST_VERSION.replace("_", ".")}-0/boost_${BOOST_VERSION}.tar.gz"
- src(srcUrl)
- onlyIfNewer(true)
- overwrite(false)
- dest(new File(downloadsDir, "boost_${BOOST_VERSION}.tar.gz"))
-}
-
-task prepareBoost(dependsOn: [downloadBoost], type: Copy) {
- from(tarTree(resources.gzip(downloadBoost.dest)))
- from("$reactNativeThirdParty/boost/Android.mk")
- include("Android.mk", "boost_${BOOST_VERSION}/boost/**/*.hpp", "boost/boost/**/*.hpp")
- includeEmptyDirs = false
- into("$thirdPartyNdkDir/boost")
- doLast {
- file("$thirdPartyNdkDir/boost/boost").renameTo("$thirdPartyNdkDir/boost/boost_${BOOST_VERSION}")
- }
-}
-// END BOOST
-
-// DOUBLE CONVERSION
-task downloadDoubleConversion(dependsOn: createNativeDepsDirectories, type: Download) {
- src("https://github.com/google/double-conversion/archive/v${DOUBLE_CONVERSION_VERSION}.tar.gz")
- onlyIfNewer(true)
- overwrite(false)
- dest(new File(downloadsDir, "double-conversion-${DOUBLE_CONVERSION_VERSION}.tar.gz"))
-}
-
-task prepareDoubleConversion(dependsOn: [downloadDoubleConversion], type: Copy) {
- from(tarTree(downloadDoubleConversion.dest))
- from("$reactNativeThirdParty/double-conversion/Android.mk")
- include("double-conversion-${DOUBLE_CONVERSION_VERSION}/src/**/*", "Android.mk")
- filesMatching("*/src/**/*", { fname -> fname.path = "double-conversion/${fname.name}" })
- includeEmptyDirs = false
- into("$thirdPartyNdkDir/double-conversion")
-}
-// END DOUBLE CONVERSION
-
-// FOLLY
-task downloadFolly(dependsOn: createNativeDepsDirectories, type: Download) {
- src("https://github.com/facebook/folly/archive/v${FOLLY_VERSION}.tar.gz")
- onlyIfNewer(true)
- overwrite(false)
- dest(new File(downloadsDir, "folly-${FOLLY_VERSION}.tar.gz"))
-}
-
-task prepareFolly(dependsOn: [downloadFolly], type: Copy) {
- from(tarTree(downloadFolly.dest))
- from("$reactNativeThirdParty/folly/Android.mk")
- include("folly-${FOLLY_VERSION}/folly/**/*", "Android.mk")
- eachFile { fname -> fname.path = (fname.path - "folly-${FOLLY_VERSION}/") }
- // Fixes problem with Folly failing to build on certain systems. See
- // https://github.com/software-mansion/react-native-reanimated/issues/1024
- def follyReplaceContent = '''
- ssize_t r;
- do {
- r = open(name, flags, mode);
- } while (r == -1 && errno == EINTR);
- return r;
- '''
- filter { line -> line.replaceAll("return int\\(wrapNoInt\\(open, name, flags, mode\\)\\);", follyReplaceContent) }
- includeEmptyDirs = false
- into("$thirdPartyNdkDir/folly")
-}
-// END FOLLY
+// TODO: Remove all these hermes code when we update our repo to react-native 0.71 by using prefab
task downloadHermes(type: Download) {
def hermesVersion = currentHermesVersion ?: "main"
src("https://github.com/facebook/hermes/tarball/${hermesVersion}")
@@ -507,10 +365,11 @@ task unzipHermes(dependsOn: downloadHermes, type: Copy) {
into(hermesDir)
}
-task prepareHermes(dependsOn: createNativeDepsDirectories) {
+task prepareHermes() {
if (!USE_HERMES) {
return
}
+ dependsOn(createNativeDepsDirectories)
if (NEED_DOWNLOAD_HERMES) {
dependsOn(unzipHermes)
}
@@ -526,61 +385,43 @@ task prepareHermes(dependsOn: createNativeDepsDirectories) {
}
}
-task prepareThirdPartyNdkHeaders(dependsOn: [prepareBoost, prepareDoubleConversion, prepareFolly]) {}
-
-def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
- dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
- from("$REACT_NATIVE_DIR/ReactAndroid/src/main/jni/prebuilt/lib")
- into("$buildDir/react-ndk/exported")
+def downloadBoost = tasks.create('downloadBoost', Download) {
+ dependsOn(createNativeDepsDirectories)
+ def srcUrl = REACT_NATIVE_TARGET_VERSION >= 69
+ ? "https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION.replace("_", ".")}/source/boost_${BOOST_VERSION}.tar.gz"
+ : "https://github.com/react-native-community/boost-for-react-native/releases/download/v${BOOST_VERSION.replace("_", ".")}-0/boost_${BOOST_VERSION}.tar.gz"
+ src(srcUrl)
+ onlyIfNewer(true)
+ overwrite(false)
+ dest(new File(downloadsDir, "boost_${BOOST_VERSION}.tar.gz"))
}
-def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
- dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
- from("$REACT_NATIVE_DIR/ReactAndroid/src/main/jni/prebuilt/lib")
- into("$buildDir/react-ndk/exported")
+
+def prepareBoost = tasks.register('prepareBoost', Copy) {
+ dependsOn(downloadBoost)
+ from(tarTree(resources.gzip(downloadBoost.dest)))
+ from("$reactNativeThirdParty/boost/Android.mk")
+ include("Android.mk", "boost_${BOOST_VERSION}/boost/**/*.hpp", "boost/boost/**/*.hpp")
+ includeEmptyDirs = false
+ into("$thirdPartyNdkDir/boost")
+ doLast {
+ new File("$thirdPartyNdkDir/boost/boost").renameTo("$thirdPartyNdkDir/boost/boost_${BOOST_VERSION}")
+ }
}
afterEvaluate {
- extractAARHeaders.dependsOn(prepareThirdPartyNdkHeaders)
- extractJNIFiles.dependsOn(prepareThirdPartyNdkHeaders)
+ preBuild.dependsOn(prepareBoost)
if (USE_HERMES) {
- prepareThirdPartyNdkHeaders.dependsOn(prepareHermes)
+ preBuild.dependsOn(prepareHermes)
if (hasHermesProject && !prebuiltHermesCacheHit) {
prepareHermes.dependsOn(":ReactAndroid:hermes-engine:assembleDebug")
}
}
-
- if (isNewArchitectureEnabled) {
- preDebugBuild.dependsOn(packageReactNdkDebugLibs)
- preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
-
- // Due to a bug inside AGP, we have to explicitly set a dependency
- // between configureCMake* tasks and the preBuild tasks.
- // This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
- configureCMakeDebug.dependsOn(preDebugBuild)
- configureCMakeRelWithDebInfo.dependsOn(preReleaseBuild)
- reactNativeArchitectures().each { architecture ->
- tasks.findByName("configureCMakeDebug[${architecture}]")?.configure {
- dependsOn("preDebugBuild")
- }
- tasks.findByName("configureCMakeRelWithDebInfo[${architecture}]")?.configure {
- dependsOn("preReleaseBuild")
- }
- }
- }
}
-tasks.whenTaskAdded { task ->
- if (!task.name.contains("Clean") && (task.name.contains('externalNativeBuild') || task.name.startsWith('configureCMake') || task.name.startsWith('buildCMake'))) {
- def buildType = task.name.endsWith('Debug') ? 'Debug' : 'Release'
- task.dependsOn(extractAARHeaders)
- task.dependsOn(extractJNIFiles)
- if (REACT_NATIVE_BUILD_FROM_SOURCE) {
- task.dependsOn(":ReactAndroid:copy${buildType}JniLibsProjectOnly")
- } else {
- task.dependsOn("extractReactNativeAAR${buildType}")
- }
- } else if (task.name.startsWith('generateJsonModel') && REACT_NATIVE_BUILD_FROM_SOURCE) {
- def buildType = task.name.endsWith('Debug') ? 'Debug' : 'Release'
- task.dependsOn(":ReactAndroid:copy${buildType}JniLibsProjectOnly")
- }
+if (REACT_NATIVE_TARGET_VERSION < 71) {
+ project.ext.extraLegacyReactNativeLibs = [
+ 'prepareDoubleConversion',
+ 'prepareFolly',
+ ]
+ applyLegacyReactNativeLibsExtractionPlugin()
}
diff --git a/node_modules/expo-modules-core/android/legacy/CMakeLists.txt b/node_modules/expo-modules-core/android/legacy/CMakeLists.txt
new file mode 100644
index 0000000..21b53ab
--- /dev/null
+++ b/node_modules/expo-modules-core/android/legacy/CMakeLists.txt
@@ -0,0 +1,194 @@
+# Remove this legacy folder when we drop SDK 47
+cmake_minimum_required(VERSION 3.4.1)
+
+project(expo-modules-core)
+
+set(CMAKE_VERBOSE_MAKEFILE ON)
+set(CMAKE_CXX_STANDARD 17)
+set(PACKAGE_NAME "expo-modules-core")
+set(BUILD_DIR ${CMAKE_SOURCE_DIR}/../build)
+set(ignoreMe "${PROJECT_BUILD_DIR} ${REACT_ANDROID_BUILD_DIR} ${REACT_ANDROID_DIR} ${HERMES_HEADER_DIR}")
+
+if (${NATIVE_DEBUG})
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
+endif ()
+
+set(SRC_DIR ${CMAKE_SOURCE_DIR}/../src)
+set(COMMON_DIR ${CMAKE_SOURCE_DIR}/../../common/cpp)
+file(GLOB sources_android "${SRC_DIR}/main/cpp/*.cpp")
+file(GLOB sources_android_types "${SRC_DIR}/main/cpp/types/*.cpp")
+file(GLOB sources_android_javaclasses "${SRC_DIR}/main/cpp/javaclasses/*.cpp")
+file(GLOB common_sources "${COMMON_DIR}/*.cpp")
+
+# shared
+
+macro(createVarAsBoolToInt name value)
+ if(${value})
+ set(${name} "1")
+ else()
+ set(${name} "0")
+ endif()
+endmacro()
+
+add_library(CommonSettings INTERFACE)
+
+add_library(
+ ${PACKAGE_NAME}
+ SHARED
+ ${common_sources}
+ ${sources_android}
+ ${sources_android_types}
+ ${sources_android_javaclasses}
+)
+
+if(IS_NEW_ARCHITECTURE_ENABLED)
+ add_subdirectory("fabric")
+ set(NEW_ARCHITECTURE_DEPENDENCIES "fabric")
+ set(NEW_ARCHITECTURE_COMPILE_OPTIONS -DIS_NEW_ARCHITECTURE_ENABLED=1 -DRN_FABRIC_ENABLED=1)
+else()
+ set(NEW_ARCHITECTURE_DEPENDENCIES "")
+ set(NEW_ARCHITECTURE_COMPILE_OPTIONS "")
+endif()
+
+createVarAsBoolToInt("USE_HERMES_INT" ${USE_HERMES})
+createVarAsBoolToInt("UNIT_TEST_INT" ${UNIT_TEST})
+
+target_compile_options(CommonSettings INTERFACE
+ -O2
+ -frtti
+ -fexceptions
+ -Wall
+ -fstack-protector-all
+ -DUSE_HERMES=${USE_HERMES_INT}
+ -DUNIT_TEST=${UNIT_TEST_INT}
+ ${NEW_ARCHITECTURE_COMPILE_OPTIONS}
+)
+
+# Extracted AAR: ${BUILD_DIR}/react-native-0*/jni/${ANDROID_ABI}
+file(GLOB LIBRN_DIR "${REACT_NATIVE_SO_DIR}/${ANDROID_ABI}")
+if (NOT LIBRN_DIR)
+ # If /${ANDROID_ABI} dir not found, then ${REACT_NATIVE_SO_DIR} is probably:
+ # ReactAndroid/build/react-ndk/exported
+ file(GLOB LIBRN_DIR "${REACT_NATIVE_SO_DIR}")
+endif ()
+
+# tests
+
+if(${UNIT_TEST})
+ if(${USE_HERMES})
+ file(GLOB HERMES_SO_DIR "${BUILD_DIR}/third-party-ndk/hermes/jni/${ANDROID_ABI}")
+ find_library(
+ JSEXECUTOR_LIB
+ hermes
+ PATHS ${HERMES_SO_DIR}
+ NO_CMAKE_FIND_ROOT_PATH
+ )
+ set(JSEXECUTOR_INCLUDE ${HERMES_HEADER_DIR} ${HERMES_HEADER_DIR}/API ${HERMES_HEADER_DIR}/public)
+ else()
+ find_library(
+ JSEXECUTOR_LIB
+ jscexecutor
+ PATHS ${LIBRN_DIR}
+ NO_CMAKE_FIND_ROOT_PATH
+ )
+ set(JSEXECUTOR_INCLUDE "")
+ endif()
+else()
+ set(JSEXECUTOR_LIB "")
+ set(JSEXECUTOR_INCLUDE "")
+endif()
+
+
+# includes
+
+target_include_directories(
+ ${PACKAGE_NAME}
+ PRIVATE
+ "${REACT_NATIVE_DIR}/React"
+ "${REACT_NATIVE_DIR}/React/Base"
+ "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni"
+ "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react"
+ "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react/turbomodule"
+ "${REACT_NATIVE_DIR}/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni"
+ "${REACT_NATIVE_DIR}/ReactCommon"
+ "${REACT_NATIVE_DIR}/ReactCommon/react/nativemodule/core"
+ "${REACT_NATIVE_DIR}/ReactCommon/callinvoker"
+ "${REACT_NATIVE_DIR}/ReactCommon/jsi"
+ "${BUILD_DIR}/third-party-ndk/boost/boost_${BOOST_VERSION}"
+ "${BUILD_DIR}/third-party-ndk/double-conversion"
+ "${BUILD_DIR}/third-party-ndk/folly"
+ "${COMMON_DIR}"
+ "${JSEXECUTOR_INCLUDE}"
+ "${SRC_DIR}/fabric"
+)
+
+# find libraries
+
+find_library(LOG_LIB log)
+
+if(${REACT_NATIVE_TARGET_VERSION} LESS 69)
+ find_library(
+ FOLLY_LIB
+ folly_json
+ PATHS ${LIBRN_DIR}
+ NO_CMAKE_FIND_ROOT_PATH
+ )
+else()
+ find_library(
+ FOLLY_LIB
+ folly_runtime
+ PATHS ${LIBRN_DIR}
+ NO_CMAKE_FIND_ROOT_PATH
+ )
+endif()
+
+find_package(fbjni REQUIRED CONFIG)
+
+find_library(
+ JSI_LIB
+ jsi
+ PATHS ${LIBRN_DIR}
+ NO_CMAKE_FIND_ROOT_PATH
+)
+
+find_library(
+ REACT_NATIVE_JNI_LIB
+ reactnativejni
+ PATHS ${LIBRN_DIR}
+ NO_CMAKE_FIND_ROOT_PATH
+)
+
+find_library(
+ REACT_NATIVE_MODULES_CORE
+ react_nativemodule_core
+ PATHS ${LIBRN_DIR}
+ NO_CMAKE_FIND_ROOT_PATH
+)
+
+#reactnativejni
+
+# linking
+
+target_compile_options(
+ ${PACKAGE_NAME}
+ PRIVATE -DFOLLY_NO_CONFIG=1
+ -DFOLLY_HAVE_CLOCK_GETTIME=1
+ -DFOLLY_HAVE_MEMRCHR=1
+ -DFOLLY_USE_LIBCPP=1
+ -DFOLLY_MOBILE=1
+)
+
+target_link_libraries(
+ ${PACKAGE_NAME}
+ CommonSettings
+ ${LOG_LIB}
+ fbjni::fbjni
+ ${JSI_LIB}
+ ${JSEXECUTOR_LIB}
+ ${REACT_NATIVE_JNI_LIB}
+ ${FOLLY_LIB}
+ ${REACT_NATIVE_MODULES_CORE}
+ android
+ ${NEW_ARCHITECTURE_DEPENDENCIES}
+)
diff --git a/node_modules/expo-modules-core/android/legacy/fabric/CMakeLists.txt b/node_modules/expo-modules-core/android/legacy/fabric/CMakeLists.txt
new file mode 100644
index 0000000..5a20de1
--- /dev/null
+++ b/node_modules/expo-modules-core/android/legacy/fabric/CMakeLists.txt
@@ -0,0 +1,40 @@
+# Copyright 2018-present 650 Industries. All rights reserved.
+
+include(Android-prebuilt.cmake)
+
+set(FABRIC_SRC_DIR ${CMAKE_SOURCE_DIR}/../src/fabric)
+set(COMMON_FABRIC_DIR ${COMMON_DIR}/fabric)
+file(GLOB SOURCES "${FABRIC_SRC_DIR}/*.cpp")
+file(GLOB COMMON_FABRIC_SOURCES "${COMMON_FABRIC_DIR}/*.cpp")
+
+add_library(fabric STATIC
+ ${COMMON_FABRIC_SOURCES}
+ ${SOURCES}
+)
+
+target_compile_options(fabric PRIVATE
+ "-std=c++17"
+)
+
+target_include_directories(fabric PRIVATE
+ "${REACT_NATIVE_DIR}/ReactCommon"
+ "${COMMON_FABRIC_DIR}"
+)
+
+target_link_libraries(fabric
+ CommonSettings
+ fabricjni
+ fbjni
+ folly_runtime
+ glog
+ jsi
+ react_debug
+ react_render_componentregistry
+ react_render_core
+ react_render_debug
+ react_render_graphics
+ react_render_mapbuffer
+ rrc_view
+ runtimeexecutor
+ yoga
+)
diff --git a/node_modules/expo-modules-core/android/src/fabric/Android-prebuilt.cmake b/node_modules/expo-modules-core/android/src/fabric/Android-prebuilt.cmake
index 03be4be..2528fd6 100644
--- a/node_modules/expo-modules-core/android/src/fabric/Android-prebuilt.cmake
+++ b/node_modules/expo-modules-core/android/src/fabric/Android-prebuilt.cmake
@@ -1,3 +1,5 @@
+# Remove this legacy folder when we drop SDK 47
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
diff --git a/node_modules/expo-modules-core/android/src/fabric/CMakeLists.txt b/node_modules/expo-modules-core/android/src/fabric/CMakeLists.txt
index a70242f..2beeb4b 100644
--- a/node_modules/expo-modules-core/android/src/fabric/CMakeLists.txt
+++ b/node_modules/expo-modules-core/android/src/fabric/CMakeLists.txt
@@ -1,7 +1,5 @@
# Copyright 2018-present 650 Industries. All rights reserved.
-include(Android-prebuilt.cmake)
-
set(COMMON_FABRIC_DIR ${COMMON_DIR}/fabric)
file(GLOB SOURCES "*.cpp")
file(GLOB COMMON_FABRIC_SOURCES "${COMMON_FABRIC_DIR}/*.cpp")
@@ -13,6 +11,11 @@ add_library(fabric STATIC
target_compile_options(fabric PRIVATE
"-std=c++17"
+ -DFOLLY_NO_CONFIG=1
+ -DFOLLY_HAVE_CLOCK_GETTIME=1
+ -DFOLLY_HAVE_MEMRCHR=1
+ -DFOLLY_USE_LIBCPP=1
+ -DFOLLY_MOBILE=1
)
target_include_directories(fabric PRIVATE
@@ -20,20 +23,24 @@ target_include_directories(fabric PRIVATE
"${COMMON_FABRIC_DIR}"
)
+find_package(ReactAndroid REQUIRED CONFIG)
+
+find_package(fbjni REQUIRED CONFIG)
+
target_link_libraries(fabric
CommonSettings
- fabricjni
- fbjni
- folly_runtime
- glog
- jsi
- react_debug
- react_render_componentregistry
- react_render_core
- react_render_debug
- react_render_graphics
- react_render_mapbuffer
- rrc_view
- runtimeexecutor
- yoga
+ fbjni::fbjni
+ ReactAndroid::fabricjni
+ ReactAndroid::folly_runtime
+ ReactAndroid::glog
+ ReactAndroid::jsi
+ ReactAndroid::react_debug
+ ReactAndroid::react_render_componentregistry
+ ReactAndroid::react_render_core
+ ReactAndroid::react_render_debug
+ ReactAndroid::react_render_graphics
+ ReactAndroid::react_render_mapbuffer
+ ReactAndroid::rrc_view
+ ReactAndroid::runtimeexecutor
+ ReactAndroid::yoga
)
diff --git a/node_modules/expo-modules-core/common/cpp/fabric/ExpoViewProps.cpp b/node_modules/expo-modules-core/common/cpp/fabric/ExpoViewProps.cpp
index 3360c32..0bfa1cf 100644
--- a/node_modules/expo-modules-core/common/cpp/fabric/ExpoViewProps.cpp
+++ b/node_modules/expo-modules-core/common/cpp/fabric/ExpoViewProps.cpp
@@ -3,6 +3,8 @@
#include "ExpoViewProps.h"
#include <react/renderer/core/propsConversions.h>
+namespace react = facebook::react;
+
namespace expo {
ExpoViewProps::ExpoViewProps(const react::PropsParserContext &context,
diff --git a/node_modules/expo-modules-core/ios/AppDelegates/EXAppDelegateWrapper.h b/node_modules/expo-modules-core/ios/AppDelegates/EXAppDelegateWrapper.h
index b542a9b..eacda2c 100644
--- a/node_modules/expo-modules-core/ios/AppDelegates/EXAppDelegateWrapper.h
+++ b/node_modules/expo-modules-core/ios/AppDelegates/EXAppDelegateWrapper.h
@@ -3,6 +3,13 @@
#import <UIKit/UIKit.h>
#import <ExpoModulesCore/EXReactDelegateWrapper.h>
+#if __has_include(<React-RCTAppDelegate/RCTAppDelegate.h>)
+#import <React-RCTAppDelegate/RCTAppDelegate.h>
+#elif __has_include(<React_RCTAppDelegate/RCTAppDelegate.h>)
+// for importing the header from framework, the dash will be transformed to underscore
+#import <React_RCTAppDelegate/RCTAppDelegate.h>
+#endif
+
NS_ASSUME_NONNULL_BEGIN
/**
@@ -10,7 +17,11 @@ NS_ASSUME_NONNULL_BEGIN
written in Objective-C and that forwards all messages to the new `ExpoAppDelegate`.
If your `AppDelegate` is in Swift, it should inherit from `ExpoAppDelegate` class instead.
*/
+#if __has_include(<React-RCTAppDelegate/RCTAppDelegate.h>) || __has_include(<React_RCTAppDelegate/RCTAppDelegate.h>)
+@interface EXAppDelegateWrapper : RCTAppDelegate
+#else
@interface EXAppDelegateWrapper : UIResponder <UIApplicationDelegate>
+#endif
@property (nonatomic, strong, readonly) EXReactDelegateWrapper *reactDelegate;
diff --git a/node_modules/expo-modules-core/ios/AppDelegates/EXAppDelegateWrapper.m b/node_modules/expo-modules-core/ios/AppDelegates/EXAppDelegateWrapper.m
deleted file mode 100644
index acd8fa9..0000000
--- a/node_modules/expo-modules-core/ios/AppDelegates/EXAppDelegateWrapper.m
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2018-present 650 Industries. All rights reserved.
-
-#import <ExpoModulesCore/EXAppDelegateWrapper.h>
-#import <ExpoModulesCore/EXReactDelegateWrapper+Private.h>
-#import <ExpoModulesCore/Swift.h>
-
-
-@interface EXAppDelegateWrapper()
-
-@property (nonatomic, strong) EXReactDelegateWrapper *reactDelegate;
-
-@end
-
-@implementation EXAppDelegateWrapper {
- EXExpoAppDelegate *_expoAppDelegate;
-}
-
-// Synthesize window, so the AppDelegate can synthesize it too.
-@synthesize window = _window;
-
-- (instancetype)init
-{
- if (self = [super init]) {
- _expoAppDelegate = [[EXExpoAppDelegate alloc] init];
- _reactDelegate = [[EXReactDelegateWrapper alloc] initWithExpoReactDelegate:_expoAppDelegate.reactDelegate];
- }
- return self;
-}
-
-// This needs to be implemented, otherwise forwarding won't be called.
-// When the app starts, `UIApplication` uses it to check beforehand
-// which `UIApplicationDelegate` selectors are implemented.
-- (BOOL)respondsToSelector:(SEL)selector
-{
- return [super respondsToSelector:selector]
- || [_expoAppDelegate respondsToSelector:selector];
-}
-
-// Forwards all invocations to `ExpoAppDelegate` object.
-- (id)forwardingTargetForSelector:(SEL)selector
-{
- return _expoAppDelegate;
-}
-
-@end
diff --git a/node_modules/expo-modules-core/ios/AppDelegates/EXAppDelegateWrapper.mm b/node_modules/expo-modules-core/ios/AppDelegates/EXAppDelegateWrapper.mm
new file mode 100644
index 0000000..d9c0c04
--- /dev/null
+++ b/node_modules/expo-modules-core/ios/AppDelegates/EXAppDelegateWrapper.mm
@@ -0,0 +1,80 @@
+// Copyright 2018-present 650 Industries. All rights reserved.
+
+#import <ExpoModulesCore/EXAppDelegateWrapper.h>
+#import <ExpoModulesCore/EXReactDelegateWrapper+Private.h>
+#import <ExpoModulesCore/Swift.h>
+
+
+@interface EXAppDelegateWrapper()
+
+@property (nonatomic, strong) EXReactDelegateWrapper *reactDelegate;
+
+@end
+
+@implementation EXAppDelegateWrapper {
+ EXExpoAppDelegate *_expoAppDelegate;
+}
+
+// Synthesize window, so the AppDelegate can synthesize it too.
+@synthesize window = _window;
+
+- (instancetype)init
+{
+ if (self = [super init]) {
+ _expoAppDelegate = [[EXExpoAppDelegate alloc] init];
+ _reactDelegate = [[EXReactDelegateWrapper alloc] initWithExpoReactDelegate:_expoAppDelegate.reactDelegate];
+ }
+ return self;
+}
+
+// This needs to be implemented, otherwise forwarding won't be called.
+// When the app starts, `UIApplication` uses it to check beforehand
+// which `UIApplicationDelegate` selectors are implemented.
+- (BOOL)respondsToSelector:(SEL)selector
+{
+ return [super respondsToSelector:selector]
+ || [_expoAppDelegate respondsToSelector:selector];
+}
+
+// Forwards all invocations to `ExpoAppDelegate` object.
+- (id)forwardingTargetForSelector:(SEL)selector
+{
+ return _expoAppDelegate;
+}
+
+#if __has_include(<React-RCTAppDelegate/RCTAppDelegate.h>)
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ [super application:application didFinishLaunchingWithOptions:launchOptions];
+ [_expoAppDelegate application:application didFinishLaunchingWithOptions:launchOptions];
+ return YES;
+}
+
+- (RCTBridge *)createBridgeWithDelegate:(id<RCTBridgeDelegate>)delegate launchOptions:(NSDictionary *)launchOptions
+{
+ return [self.reactDelegate createBridgeWithDelegate:delegate launchOptions:launchOptions];
+}
+
+- (UIView *)createRootViewWithBridge:(RCTBridge *)bridge
+ moduleName:(NSString *)moduleName
+ initProps:(NSDictionary *)initProps
+{
+ BOOL enableFabric = NO;
+#if RN_FABRIC_ENABLED
+ enableFabric = self.fabricEnabled;
+#endif
+
+ return [self.reactDelegate createRootViewWithBridge:bridge
+ moduleName:moduleName
+ initialProperties:initProps
+ fabricEnabled:enableFabric];
+}
+
+- (UIViewController *)createRootViewController
+{
+ return [self.reactDelegate createRootViewController];
+}
+#endif // __has_include(<React-RCTAppDelegate/RCTAppDelegate.h>)
+
+@end
diff --git a/node_modules/expo-modules-core/ios/JSI/EXJavaScriptRuntime.mm b/node_modules/expo-modules-core/ios/JSI/EXJavaScriptRuntime.mm
index fe1e05f..a5c0c70 100644
--- a/node_modules/expo-modules-core/ios/JSI/EXJavaScriptRuntime.mm
+++ b/node_modules/expo-modules-core/ios/JSI/EXJavaScriptRuntime.mm
@@ -4,8 +4,8 @@
#if __has_include(<reacthermes/HermesExecutorFactory.h>)
#import <reacthermes/HermesExecutorFactory.h>
-#elif __has_include(<hermes/hermes.h>)
-#import <hermes/hermes.h>
+#elif __has_include(<React-jsc/JSCRuntime.h>)
+#import <React-jsc/JSCRuntime.h>
#else
#import <jsi/JSCRuntime.h>
#endif
@@ -16,8 +16,6 @@
#import <ExpoModulesCore/EXJSIConversions.h>
#import <ExpoModulesCore/Swift.h>
-using namespace facebook;
-
/**
Property name of the main object in the Expo JS runtime.
*/
@@ -37,8 +35,8 @@ static NSString *mainObjectPropertyName = @"expo";
- (nonnull instancetype)init
{
if (self = [super init]) {
-#if __has_include(<reacthermes/HermesExecutorFactory.h>) || __has_include(<hermes/hermes.h>)
- _runtime = hermes::makeHermesRuntime();
+#if __has_include(<reacthermes/HermesExecutorFactory.h>)
+ _runtime = facebook::hermes::makeHermesRuntime();
#else
_runtime = jsc::makeJSCRuntime();
#endif
diff --git a/node_modules/expo-modules-core/ios/ReactDelegates/EXReactCompatibleHelpers.h b/node_modules/expo-modules-core/ios/ReactDelegates/EXReactCompatibleHelpers.h
index 4b177f2..4a086b4 100644
--- a/node_modules/expo-modules-core/ios/ReactDelegates/EXReactCompatibleHelpers.h
+++ b/node_modules/expo-modules-core/ios/ReactDelegates/EXReactCompatibleHelpers.h
@@ -13,6 +13,6 @@ EX_EXTERN_C_BEGIN
*
* `RCTAppSetupDefaultRootView` is introduced in react-native 0.68. To make `expo-modules-core` compatible with older react-native, introduces this compatible helper.
*/
-UIView *EXAppSetupDefaultRootView(RCTBridge *bridge, NSString *moduleName, NSDictionary *initialProperties);
+UIView *EXAppSetupDefaultRootView(RCTBridge *bridge, NSString *moduleName, NSDictionary *initialProperties, BOOL fabricEnabled);
EX_EXTERN_C_END
diff --git a/node_modules/expo-modules-core/ios/ReactDelegates/EXReactCompatibleHelpers.m b/node_modules/expo-modules-core/ios/ReactDelegates/EXReactCompatibleHelpers.m
index d719238..50c0019 100644
--- a/node_modules/expo-modules-core/ios/ReactDelegates/EXReactCompatibleHelpers.m
+++ b/node_modules/expo-modules-core/ios/ReactDelegates/EXReactCompatibleHelpers.m
@@ -8,12 +8,18 @@
#import <React/RCTAppSetupUtils.h>
#endif
-UIView *EXAppSetupDefaultRootView(RCTBridge *bridge, NSString *moduleName, NSDictionary *initialProperties)
+UIView *EXAppSetupDefaultRootView(RCTBridge *bridge, NSString *moduleName, NSDictionary *initialProperties, BOOL fabricEnabled)
{
#if __has_include(<React/RCTAppSetupUtils.h>)
+
+#if REACT_NATIVE_MINOR_VERSION >= 71
+ return RCTAppSetupDefaultRootView(bridge, moduleName, initialProperties, fabricEnabled);
+#else
return RCTAppSetupDefaultRootView(bridge, moduleName, initialProperties);
+#endif // REACT_NATIVE_MINOR_VERSION >= 71
+
#else
return [[RCTRootView alloc] initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties];
-#endif
+#endif // __has_include(<React/RCTAppSetupUtils.h>)
}
diff --git a/node_modules/expo-modules-core/ios/ReactDelegates/EXReactDelegateWrapper.h b/node_modules/expo-modules-core/ios/ReactDelegates/EXReactDelegateWrapper.h
index 35b595c..31e62dc 100644
--- a/node_modules/expo-modules-core/ios/ReactDelegates/EXReactDelegateWrapper.h
+++ b/node_modules/expo-modules-core/ios/ReactDelegates/EXReactDelegateWrapper.h
@@ -18,6 +18,11 @@ NS_ASSUME_NONNULL_BEGIN
moduleName:(NSString *)moduleName
initialProperties:(nullable NSDictionary *)initialProperties;
+- (RCTRootView *)createRootViewWithBridge:(RCTBridge *)bridge
+ moduleName:(NSString *)moduleName
+ initialProperties:(nullable NSDictionary *)initialProperties
+ fabricEnabled:(BOOL)fabricEnabled;
+
- (UIViewController *)createRootViewController;
@end
diff --git a/node_modules/expo-modules-core/ios/ReactDelegates/EXReactDelegateWrapper.m b/node_modules/expo-modules-core/ios/ReactDelegates/EXReactDelegateWrapper.m
index 581aa2a..eb65068 100644
--- a/node_modules/expo-modules-core/ios/ReactDelegates/EXReactDelegateWrapper.m
+++ b/node_modules/expo-modules-core/ios/ReactDelegates/EXReactDelegateWrapper.m
@@ -1,6 +1,8 @@
// Copyright 2018-present 650 Industries. All rights reserved.
#import <ExpoModulesCore/EXReactDelegateWrapper.h>
+
+#import <ExpoModulesCore/EXAppDefines.h>
#import <ExpoModulesCore/EXReactDelegateWrapper+Private.h>
@interface EXReactDelegateWrapper()
@@ -29,7 +31,18 @@
moduleName:(NSString *)moduleName
initialProperties:(nullable NSDictionary *)initialProperties
{
- return [_expoReactDelegate createRootViewWithBridge:bridge moduleName:moduleName initialProperties:initialProperties];
+ return [_expoReactDelegate createRootViewWithBridge:bridge
+ moduleName:moduleName
+ initialProperties:initialProperties
+ fabricEnabled:EXAppDefines.APP_NEW_ARCH_ENABLED];
+}
+
+- (RCTRootView *)createRootViewWithBridge:(RCTBridge *)bridge
+ moduleName:(NSString *)moduleName
+ initialProperties:(nullable NSDictionary *)initialProperties
+ fabricEnabled:(BOOL)fabricEnabled
+{
+ return [_expoReactDelegate createRootViewWithBridge:bridge moduleName:moduleName initialProperties:initialProperties fabricEnabled:fabricEnabled];
}
- (UIViewController *)createRootViewController
diff --git a/node_modules/expo-modules-core/ios/ReactDelegates/ExpoReactDelegate.swift b/node_modules/expo-modules-core/ios/ReactDelegates/ExpoReactDelegate.swift
index 178c852..4058034 100644
--- a/node_modules/expo-modules-core/ios/ReactDelegates/ExpoReactDelegate.swift
+++ b/node_modules/expo-modules-core/ios/ReactDelegates/ExpoReactDelegate.swift
@@ -22,10 +22,15 @@ public class ExpoReactDelegate: NSObject {
}
@objc
- public func createRootView(bridge: RCTBridge, moduleName: String, initialProperties: [AnyHashable: Any]?) -> UIView {
+ public func createRootView(
+ bridge: RCTBridge,
+ moduleName: String,
+ initialProperties: [AnyHashable: Any]?,
+ fabricEnabled: Bool = EXAppDefines.APP_NEW_ARCH_ENABLED
+ ) -> UIView {
return self.handlers.lazy
.compactMap { $0.createRootView(reactDelegate: self, bridge: bridge, moduleName: moduleName, initialProperties: initialProperties) }
- .first(where: { _ in true }) ?? EXAppSetupDefaultRootView(bridge, moduleName, initialProperties)
+ .first(where: { _ in true }) ?? EXAppSetupDefaultRootView(bridge, moduleName, initialProperties, fabricEnabled)
}
@objc
diff --git a/node_modules/react-native/Libraries/AppDelegate/RCTAppDelegate.h b/node_modules/react-native/Libraries/AppDelegate/RCTAppDelegate.h
index b8d00ba..e7d1ac2 100644
--- a/node_modules/react-native/Libraries/AppDelegate/RCTAppDelegate.h
+++ b/node_modules/react-native/Libraries/AppDelegate/RCTAppDelegate.h
@@ -9,7 +9,7 @@
#import <React/RCTBridgeDelegate.h>
#import <UIKit/UIKit.h>
-#if RCT_NEW_ARCH_ENABLED
+#if RCT_NEW_ARCH_ENABLED && __cplusplus
// When the new architecture is enabled, the RCTAppDelegate imports some additional headers
#import <React/RCTCxxBridgeDelegate.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>
@@ -100,7 +100,7 @@
@end
-#if RCT_NEW_ARCH_ENABLED
+#if RCT_NEW_ARCH_ENABLED && __cplusplus
/// Extension that makes the RCTAppDelegate conform to New Architecture delegates
@interface RCTAppDelegate () <RCTTurboModuleManagerDelegate, RCTCxxBridgeDelegate>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment