Skip to content

Commit 7ac237b

Browse files
committed
fix: Ensure compatibility with new React Native version
1 parent bd6cc36 commit 7ac237b

File tree

2 files changed

+54
-7
lines changed

2 files changed

+54
-7
lines changed

android/build.gradle

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,51 @@ buildscript {
1616
}
1717

1818
def getRNVersion() {
19-
def file = new File(rootDir, "../package.json")
20-
def json = new JsonSlurper().parse(file)
21-
return json.dependencies["react-native"] ?: json.devDependencies["react-native"]
19+
def rootPackageFile = new File(rootDir, "../package.json")
20+
if (rootPackageFile.exists()) {
21+
try {
22+
def json = new JsonSlurper().parse(rootPackageFile)
23+
def version = json.dependencies["react-native"] ?: json.devDependencies["react-native"]
24+
if (version) {
25+
return version
26+
}
27+
} catch (Exception e) {
28+
// Ignore parsing errors and continue
29+
}
30+
}
31+
32+
def searchPaths = [
33+
'../react-native/package.json',
34+
'../../react-native/package.json',
35+
'../../../react-native/package.json',
36+
'node_modules/react-native/package.json',
37+
'../node_modules/react-native/package.json',
38+
'../../node_modules/react-native/package.json'
39+
]
40+
41+
for (path in searchPaths) {
42+
def packageFile = new File(project.projectDir, path).getCanonicalFile()
43+
if (packageFile.exists()) {
44+
try {
45+
def json = new JsonSlurper().parse(packageFile)
46+
def version = json.version
47+
if (version) {
48+
if (version == '*' || version.contains('*')) {
49+
return "0.80.0" // Default for wildcard versions
50+
}
51+
return version
52+
}
53+
} catch (Exception e) {
54+
// Ignore parsing errors and continue
55+
}
56+
}
57+
}
58+
return "0.77.0"
2259
}
2360

61+
2462
def rnVersion = getRNVersion()
63+
println "Found react native version as ${rnVersion}"
2564

2665
def isNewArchitectureEnabled() {
2766
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"

hyper-sdk-react.podspec

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ require "json"
33
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
44

55
rn_minor_version = 0
6+
rn_major_version = 0
67
[
78
'../react-native/package.json',
89
'../../react-native/package.json',
@@ -16,8 +17,11 @@ rn_minor_version = 0
1617
version = package1 ['version']
1718
if version == '*' || version.include?('*')
1819
rn_minor_version = 80
20+
rn_major_version = 0
1921
else
20-
rn_minor_version = version.split('.')[1].to_i
22+
version_parts = version.split('.')
23+
rn_major_version = version_parts[0].to_i
24+
rn_minor_version = version_parts[1].to_i
2125
end
2226
break
2327
rescue => e
@@ -39,8 +43,11 @@ if rn_minor_version == 0
3943
version = package1 ['version']
4044
if version == '*' || version.include?('*')
4145
rn_minor_version = 80
46+
rn_major_version = 0
4247
else
43-
rn_minor_version = version.split('.')[1].to_i
48+
version_parts = version.split('.')
49+
rn_major_version = version_parts[0].to_i
50+
rn_minor_version = version_parts[1].to_i
4451
end
4552
break
4653
rescue => e
@@ -52,8 +59,9 @@ end
5259
# Fallback if still not found
5360
if rn_minor_version == 0
5461
rn_minor_version = 77
62+
rn_major_version = 0
5563
end
56-
puts ("Found react native minor version as #{rn_minor_version}").yellow
64+
puts ("Found react native minor version as #{rn_major_version}.#{rn_minor_version}").yellow
5765

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

@@ -79,7 +87,7 @@ puts ("HyperSDK Version: #{hyper_sdk_version}")
7987
source_files_array = ["ios/**/*.{h,m,mm,swift}"]
8088
exclude_files = []
8189

82-
if rn_minor_version >= 78
90+
if rn_minor_version >= 78 || (rn_major_version > 0)
8391
source_files_array << "ios/latest/**/*.{h,m,mm,swift}"
8492
exclude_files << "ios/rn77/**/*"
8593
else

0 commit comments

Comments
 (0)