Skip to content

Commit 056b61e

Browse files
committed
Setup new arch support
1 parent 53f750f commit 056b61e

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed

RNCAsyncStorage.podspec

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ require 'json'
22

33
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
44

5+
fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
6+
57
Pod::Spec.new do |s|
68
s.name = "RNCAsyncStorage"
79
s.version = package['version']
@@ -10,10 +12,30 @@ Pod::Spec.new do |s|
1012

1113
s.authors = package['author']
1214
s.homepage = package['homepage']
13-
s.platforms = { :ios => "9.0", :tvos => "9.2", :osx => "10.14" }
1415

1516
s.source = { :git => "https://github.com/react-native-async-storage/async-storage.git", :tag => "v#{s.version}" }
16-
s.source_files = "ios/**/*.{h,m}"
17+
s.source_files = "ios/**/*.{h,m,mm}"
18+
19+
if fabric_enabled
20+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
21+
22+
s.pod_target_xcconfig = {
23+
'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/boost" "$(PODS_ROOT)/boost-for-react-native" "$(PODS_ROOT)/RCT-Folly"',
24+
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17',
25+
}
26+
s.platforms = { ios: '11.0', tvos: '11.0', :osx => "10.14" }
27+
s.compiler_flags = folly_compiler_flags + ' -DRCT_NEW_ARCH_ENABLED'
28+
29+
s.dependency "React"
30+
s.dependency "React-RCTFabric" # This is for fabric component
31+
s.dependency "React-Codegen"
32+
s.dependency "RCT-Folly"
33+
s.dependency "RCTRequired"
34+
s.dependency "RCTTypeSafety"
35+
s.dependency "ReactCommon/turbomodule/core"
36+
else
37+
s.platforms = { :ios => "9.0", :tvos => "9.2", :osx => "10.14" }
1738

18-
s.dependency 'React-Core'
39+
s.dependency "React-Core"
40+
end
1941
end

android/build.gradle

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ def getVersionOrDefault(String flagName, String defaultVersion) {
2929
rootProject.hasProperty(flagName) ? rootProject.properties[flagName] : defaultVersion
3030
}
3131

32+
def isNewArchitectureEnabled() {
33+
// To opt-in for the New Architecture, you can either:
34+
// - Set `newArchEnabled` to true inside the `gradle.properties` file
35+
// - Invoke gradle with `-newArchEnabled=true`
36+
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
37+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
38+
}
39+
3240
configurations {
3341
compileClasspath
3442
}
@@ -77,8 +85,22 @@ if (useNextStorage) {
7785
apply from: './testresults.gradle'
7886
}
7987

88+
if (isNewArchitectureEnabled()) {
89+
apply plugin: "com.facebook.react"
90+
}
91+
8092
android {
8193
compileSdkVersion safeExtGet('compileSdkVersion', 31)
94+
95+
// Used to override the NDK path/version by allowing users to customize
96+
// the NDK path/version from their root project (e.g. for M1 support)
97+
if (rootProject.hasProperty("ndkPath")) {
98+
ndkPath rootProject.ext.ndkPath
99+
}
100+
if (rootProject.hasProperty("ndkVersion")) {
101+
ndkVersion rootProject.ext.ndkVersion
102+
}
103+
82104
defaultConfig {
83105
minSdkVersion safeExtGet('minSdkVersion', 21)
84106
targetSdkVersion safeExtGet('targetSdkVersion', 31)

0 commit comments

Comments
 (0)