diff --git a/android/build/generated/source/codegen/jni/CMakeLists.txt b/android/build/generated/source/codegen/jni/CMakeLists.txt deleted file mode 100644 index b8ca81aa..00000000 --- a/android/build/generated/source/codegen/jni/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Minimal stub CMakeLists for missing codegen outputs. -# This defines the react_codegen_RNCConfigModule target so native builds -# that expect generated code can link against a placeholder library. -cmake_minimum_required(VERSION 3.4.1) - -# Create a small static library with a trivial source file so CMake has a target to link. -add_library(react_codegen_RNCConfigModule STATIC "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp") - -# Expose the current source dir (if other CMake code expects include dirs) -target_include_directories(react_codegen_RNCConfigModule PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) - -# Prevent warnings when linked against: set an empty interface -target_compile_definitions(react_codegen_RNCConfigModule INTERFACE "REACT_NATIVE_CONFIG_STUB") diff --git a/android/build/generated/source/codegen/jni/empty.cpp b/android/build/generated/source/codegen/jni/empty.cpp deleted file mode 100644 index 772f76b7..00000000 --- a/android/build/generated/source/codegen/jni/empty.cpp +++ /dev/null @@ -1,2 +0,0 @@ -// Auto-generated stub file to satisfy CMake when real codegen output is not present. -extern "C" void __react_native_config_codegen_stub() {} diff --git a/index.js b/index.js index cdd5acfa..e398c70a 100644 --- a/index.js +++ b/index.js @@ -3,35 +3,8 @@ // Bridge to: // Android: buildConfigField vars set in build.gradle, and exported via ReactConfig // iOS: config vars set in xcconfig and exposed via RNCConfig.m -import { NativeModules, TurboModuleRegistry, Platform } from 'react-native'; +import { NativeModules } from 'react-native'; -// New-arch TurboModule name should match native module name -const TM_NAME = 'RNCConfigModule'; +export const Config = NativeModules.RNCConfigModule || {} -function getTurboModule() { - try { - if (TurboModuleRegistry?.get) { - return TurboModuleRegistry.get(TM_NAME); - } - } catch (_) {} - return null; -} - -const Turbo = getTurboModule(); -const Paper = NativeModules?.RNCConfigModule; - -let config = {}; -if (Turbo) { - // Prefer TM sync getAll when available to return a plain object - if (typeof Turbo.getAll === 'function') { - try { config = Turbo.getAll() || {}; } catch (_) { config = {}; } - } else { - config = Turbo; - } -} else if (Paper) { - config = Paper; -} - -export const Config = config; export default Config; - diff --git a/package.json b/package.json index 9fc87c63..723cad90 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-config", - "version": "1.5.8", + "version": "1.5.9", "description": "Expose config variables to React Native apps", "keywords": [ "env", @@ -42,7 +42,7 @@ "@types/jest": "^29.5.12" }, "dependencies": { - "@babel/core": "^7.25.2", + "@babel/core": "^7.25.2", "@babel/preset-env": "^7.25.0", "@babel/preset-react": "^7.24.7", "babel-jest": "^29.7.0"