Skip to content

Commit eed1607

Browse files
authored
chore: bump React Native to 0.78, support new architecture (#92)
* chore: bump React Native to 0.78 * chore: remove java, objective-c examples * feat: use ReactNativeFactory * feat: base setup for Android * migrate to separate example app to satisfy codegen * feat: initial working state for Android * feat: use Jetpack Compose, implelement view factory
1 parent 34e48c5 commit eed1607

File tree

94 files changed

+12172
-9415
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+12172
-9415
lines changed

.github/workflows/ci.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,15 @@ jobs:
2222
node-version: 'lts/*'
2323
cache: 'yarn'
2424

25-
- name: Install dependencies
25+
- name: Install root dependencies
2626
run: yarn install
2727

28+
- name: Install example dependencies
29+
run: |
30+
cd example
31+
yarn install
32+
cd ..
33+
2834
- name: Lint JS Code (ESLint)
2935
run: yarn run lint
3036

.gitignore

+9-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ build/
3030
.gradle
3131
local.properties
3232
*.iml
33+
example/kotlin/build/
34+
*.iml
35+
*.hprof
36+
**/.cxx/
37+
*.keystore
38+
!debug.keystore
39+
.kotlin/
3340

3441
# node.js
3542
#
@@ -67,7 +74,8 @@ buck-out/
6774
!.yarn/releases
6875
!.yarn/sdks
6976
!.yarn/versions
70-
.yarnrc.yml
77+
.yarnrc.yml
78+
example/.yarn/*
7179

7280
# generated by bob
7381
lib/

ReactNativeBrownfield.podspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ Pod::Spec.new do |spec|
1818

1919
# s.source = { :git => "[email protected]/michalchudziak/react-native-brownfield.git", :tag => "v#{s.version}" }
2020
spec.source = { :path => "." }
21-
spec.source_files = "ios/**/*.{h,m,mm}"
21+
spec.source_files = "ios/**/*.{h,m,mm,swift}"
2222
spec.compiler_flags = new_arch_enabled_flag
2323
spec.pod_target_xcconfig = { 'OTHER_CPLUSPLUSFLAGS' => other_cflags }
2424

25-
spec.dependency 'React'
25+
install_modules_dependencies(spec)
2626
end

android/build.gradle

+89-16
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,102 @@
1-
apply plugin: 'com.android.library'
2-
apply plugin: 'kotlin-android'
1+
buildscript {
2+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
3+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["RNBrownfield_kotlinVersion"]
34

4-
def safeExtGet(prop, fallback) {
5-
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
5+
repositories {
6+
google()
7+
mavenCentral()
8+
}
9+
10+
dependencies {
11+
classpath "com.android.tools.build:gradle:7.2.1"
12+
// noinspection DifferentKotlinGradleVersion
13+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14+
}
615
}
716

8-
repositories {
9-
google()
17+
def isNewArchitectureEnabled() {
18+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
19+
}
20+
21+
def isHermesEnabled() {
22+
return rootProject.hasProperty("hermesEnabled") && rootProject.getProperty("hermesEnabled") == "true"
23+
}
24+
25+
apply plugin: "com.android.library"
26+
apply plugin: "kotlin-android"
27+
28+
if (isNewArchitectureEnabled()) {
29+
apply plugin: "com.facebook.react"
30+
}
31+
32+
def getExtOrDefault(name) {
33+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["RNBrownfield_" + name]
34+
}
35+
36+
def getExtOrIntegerDefault(name) {
37+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["RNBrownfield_" + name]).toInteger()
38+
}
39+
40+
def supportsNamespace() {
41+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
42+
def major = parsed[0].toInteger()
43+
def minor = parsed[1].toInteger()
44+
45+
// Namespace support was added in 7.3.0
46+
return (major == 7 && minor >= 3) || major >= 8
1047
}
1148

1249
android {
13-
compileSdkVersion safeExtGet('compileSdkVersion', 28)
50+
if (supportsNamespace()) {
51+
namespace "com.callstack.reactnativebrownfield"
1452

15-
defaultConfig {
16-
minSdkVersion safeExtGet('minSdkVersion', 21)
17-
targetSdkVersion safeExtGet('targetSdkVersion', 28)
18-
}
53+
sourceSets {
54+
main {
55+
manifest.srcFile "src/main/AndroidManifest.xml"
56+
}
57+
}
58+
}
59+
60+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
61+
62+
defaultConfig {
63+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
64+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
65+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
66+
buildConfigField "boolean", "IS_HERMES_ENABLED", isHermesEnabled().toString()
67+
}
68+
69+
buildFeatures {
70+
buildConfig true
71+
}
1972

20-
lintOptions {
21-
abortOnError false
73+
buildTypes {
74+
release {
75+
minifyEnabled false
2276
}
77+
}
2378

79+
lintOptions {
80+
disable "GradleCompatible"
81+
}
82+
83+
compileOptions {
84+
sourceCompatibility JavaVersion.VERSION_1_8
85+
targetCompatibility JavaVersion.VERSION_1_8
86+
}
87+
}
88+
89+
repositories {
90+
mavenCentral()
91+
google()
2492
}
2593

94+
def kotlin_version = getExtOrDefault("kotlinVersion")
95+
2696
dependencies {
27-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${safeExtGet('kotlinVersion', '1.3.40')}"
28-
implementation "com.facebook.react:react-native:+"
29-
}
97+
// For < 0.71, this will be from the local maven repo
98+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
99+
//noinspection GradleDynamicVersion
100+
implementation "com.facebook.react:react-native:+"
101+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
102+
}

android/gradle.properties

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
RNBrownfield_kotlinVersion=1.7.0
2+
RNBrownfield_minSdkVersion=21
3+
RNBrownfield_targetSdkVersion=31
4+
RNBrownfield_compileSdkVersion=31
5+
RNBrownfield_ndkversion=21.4.7075529

android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeActivity.kt

-188
This file was deleted.

0 commit comments

Comments
 (0)