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

feat: react native config #42

Merged
merged 1 commit into from
Dec 13, 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
2 changes: 2 additions & 0 deletions apps/app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@ yarn-error.log
!.yarn/releases
!.yarn/sdks
!.yarn/versions

ios/tmp.xcconfig
2 changes: 2 additions & 0 deletions apps/app/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: "com.android.application"
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"

Expand Down Expand Up @@ -110,6 +111,7 @@ android {
dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
implementation project(':react-native-config')

if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
Expand Down
2 changes: 2 additions & 0 deletions apps/app/android/app/src/main/java/com/app/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.react.soloader.OpenSourceMergedSoMapping
import com.facebook.soloader.SoLoader
import com.lugg.RNCConfig.RNCConfigPackage

class MainApplication : Application(), ReactApplication {

Expand All @@ -20,6 +21,7 @@ class MainApplication : Application(), ReactApplication {
PackageList(this).packages.apply {
// Packages that cannot be autolinked yet can be added manually here, for example:
// add(MyReactNativePackage())
add(RNCConfigPackage())
}

override fun getJSMainModuleName(): String = "index"
Expand Down
2 changes: 2 additions & 0 deletions apps/app/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ rootProject.name = 'fienmee-app'
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')

include ':react-native-config'
project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android')
10 changes: 10 additions & 0 deletions apps/app/ios/Config.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// Config.xcconfig
// app
//
// Created by 나구원 on 12/13/24.
//

// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974
#include? "tmp.xcconfig"
8 changes: 8 additions & 0 deletions apps/app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,10 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-config (1.5.3):
- react-native-config/App (= 1.5.3)
- react-native-config/App (1.5.3):
- React-Core
- react-native-safe-area-context (4.14.0):
- DoubleConversion
- glog
Expand Down Expand Up @@ -1682,6 +1686,7 @@ DEPENDENCIES:
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
- React-Mapbuffer (from `../node_modules/react-native/ReactCommon`)
- React-microtasksnativemodule (from `../node_modules/react-native/ReactCommon/react/nativemodule/microtasks`)
- react-native-config (from `../node_modules/react-native-config`)
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
- react-native-webview (from `../node_modules/react-native-webview`)
- React-nativeconfig (from `../node_modules/react-native/ReactCommon`)
Expand Down Expand Up @@ -1790,6 +1795,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon"
React-microtasksnativemodule:
:path: "../node_modules/react-native/ReactCommon/react/nativemodule/microtasks"
react-native-config:
:path: "../node_modules/react-native-config"
react-native-safe-area-context:
:path: "../node_modules/react-native-safe-area-context"
react-native-webview:
Expand Down Expand Up @@ -1889,6 +1896,7 @@ SPEC CHECKSUMS:
React-logger: 81d58ca6f1d93fca9a770bda6cc1c4fbfcc99c9c
React-Mapbuffer: 726951e68f4bb1c2513d322f2548798b2a3d628d
React-microtasksnativemodule: 7a69a9b8fded72ea3cf81923ecf75cad5558ed26
react-native-config: 8f7283449bbb048902f4e764affbbf24504454af
react-native-safe-area-context: 2500e4fe998caad50ad3bc51ec23ef951308569e
react-native-webview: 0bd56be54d01756f20eb942dad37a2cd22a6def2
React-nativeconfig: 470fce6d871c02dc5eff250a362d56391b7f52d6
Expand Down
4 changes: 4 additions & 0 deletions apps/app/ios/app.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = PrivacyInfo.xcprivacy; path = app/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
19F6CBCC0A4E27FBF8BF4A61 /* libPods-app-appTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-app-appTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
3B4392A12AC88292D35C810B /* Pods-app.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-app.debug.xcconfig"; path = "Target Support Files/Pods-app/Pods-app.debug.xcconfig"; sourceTree = "<group>"; };
5190EDF22D0C688D00DC5D68 /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
5709B34CF0A7D63546082F79 /* Pods-app.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-app.release.xcconfig"; path = "Target Support Files/Pods-app/Pods-app.release.xcconfig"; sourceTree = "<group>"; };
5B7EB9410499542E8C5724F5 /* Pods-app-appTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-app-appTests.debug.xcconfig"; path = "Target Support Files/Pods-app-appTests/Pods-app-appTests.debug.xcconfig"; sourceTree = "<group>"; };
5DCACB8F33CDC322A6C60F78 /* libPods-app.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-app.a"; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -119,6 +120,7 @@
83CBB9F61A601CBA00E9B192 = {
isa = PBXGroup;
children = (
5190EDF22D0C688D00DC5D68 /* Config.xcconfig */,
13B07FAE1A68108700A75B9A /* app */,
832341AE1AAA6A7D00B99B32 /* Libraries */,
00E356EF1AD99517003FC87E /* appTests */,
Expand Down Expand Up @@ -519,6 +521,7 @@
};
83CBBA201A601CBA00E9B192 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 5190EDF22D0C688D00DC5D68 /* Config.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
Expand Down Expand Up @@ -599,6 +602,7 @@
};
83CBBA211A601CBA00E9B192 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 5190EDF22D0C688D00DC5D68 /* Config.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
Expand Down
20 changes: 19 additions & 1 deletion apps/app/ios/app.xcodeproj/xcshareddata/xcschemes/app.xcscheme
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1210"
version = "1.3">
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<PreActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "# Type a script or drag a script file from your workspace to insert its path.&#10;&#10;&quot;${SRCROOT}/../node_modules/react-native-config/ios/ReactNativeConfig/BuildXCConfig.rb&quot; &quot;${SRCROOT}/..&quot; &quot;${SRCROOT}/tmp.xcconfig&quot;&#10;">
<EnvironmentBuildable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "app.app"
BlueprintName = "app"
ReferencedContainer = "container:app.xcodeproj">
</BuildableReference>
</EnvironmentBuildable>
</ActionContent>
</ExecutionAction>
</PreActions>
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand Down
1 change: 1 addition & 0 deletions apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"metro-config": "^0.81.0",
"react": "18.3.1",
"react-native": "0.76.2",
"react-native-config": "^1.5.3",
"react-native-safe-area-context": "^4.14.0",
"react-native-screens": "^4.3.0",
"react-native-webview": "^13.12.4"
Expand Down
9 changes: 9 additions & 0 deletions apps/app/react-native-config.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
declare module 'react-native-config' {
export interface NativeConfig {
FE_URL: string
BE_URL: string
}

export const Config: NativeConfig
export default Config
}
3 changes: 2 additions & 1 deletion apps/app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useColorScheme } from 'react-native'
import { WebView } from 'react-native-webview'
import { NavigationContainer } from '@react-navigation/native'
import { createNativeStackNavigator } from '@react-navigation/native-stack'
import config from 'react-native-config'

import { Colors } from 'react-native/Libraries/NewAppScreen'
import LoginScreen from '../pages/login.tsx'
Expand All @@ -33,7 +34,7 @@ function App(): React.JSX.Element {
<Stack.Screen
name="WebView"
component={() => {
return <WebView source={{ uri: 'http://192.168.0.6:3000/' }} containerStyle={{ flex: 0, width: '100%', height: '100%' }} />
return <WebView source={{ uri: config.FE_URL }} containerStyle={{ flex: 0, width: '100%', height: '100%' }} />
}}
/>
<Stack.Screen
Expand Down
13 changes: 13 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading