Skip to content

config: React Native Code Push 안드로이드 적용 #87

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

Merged
merged 9 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ node_modules/
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.env
.env
sentry.properties
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"storybook": "yarn workspace design-system run storybook",
"prepare": "husky",
"postinstall": "husky install",
"pod": "cd packages/react-native/ios && pod install"
"pod": "cd packages/react-native/ios && pod install",
"codepush:android": "yarn workspace react-native codepush:android"
},
"packageManager": "yarn@3.6.4",
"dependencies": {
Expand Down
14 changes: 12 additions & 2 deletions packages/react-native/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ apply plugin: "com.facebook.react"
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def KAKAO_APP_KEY = properties.getProperty('KAKAO_APP_KEY')
def CODEPUSH_DEPLOYMENT_KEY=properties.getProperty('CODEPUSH_DEPLOYMENT_KEY')

/**
* This is the configuration block to customize your React Native Android app.
Expand Down Expand Up @@ -84,10 +85,11 @@ android {
applicationId "com.spotclient"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
versionCode 2
versionName "1.0.1"
manifestPlaceholders=[KAKAO_APP_KEY:KAKAO_APP_KEY]
resValue "string", "KAKAO_APP_KEY", KAKAO_APP_KEY
resValue "string", "CODEPUSH_DEPLOYMENT_KEY",CODEPUSH_DEPLOYMENT_KEY
}
signingConfigs {
release{
Expand All @@ -108,14 +110,21 @@ android {
buildTypes {
debug {
signingConfig signingConfigs.debug
resValue "string", "CodePushDeploymentKey", CODEPUSH_DEPLOYMENT_KEY_PRODUCTION
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.release
resValue "string", "CodePushDeploymentKey", CODEPUSH_DEPLOYMENT_KEY_PRODUCTION
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
releaseStaging {
initWith release // release build type 설정을 상속
resValue "string", "CodePushDeploymentKey", CODEPUSH_DEPLOYMENT_KEY_STAGING
matchingFallbacks = ['release']
}
}
}

Expand All @@ -131,3 +140,4 @@ dependencies {
}

apply from: file("../../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: "../../../../node_modules/react-native-code-push/android/codepush.gradle"
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.soloader.SoLoader
import com.microsoft.codepush.react.CodePush

class MainApplication : Application(), ReactApplication {

Expand All @@ -27,6 +28,10 @@ class MainApplication : Application(), ReactApplication {

override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED

override fun getJSBundleFile(): String? {
return CodePush.getJSBundleFile()
}
}

override val reactHost: ReactHost
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<resources>
<string name="app_name">SPOT!</string>
<string name="kakao_app_key">@string/KAKAO_APP_KEY</string>
<string moduleConfig="true" name="CodePushDeploymentKey">@string/CODEPUSH_DEPLOYMENT_KEY</string>
</resources>
2 changes: 2 additions & 0 deletions packages/react-native/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ rootProject.name = 'SPOTClient'
apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../../../node_modules/@react-native/gradle-plugin')
include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-code-push/android/app')
20 changes: 20 additions & 0 deletions packages/react-native/codePush.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
mkdir CodePush

# create js source bundle
npx react-native bundle \
--entry-file=./index.js \
--bundle-output=./CodePush/index.android.bundle \
--assets-dest=./CodePush/ \
--dev=false \
--platform=android

# send codepush
# t에 타겟 버전(android build)
appcenter codepush release \
-a rlfehd2013/SPOT \
-c ./CodePush \
-d Production \
-t 1.0.0 \
``

rm -rf CodePush
6 changes: 4 additions & 2 deletions packages/react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "react-native",
"version": "0.0.1",
"version": "1.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"lint": "prettier --cache --write src & eslint --cache --cache-location ./.cache/.eslintcache src",
"start": "react-native start",
"test": "jest"
"test": "jest",
"codepush:android": "sh codePush.sh"
},
"lint-staged": {
"*.{js,ts,tsx}": [
Expand Down Expand Up @@ -36,6 +37,7 @@
"react-error-boundary": "^4.0.13",
"react-native": "0.74.3",
"react-native-calendars": "^1.1306.0",
"react-native-code-push": "^9.0.0",
"react-native-date-picker": "^5.0.4",
"react-native-dotenv": "^3.4.11",
"react-native-element-dropdown": "^2.12.1",
Expand Down
5 changes: 3 additions & 2 deletions packages/react-native/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import StackNavigator from '@routes/StackNavigator';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { Alert } from 'react-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import CodePush from 'react-native-code-push';
import * as Sentry from '@sentry/react-native';
import { SENTRY_DSN } from '@env';

Expand All @@ -25,6 +26,7 @@ const queryClient = new QueryClient({
},
},
});

function App() {
return (
<QueryClientProvider client={queryClient}>
Expand All @@ -38,5 +40,4 @@ function App() {
</QueryClientProvider>
);
}

export default Sentry.wrap(App);
export default CodePush(Sentry.wrap(App));
Loading
Loading