Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating to the New Architecture #126

Merged
merged 5 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions .github/actions/build-app/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,26 @@ inputs:
description: 'Platform (example: android or ios))'
required: true

node-version:
description: 'The Node.js version to set up'
required: false

java-version:
description: 'The Java version to set up'
required: false


runs:
using: 'composite'
steps:
- uses: ./.github/actions/lock-nodejs-ver
with:
node-version: ${{ inputs.node-version }}

- uses: ./.github/actions/lock-java-ver
if: ${{ inputs.platform == 'android' }}
with:
java-version: ${{ inputs.java-version }}

- uses: ./.github/actions/lock-ruby-ver
if: ${{ inputs.platform == 'ios' }}
Expand Down Expand Up @@ -78,13 +90,25 @@ runs:
if [[ '${{ inputs.platform }}' == 'ios' ]]; then
brew install xcbeautify


# Disable Flipper
# RN 0.69.x and 0.70.x
retyui marked this conversation as resolved.
Show resolved Hide resolved
sed -i.bak "s|FlipperConfiguration.enabled|ENV['NO_FLIPPER'] == \"1\" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled|g" ios/Podfile
# RN <= 0.68.x
sed -i.bak 's|use_flipper!()|if ENV["NO_FLIPPER"] != "1"\n use_flipper!()\n end|g' ios/Podfile

# Fix Xcode 14 ([email protected])
sed -i.bak 's|node->getLayout().hadOverflow() \|\||node->getLayout().hadOverflow()\|\||g' node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp
sed -i.bak 's|node->getLayout().hadOverflow() \||node->getLayout().hadOverflow()\|\||g' node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp


# Update pods after adding new module
npx pod-install

# Build iOS App
xcodebuild -scheme ${{ env.APP_NAME }} -workspace ios/${{ env.APP_NAME }}.xcworkspace -configuration Release -sdk iphonesimulator -destination 'generic/platform=iOS Simulator' | xcbeautify --quiet
# set output variable

# set output variable
echo "app_path=$(find ~/Library/Developer/Xcode/DerivedData -type d -name "${{ env.APP_NAME }}.app")" >> $GITHUB_OUTPUT
else
# Enable new arch for Android
Expand All @@ -94,7 +118,7 @@ runs:

# Build Android
./android/gradlew assembleRelease --no-daemon -p android -PreactNativeArchitectures=${{ inputs.arch }}

# set output variable
echo "app_path=$(find $(pwd)/android -type f -name '*.apk')" >> $GITHUB_OUTPUT
fi
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ jobs:
max-parallel: 4
matrix:
new_arch_enabled: [ 1, 0 ]
rn_ver: [latest ] # also, can be any npm tag: 0.71-stable, next, nightly
rn_ver: [latest] # also, can be any npm tag: 0.71-stable, next, nightly or version: 0.68, 0.70 ...

steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -70,6 +71,8 @@ jobs:
module-to-install: file:${{ github.workspace }}
store-artifacts: true
platform: android
node-version: ${{ contains(matrix.rn_ver, '0.5') && '14' || contains(matrix.rn_ver, '0.6') && '16' || '18' }}
java-version: ${{ contains(matrix.rn_ver, '0.5') && '8' || contains(matrix.rn_ver, '0.6') && '11' || '17' }}

build-ios:
name: Build iOS
Expand All @@ -79,7 +82,10 @@ jobs:
max-parallel: 3
matrix:
new_arch_enabled: [ 1, 0 ]
rn_ver: [latest ] # also, can be any npm tag: 0.71-stable, next, nightly
rn_ver: [latest] # also, can be any npm tag: 0.71-stable, next, nightly or version: 0.68, 0.70 ...



steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -92,3 +98,5 @@ jobs:
module-to-install: file:${{ github.workspace }}
store-artifacts: true
platform: ios
node-version: ${{ contains(matrix.rn_ver, '0.5') && '14' || contains(matrix.rn_ver, '0.6') && '16' || '18' }}
java-version: ${{ contains(matrix.rn_ver, '0.5') && '8' || contains(matrix.rn_ver, '0.6') && '11' || '17' }}
99 changes: 71 additions & 28 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@

buildscript {
repositories {
google()
mavenCentral()
}
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
dependencies {
classpath "com.android.tools.build:gradle:7.2.1"
}
}

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

apply plugin: "com.android.library"

if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"
}

def getExtOrDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['RNImageEditor_' + name]
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["RNImageEditor_" + name]
}

def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['RNImageEditor_' + name]).toInteger()
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["RNImageEditor_" + name]).toInteger()
}

def supportsNamespace() {
Expand All @@ -27,34 +36,68 @@ def supportsNamespace() {
return (major == 7 && minor >= 3) || major >= 8
}


apply plugin: 'com.android.library'

android {
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
buildToolsVersion getExtOrDefault('buildToolsVersion')
if (supportsNamespace()) {
namespace "com.reactnativecommunity.imageeditor"

if (supportsNamespace()) {
namespace "com.reactnativecommunity.imageeditor"
sourceSets {
main {
manifest.srcFile "src/main/AndroidManifestNew.xml"
}
}
}
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
defaultConfig {
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
}
buildFeatures {
buildConfig true
}

sourceSets {
main {
manifest.srcFile "src/main/AndroidManifestNew.xml"
}
}
buildTypes {
release {
minifyEnabled false
}
}

lintOptions {
disable "GradleCompatible"
}

defaultConfig {
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

sourceSets {
main {
if (isNewArchitectureEnabled()) {
java.srcDirs += ["src/newarch"]
} else {
java.srcDirs += ["src/oldarch"]
}
}
}
}

repositories {
mavenCentral()
mavenCentral()
google()
}

dependencies {
api 'com.facebook.react:react-native:+'
// For < 0.71, this will be from the local maven repo
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
}

if (isNewArchitectureEnabled()) {
react {
retyui marked this conversation as resolved.
Show resolved Hide resolved
jsRootDir = file("../src/")
libraryName = "RNCImageEditor"
codegenJavaPackageName = "com.reactnativecommunity.imageeditor"
}
}

7 changes: 3 additions & 4 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
RNImageEditor_compileSdkVersion=28
RNImageEditor_buildToolsVersion=28.0.3
RNImageEditor_targetSdkVersion=28
RNImageEditor_minSdkVersion=19
RNImageEditor_compileSdkVersion=31
retyui marked this conversation as resolved.
Show resolved Hide resolved
RNImageEditor_targetSdkVersion=31
RNImageEditor_minSdkVersion=21
3 changes: 2 additions & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Sat Nov 04 23:34:44 CET 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3 changes: 0 additions & 3 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.reactnativecommunity.imageeditor">

</manifest>

Loading