{"id":25690693,"url":"https://github.com/csath/react-native-config-reader","last_synced_at":"2025-04-24T04:39:56.979Z","repository":{"id":34522358,"uuid":"179270286","full_name":"csath/react-native-config-reader","owner":"csath","description":"🛠 Easily access any of the build configs defined in build.gradle or info.plist from your JS code.","archived":false,"fork":false,"pushed_at":"2023-02-27T19:51:02.000Z","size":2360,"stargazers_count":47,"open_issues_count":20,"forks_count":17,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-24T04:39:50.377Z","etag":null,"topics":["android","buildconfig","buildconfigfield","config","config-reader","ios","native","react","react-native","react-native-config-reader","reader"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/csath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-03T10:51:24.000Z","updated_at":"2024-12-04T11:07:21.000Z","dependencies_parsed_at":"2024-06-19T13:20:28.654Z","dependency_job_id":"f92b9c89-2d29-4956-b748-9d1de004f01e","html_url":"https://github.com/csath/react-native-config-reader","commit_stats":{"total_commits":57,"total_committers":10,"mean_commits":5.7,"dds":0.543859649122807,"last_synced_commit":"64bc2f0428dfd5954bb43725dcf592e2d2b9973f"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csath%2Freact-native-config-reader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csath%2Freact-native-config-reader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csath%2Freact-native-config-reader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csath%2Freact-native-config-reader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/csath","download_url":"https://codeload.github.com/csath/react-native-config-reader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250566440,"owners_count":21451227,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","buildconfig","buildconfigfield","config","config-reader","ios","native","react","react-native","react-native-config-reader","reader"],"created_at":"2025-02-24T22:50:51.936Z","updated_at":"2025-04-24T04:39:56.964Z","avatar_url":"https://github.com/csath.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🛠 react-native-config-reader [![npm](https://img.shields.io/npm/v/react-native-config-reader.svg)](https://npmjs.com/package/react-native-config-reader)  [![npm](https://img.shields.io/npm/dm/react-native-config-reader.svg)](https://npmjs.com/package/react-native-config-reader)\n\nA native library to access all the native code's build configurations from JS.\n\nFor **react-native@0.60+** versions use **react-native-config-reader@4.0+**\n(autolinking support enabled now).\n\n🚨 Seeking help maintaining `react-native-windows` compatibility. See [below](#windows-beta).\n\n## Installation\n\nFor **rn 0.60+ Auto Linking** will do things for you.\n\nIf not, follow these:\n\n1. `$ npm install react-native-config-reader --save` or  `$ yarn add react-native-config-reader`\n\n2. `$ react-native link react-native-config-reader`\n\n3. Go to **android/app/src/main/packageName/MainApplication.java** and find line\n\n   `new RNConfigReaderPackage()`\n\nSee [manual installation](#manual-installation) below if you have issues with `react-native link`.\n\n## Usage\n\n```javascript\nimport RNConfigReader from 'react-native-config-reader';\n\n// access any of the defined config variables in Android build gradle or iOS info.plist\nconst configValue = RNConfigReader.ANY_DEFINED_CONFIG_FIELD;\n```\n\n### More examples\n\nCreate new build config field inside android `build.gradle` file **(android/app/build.gradle)**\n\n```gradle\nandroid {\n\n    defaultConfig {\n        applicationId \"com.react-native.react-native-config-reader\"\n        versionCode 1\n        versionName \"1.0\"\n\n        buildConfigField \"String\", \"TEST_CONFIG_FIELD\", \"Hello I'm your test config value\"\n    }\n}\n```\n\nCreate new field inside ios `info.plist` file\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003c!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"\u003e\n\n\u003cplist version=\"1.0\"\u003e\n\u003cdict\u003e\n   \u003ckey\u003eCFBundleDisplayName\u003c/key\u003e\n   \u003cstring\u003ecom.react-native.react-native-config-reader\u003c/string\u003e\n\n   \u003ckey\u003eTEST_CONFIG_FIELD\u003c/key\u003e\n   \u003cstring\u003e\"Hello I'm your test config value\"\u003c/string\u003e\n\u003c/dict\u003e\n\u003c/plist\u003e\n```\n\nNow you can access them inside the JS code:\n\n```javascript\nimport { Platform } from 'react-native';\nimport RNConfigReader from 'react-native-config-reader';\n\nif (Platform.OS === 'ios') {\n  const iosBundleDisplayName = RNConfigReader.CFBundleDisplayName;\n  const testConfigValue = RNConfigReader.TEST_CONFIG_FIELD;\n}\n\nif (Platform.OS === 'android') {\n  const androidApplicationID = RNConfigReader.applicationId;\n  const testConfigValue = RNConfigReader.TEST_CONFIG_FIELD;\n}\n```\n\n## Manual installation\n\n### iOS\n\n1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`\n2. Go to `node_modules` ➜ `react-native-config-reader` and add `RNConfigReader.xcodeproj`\n3. In XCode, in the project navigator, select your project. Add `libRNConfigReader.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`\n4. Run your project (`Cmd+R`)\n\n### Android\n\n1. Open up `android/app/src/main/java/[...]/MainApplication.java`\n\n  - Add `import com.reactlibrary.RNConfigReaderPackage;` to the imports at the top of the file\n  - Add `new RNConfigReaderPackage()` to the list returned by the `getPackages()` method\n\n1. Append the following lines to `android/settings.gradle`:\n\n   ```gradle\n   include ':react-native-config-reader'\n   project(':react-native-config-reader').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config-reader/android')\n   ```\n\n1. Insert the following lines inside the dependencies block in `android/app/build.gradle`:\n\n```gradle\ncompile project(':react-native-config-reader')\n```\n\n#### Android advanced configurations with Multiple environments\n\nIf your app uses an `applicationIdSuffix` or a different `applicationId` depending on the build variants, you must append the following line inside the `buildTypes` block in your `android/app/build.gradle` file and specify your new package name.\n\n```gradle\n  resValue \"string\", \"rn_config_reader_custom_package\", \"com.yourNewPackage\"\n```\n\nExample\n\n```gradle\nbuildTypes {\n  ...\n  debug {\n    ...\n    applicationIdSuffix \".dev\"\n    resValue \"string\", \"rn_config_reader_custom_package\", \"com.yourNewPackage\"\n  }\n}\n```\n\n### Windows (Beta)\n\n🚨 When this project was first created in early 2019, it offered support for a beta version of [React Native for Windows](https://github.com/microsoft/react-native-windows).  Since this time, many updates have been published to both `react-native` and `react-native-windows`, with no active updates in this project to ensure compatibility.\n\n🙏 If you're interested in using this library with `react-native-windows`, and can offer assistance maintaining it, please reach out to the maintainers by filing an issue.\n\n1. In Visual Studio add the `RNConfigReader.sln` in `node_modules/react-native-config-reader/windows/RNConfigReader.sln` folder to their solution, reference from their app.\n\n1. Open up your `MainPage.cs` app\n\n  - Add `using Config.Reader.RNConfigReader;` to the usings at the top of the file\n  - Add `new RNConfigReaderPackage()` to the `List\u003cIReactPackage\u003e` returned by the `Packages` method\n\n## Troubleshooting\n\n### Problems with Proguard\n\nWhen Proguard is enabled (which it is by default for Android release builds), it can rename the BuildConfig Java class in the minification process and prevent `react-native-config-reader` from referencing it. To avoid this, add an exception to android/app/proguard-rules.pro:\n\n`-keep class com.yourNewPackage.BuildConfig { *; }`\n\ncom.yourNewPackage should match the package value in your app/src/main/AndroidManifest.xml file.\n\nIf using Dexguard, the shrinking phase will remove resources it thinks are unused. It is necessary to add an exception to preserve the build config package name.\n\n`-keepresources string/rn_config_reader_custom_package`\n\n## License\n\nMIT License\n\nCopyright (c) 2019 Chanaka Athurugiriya\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsath%2Freact-native-config-reader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsath%2Freact-native-config-reader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsath%2Freact-native-config-reader/lists"}