Skip to content

Commit

Permalink
feat: use expo
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiqingchen committed Apr 29, 2022
1 parent f2b770a commit 40d1d1d
Show file tree
Hide file tree
Showing 18 changed files with 1,066 additions and 1,014 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/assemble_android_debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ env:
# 打包类型
BUILD_TYPE: debug
# 版本名称
ANDROID_VERSION_NAME: 1.4.7
ANDROID_VERSION_NAME: 1.5.0
# 版本号
ANDROID_VERSION_CODE: 14700
ANDROID_VERSION_CODE: 15000
# 密钥库文件
ANDROID_KEYSTORE_FILE: debug.keystore
# 密钥库口令
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/assemble_android_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ env:
# 打包类型
BUILD_TYPE: release
# 版本名称
ANDROID_VERSION_NAME: 1.4.7
ANDROID_VERSION_NAME: 1.5.0
# 版本号
ANDROID_VERSION_CODE: 14700
ANDROID_VERSION_CODE: 15000
# 密钥库文件
ANDROID_KEYSTORE_FILE: release.keystore
# 密钥库口令
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/assemble_ios_debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:
APP_ID: ${{secrets.APP_ID}}
APP_NAME: Taro
BUILD_TYPE: debug
IOS_VERSION_NUMBER: 1.4.7
IOS_VERSION_NUMBER: 1.5.0
IOS_TEAM_ID: ${{secrets.TEAM_ID}}
IOS_PROVISIONING_PROFILE_SPECIFIER: ${{secrets.DEBUG_PROVISIONING_PROFILE_SPECIFIER}}
IOS_CODE_SIGN_IDENTITY: iPhone Developer
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/assemble_ios_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ env:
APP_ID: ${{secrets.APP_ID}}
APP_NAME: Taro
BUILD_TYPE: release
IOS_VERSION_NUMBER: 1.4.7
IOS_BUILD_NUMBER: 1.4.7.1
IOS_VERSION_NUMBER: 1.5.0
IOS_BUILD_NUMBER: 1.5.0.1
IOS_TEAM_ID: ${{secrets.TEAM_ID}}
IOS_PROVISIONING_PROFILE_SPECIFIER: ${{secrets.RELEASE_PROVISIONING_PROFILE_SPECIFIER}}
IOS_CODE_SIGN_IDENTITY: iPhone Distribution
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ android.applicationVariants.all {
processManifestTask.doLast {
def processResources = output.getProcessResourcesProvider().get()
def manifestPath = processResources.manifestFile
def manifestFile = file(manifestPath)
def parser = new XmlParser()
def manifestFile = file(manifestPath)
def parser = new groovy.xml.XmlParser()
def rootNode = parser.parse(manifestFile)
extraPermissionsForDebug.each {
rootNode.appendNode("uses-permission", ["android:name": "android.permission.$it"])
Expand Down
9 changes: 9 additions & 0 deletions android/app/src/main/java/com/tarodemo/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package com.tarodemo;
import expo.modules.ReactActivityDelegateWrapper;
import com.facebook.react.ReactActivityDelegate;
import android.os.Bundle; // here
import com.facebook.react.ReactActivity;
import com.tarodemo.devmanager.TaroDevManager;
Expand Down Expand Up @@ -28,4 +30,11 @@ public void finish() {
protected String getMainComponentName() {
return "taroDemo";
}

@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegateWrapper(this,
new ReactActivityDelegate(this, getMainComponentName())
);
}
}
13 changes: 12 additions & 1 deletion android/app/src/main/java/com/tarodemo/MainApplication.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.tarodemo;

import android.content.res.Configuration;
import expo.modules.ApplicationLifecycleDispatcher;
import expo.modules.ReactNativeHostWrapper;

import android.app.Application;
import android.content.Context;

Expand All @@ -17,7 +21,7 @@ public class MainApplication extends Application implements ReactApplication {

@Override
public ReactNativeHost getReactNativeHost() {
return TaroDevManager.getReactNativeHost();
return new ReactNativeHostWrapper(this, TaroDevManager.getReactNativeHost());
}

@Override
Expand All @@ -31,6 +35,7 @@ public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
//initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
ApplicationLifecycleDispatcher.onApplicationCreate(this);
}

public static MainApplication getInstance(){
Expand Down Expand Up @@ -67,4 +72,10 @@ private static void initializeFlipper(
}
}
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.tarodemo.devmanager

import android.app.Application
import com.facebook.react.*
import com.tarodemo.BuildConfig
import com.tarodemo.generated.BasePackageList
import com.facebook.react.PackageList
import com.facebook.react.ReactInstanceManager
import com.facebook.react.ReactNativeHost
import com.facebook.react.ReactPackage

class TaroReactNativeHost(application: Application) : ReactNativeHost(application) {

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.2")
classpath("com.android.tools.build:gradle:7.1.2")
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 3 additions & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
rootProject.name = 'taroDemo'
apply from: '../node_modules/react-native-unimodules/gradle.groovy'; includeUnimodulesProjects()
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'

apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle")
useExpoModules()
11 changes: 10 additions & 1 deletion ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '11.0'
platform :ios, '12.0'

target 'taroDemo' do
use_expo_modules!
post_integrate do |installer|
begin
expo_patch_react_imports!(installer)
rescue => e
Pod::UI.warn e
end
end
config = use_native_modules!

use_react_native!(
Expand Down
Loading

0 comments on commit 40d1d1d

Please sign in to comment.