Skip to content

Commit 12b6253

Browse files
Ron RadtkeRon Radtke
authored andcommitted
[FEAT] New Architecture Migration
# Conflicts: # android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilImpl.java # android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java
2 parents 8d9d980 + 6378035 commit 12b6253

Some content is hidden

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

41 files changed

+3475
-2548
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ codecov.yml
2727
# Example
2828
img/
2929
example/
30+
examples/
3031
app.json
3132

3233
# Android

Migration.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Migration to the New Architecture
2+
3+
This file is a tracker for what has been done to work on the migration of this library and to keep also track of the various todo:
4+
5+
## TODO
6+
7+
- [] Write JS spec in Flow for the New Architecture
8+
- [] Implent the new Native Code on iOS
9+
- [] Implent the new Native Code on Android
10+
- [] Test on OldArch app (iOS)
11+
- [] Test on OldArch app (Android)
12+
- [] Test on NewArch app (iOS)
13+
- [] Test on NewArch app (Android)
14+
- [] Open PR
15+
16+
## Done
17+
18+
### Setup
19+
1. Forked and cloned the repo
20+
1. Checked the list of APIs to migrate.
21+
1. Created an `OldArch` app (0.70) configured for the Old Architecture.
22+
1. Run the app to make sure that it works properly.
23+
1. Created a `NewArch` app (0.70) configured for the New Architecture.
24+
1. Switched the flags for iOS and Android to have the new arch enabled by default
25+
1. Run the app to make sure that it works properly.
26+
1. Moved the apps in the `examples` folder
27+
28+
### Installing blob-utils
29+
1. Move to `OldArch`
30+
1. Run `yarn add ../..` to install the blob utils.
31+
1. `cd ios`
32+
1. `bundle install && bundle exec pod install`
33+
1. `cd ..`
34+
1. `npx react-native run-ios`
35+
1. Copy the app JS code from `examples/ReactNativeBlobUtil/App.js` to `examples/OldArch/App.js`
36+
1. Fixed various JS issues
37+
1. The app depends on the `Picker`. *Note:* It does not support the New Arch, we need to figure out another way to choose.
38+
1. run `yarn add @react-native-picker/picker`
39+
1. run `bundle exec pod install` from the iOS folder
40+
1. re-run the app
41+
1. Repeat the above steps for `NewArch`

android.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
// Use of this source code is governed by a MIT-style license that can be
33
// found in the LICENSE file.
44

5-
import { NativeModules, Platform } from 'react-native';
6-
7-
const ReactNativeBlobUtil = NativeModules.ReactNativeBlobUtil;
5+
import { Platform } from 'react-native';
6+
import ReactNativeBlobUtil from './codegenSpecs/NativeBlobUtils';
87

98
/**
109
* Send an intent to open the file.

android/build.gradle

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,19 @@ buildscript {
3030
mavenCentral()
3131
}
3232
dependencies {
33-
classpath 'com.android.tools.build:gradle:4.1.3'
33+
classpath 'com.android.tools.build:gradle:7.2.1'
3434
}
3535
}
3636
}
3737

38+
def isNewArchitectureEnabled() {
39+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
40+
}
41+
42+
if (isNewArchitectureEnabled()) {
43+
apply plugin: 'com.facebook.react'
44+
}
45+
3846
android {
3947
compileSdkVersion safeExtGet('compileSdkVersion', 30)
4048
buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')
@@ -43,6 +51,7 @@ android {
4351
targetSdkVersion safeExtGet('targetSdkVersion', 30)
4452
versionCode 1
4553
versionName "1.0"
54+
buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
4655
}
4756
buildTypes {
4857
release {
@@ -55,6 +64,15 @@ android {
5564
}
5665
productFlavors {
5766
}
67+
sourceSets {
68+
main {
69+
if (isNewArchitectureEnabled()) {
70+
java.srcDirs += ['src/newarch']
71+
} else {
72+
java.srcDirs += ['src/oldarch']
73+
}
74+
}
75+
}
5876
}
5977

6078
dependencies {

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip

android/gradlew

100644100755
File mode changed.

0 commit comments

Comments
 (0)