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

Build error on 0.71.2: 'RNUltimateConfigSpec.h' file not found #130

Open
dennisvk001 opened this issue Feb 14, 2023 · 12 comments
Open

Build error on 0.71.2: 'RNUltimateConfigSpec.h' file not found #130

dennisvk001 opened this issue Feb 14, 2023 · 12 comments
Labels
question Further information is requested

Comments

@dennisvk001
Copy link

Hi,
I am having the next problem while building project with RN 0.71.2 (new architecture enabled ):

In file included from ..UltimateConfig.m:1:
..UltimateConfig.h:3:9: fatal error: 'RNUltimateConfigSpec.h' file not found

Ultimate Config Version: "6.0.0"

I didnt found this file in sources, so i suppose it was not generated.

@dennisvk001 dennisvk001 added the question Further information is requested label Feb 14, 2023
@vagnerlandio
Copy link
Contributor

Hi @dennisvk001 ,

I'll investigate the issue and work to solve the problem as soon as possible.

@DzmitryPlatonau
Copy link

Are there any updates here that have the same issue with RN 0.71.11 (new architecture included)?

@SukumarRN7
Copy link

Am facing the same issue with rn 72 (new architecture enabled)

@alexkev
Copy link

alexkev commented Dec 5, 2023

I am facing the same issue with 72 and the new architecture enabled.

@alexkev
Copy link

alexkev commented Dec 5, 2023

This seems to relate to Codegen process, but I could be wrong.

@zubko
Copy link

zubko commented Mar 6, 2024

Still happens with RN 73 and new architecture enabled.

"react-native-ultimate-config": "6.0.1"

@zubko
Copy link

zubko commented Mar 6, 2024

The Codegen part was missing. I did some quick exercise to add it.

I had to add the codegen section to package.json, add a minimal spec and change the source file from m to mm.

Here is the patch made with yarn patch .. which made it possible to compile the app. No warranty though, I'm touching these kind of new arch things for the first time:

diff --git a/ios/UltimateConfig.h b/ios/UltimateConfig.h
index 41ad9efb55a3fd96986a49ef9e369e5b6271e328..2c3004d99238d8a3c2dbcebdc63838cd068af46f 100644
--- a/ios/UltimateConfig.h
+++ b/ios/UltimateConfig.h
@@ -1,6 +1,6 @@

 #ifdef RCT_NEW_ARCH_ENABLED
-#import "RNUltimateConfigSpec.h"
+#import "RNUltimateConfig/RNUltimateConfig.h"

 @interface UltimateConfig : NSObject <NativeUltimateConfigSpec>
 #else
diff --git a/ios/UltimateConfig.m b/ios/UltimateConfig.m
deleted file mode 100644
index 7debfdff0402385a71111c72517799ec25128e8d..0000000000000000000000000000000000000000
--- a/ios/UltimateConfig.m
+++ /dev/null
@@ -1,26 +0,0 @@
-#import "UltimateConfig.h"
-#import "ConfigValues.h"
-
-@implementation UltimateConfig
-RCT_EXPORT_MODULE()
-
-+ (BOOL)requiresMainQueueSetup
-{
-    return YES;
-}
-
-- (NSDictionary *)constantsToExport
-{
-    return getValues();
-}
-
-// Don't compile this code when we build for the old architecture.
-#ifdef RCT_NEW_ARCH_ENABLED
-- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
-    (const facebook::react::ObjCTurboModule::InitParams &)params
-{
-    return std::make_shared<facebook::react::NativeUltimateConfigSpecJSI>(params);
-}
-#endif
-
-@end
diff --git a/ios/UltimateConfig.mm b/ios/UltimateConfig.mm
new file mode 100644
index 0000000000000000000000000000000000000000..7debfdff0402385a71111c72517799ec25128e8d
--- /dev/null
+++ b/ios/UltimateConfig.mm
@@ -0,0 +1,26 @@
+#import "UltimateConfig.h"
+#import "ConfigValues.h"
+
+@implementation UltimateConfig
+RCT_EXPORT_MODULE()
+
++ (BOOL)requiresMainQueueSetup
+{
+    return YES;
+}
+
+- (NSDictionary *)constantsToExport
+{
+    return getValues();
+}
+
+// Don't compile this code when we build for the old architecture.
+#ifdef RCT_NEW_ARCH_ENABLED
+- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
+    (const facebook::react::ObjCTurboModule::InitParams &)params
+{
+    return std::make_shared<facebook::react::NativeUltimateConfigSpecJSI>(params);
+}
+#endif
+
+@end
diff --git a/ios/UltimateConfig.xcodeproj/project.pbxproj b/ios/UltimateConfig.xcodeproj/project.pbxproj
index 9ec0fd89049bbcf2c75ca18cd7b489a06048ea11..ad1fec12fbc7d2d9020e98f9658ed9dd3df5fc80 100644
--- a/ios/UltimateConfig.xcodeproj/project.pbxproj
+++ b/ios/UltimateConfig.xcodeproj/project.pbxproj
@@ -7,7 +7,7 @@
 	objects = {

 /* Begin PBXBuildFile section */
-		5E555C0D2413F4C50049A1A2 /* UltimateConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* UltimateConfig.m */; };
+		5E555C0D2413F4C50049A1A2 /* UltimateConfig.mm in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* UltimateConfig.mm */; };
 /* End PBXBuildFile section */

 /* Begin PBXCopyFilesBuildPhase section */
@@ -25,7 +25,7 @@
 /* Begin PBXFileReference section */
 		134814201AA4EA6300B7C361 /* libUltimateConfig.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libUltimateConfig.a; sourceTree = BUILT_PRODUCTS_DIR; };
 		B3E7B5881CC2AC0600A0062D /* UltimateConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UltimateConfig.h; sourceTree = "<group>"; };
-		B3E7B5891CC2AC0600A0062D /* UltimateConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UltimateConfig.m; sourceTree = "<group>"; };
+		B3E7B5891CC2AC0600A0062D /* UltimateConfig.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UltimateConfig.mm; sourceTree = "<group>"; };
 /* End PBXFileReference section */

 /* Begin PBXFrameworksBuildPhase section */
@@ -51,7 +51,7 @@
 			isa = PBXGroup;
 			children = (
 				B3E7B5881CC2AC0600A0062D /* UltimateConfig.h */,
-				B3E7B5891CC2AC0600A0062D /* UltimateConfig.m */,
+				B3E7B5891CC2AC0600A0062D /* UltimateConfig.mm */,
 				134814211AA4EA7D00B7C361 /* Products */,
 			);
 			sourceTree = "<group>";
@@ -113,7 +113,7 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				B3E7B58A1CC2AC0600A0062D /* UltimateConfig.m in Sources */,
+				B3E7B58A1CC2AC0600A0062D /* UltimateConfig.mm in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/package.json b/package.json
index 6d116ba0f8e34c1671a75ef86df2627e46485892..2b03a617ba86f5caa128e0c96f1a4b5002ec2113 100644
--- a/package.json
+++ b/package.json
@@ -72,5 +72,13 @@
   "resolutions": {
     "logkitty": "^0.7.1",
     "lodash": "^4.17.19"
+  },
+  "codegenConfig": {
+    "android": {
+      "javaPackageName": "com.reactnativeultimateconfig"
+    },
+    "name": "RNUltimateConfig",
+    "type": "all",
+    "jsSrcsDir": "./src/specs"
   }
 }
diff --git a/src/specs/NativeUltimateConfig.js b/src/specs/NativeUltimateConfig.js
new file mode 100644
index 0000000000000000000000000000000000000000..15a3f85e9f77ed67c209272e140b8e71d04e0fa3
--- /dev/null
+++ b/src/specs/NativeUltimateConfig.js
@@ -0,0 +1,10 @@
+// @flow
+import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
+import {TurboModuleRegistry} from 'react-native';
+
+export interface Spec extends TurboModule {
+  getConstants: () => {||}
+}
+export default (TurboModuleRegistry.get<Spec>(
+  'RNUltimateConfig'
+): ?Spec);
\ No newline at end of file

But using of new architecture for such a simple native code is very questionable, imo. 🤔 Even with the new bridgeless mode of RN there is some emulation of old module system and for such a simple module which just returns constants there is no benefit of using JSI or having a delayed initialization of the module itself. I'd just remove the new arch things, if the package still compiles when the app has the new architecture enabled and the bridgeless mode turned on.

@joeldebont
Copy link

joeldebont commented Sep 16, 2024

@zubko Hello, I have followed the steps you have done and created a patch file after but now I get the error "cannot find file RNUltimateConfig/RNUltimateConfig.h" inside UltimateConfig.h.

Any suggestions? I don't really have experience in changing packages

@zubko
Copy link

zubko commented Sep 30, 2024

@zubko Hello, I have followed the steps you have done and created a patch file after but now I get the error "cannot find file RNUltimateConfig/RNUltimateConfig.h" inside UltimateConfig.h.

Any suggestions? I don't really have experience in changing packages

@joeldebont

Sorry to read this one didn't work straight. Maybe RN version is different or smth and now codegen is a bit different.

I stopped using new architecture on that project pretty soon - there were just too many random crashes. And I'm still on the old one everywhere, so I can't do a quick check. I'd check if another import would work - for example just RNUltimateConfig.h. I'd maybe opened Xcode and checked the Cocoa Pod for this library and checked what ended up in the import search path for that config. But it's maybe too much a new thing for you.

I would also try to remove all the new arch files from this library and make a patch for it. Maybe there is already some automatic "adaptor" to use an old arch library on a new arch project. I'm not aware of the status of this, if such thing was included already in a newer RN version. As I wrote - after a few initial configuration bumps and then some weird crashes deep inside the framework's native code I'm really not rushing towards the new arch. 🤷🏼‍♂️

But I keep using this package heavily, it's really much more superior to react-native-config in many subtle but important ways.

@Sky
Copy link

Sky commented Oct 21, 2024

This patch builds with RN 0.75.4.
With TurboModules it's not possible to read constants from module object as before.
Also generaly I am not sure why it's implemented by reading values from native context instead of just creating JS template as I added in this patch. All the native module part can go away then.

diff --git a/node_modules/react-native-ultimate-config/ios/UltimateConfig.m b/node_modules/react-native-ultimate-config/ios/UltimateConfig.mm
similarity index 100%
rename from node_modules/react-native-ultimate-config/ios/UltimateConfig.m
rename to node_modules/react-native-ultimate-config/ios/UltimateConfig.mm
diff --git a/node_modules/react-native-ultimate-config/react-native-ultimate-config.podspec b/node_modules/react-native-ultimate-config/react-native-ultimate-config.podspec
index 3421407..2f7d667 100644
--- a/node_modules/react-native-ultimate-config/react-native-ultimate-config.podspec
+++ b/node_modules/react-native-ultimate-config/react-native-ultimate-config.podspec
@@ -1,7 +1,6 @@
 require "json"
 
 package = JSON.parse(File.read(File.join(__dir__, "package.json")))
-folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
 
 Pod::Spec.new do |s|
   s.name         = "react-native-ultimate-config"
@@ -19,20 +18,9 @@ Pod::Spec.new do |s|
 
   s.source_files = "ios/**/*.{h,m,mm}"
 
-  s.dependency "React-Core"
-
-  # Don't install the dependencies when we run `pod install` in the old architecture.
-  if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
-    s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
-    s.pod_target_xcconfig    = {
-        "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
-        "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
-        "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
-    }
-    s.dependency "React-Codegen"
-    s.dependency "RCT-Folly"
-    s.dependency "RCTRequired"
-    s.dependency "RCTTypeSafety"
-    s.dependency "ReactCommon/turbomodule/core"
+  if defined? install_modules_dependencies
+    install_modules_dependencies(s)
+  else
+    s.dependency 'React-Core'
   end
 end
diff --git a/node_modules/react-native-ultimate-config/src/fabric/NativeUltimateConfig.ts b/node_modules/react-native-ultimate-config/src/fabric/NativeUltimateConfig.ts
new file mode 100644
index 0000000..2c4bb86
--- /dev/null
+++ b/node_modules/react-native-ultimate-config/src/fabric/NativeUltimateConfig.ts
@@ -0,0 +1,7 @@
+import type { TurboModule } from 'react-native'
+import { TurboModuleRegistry } from 'react-native'
+
+export interface Spec extends TurboModule {
+  readonly getConstants: () => {}
+}
+export default TurboModuleRegistry.getEnforcing<Spec>('UltimateConfig')
diff --git a/node_modules/react-native-ultimate-config/src/render-env.js b/node_modules/react-native-ultimate-config/src/render-env.js
index 6ea43b3..7c662e9 100644
--- a/node_modules/react-native-ultimate-config/src/render-env.js
+++ b/node_modules/react-native-ultimate-config/src/render-env.js
@@ -58,6 +58,7 @@ function render_template(template_name, data) {
 module.exports = function render_env(project_root, lib_root, env, rc) {
   const { ios, android, web } = env;
   const map = {
+    [path.join(lib_root, "index.js")]: render_template("index.js", ios),
     [path.join(lib_root, "index.d.ts")]: render_template("index.d.ts", ios),
     [path.join(lib_root, "index.web.js")]: render_template("index.web.js", web),
     [path.join(lib_root, "ios", `${code_file_name}.h`)]: render_template(
diff --git a/node_modules/react-native-ultimate-config/src/templates/index.js.handlebars b/node_modules/react-native-ultimate-config/src/templates/index.js.handlebars
new file mode 100644
index 0000000..5faac34
--- /dev/null
+++ b/node_modules/react-native-ultimate-config/src/templates/index.js.handlebars
@@ -0,0 +1,5 @@
+import override from "./override";
+
+const values = {{{toJSON @root}}}
+
+export default { ...values, ...override };
diff --git a/node_modules/react-native-ultimate-config/package.json b/node_modules/react-native-ultimate-config/package.json
index 6d116ba..bce6f0b 100644
--- a/node_modules/react-native-ultimate-config/package.json
+++ b/node_modules/react-native-ultimate-config/package.json
@@ -72,5 +72,13 @@
   "resolutions": {
     "logkitty": "^0.7.1",
     "lodash": "^4.17.19"
-  }
+  },
+  "codegenConfig": {
+     "name": "RNUltimateConfigSpec",
+     "type": "modules",
+     "jsSrcsDir": "./src/fabric",
+     "android": {
+       "javaPackageName": "com.reactnativeultimateconfig"
+     }
+   }
 }
\ No newline at end of file

@trinadhkoyainspire
Copy link

trinadhkoyainspire commented Oct 31, 2024

Is there any update on this issue? Are there any plans to migrate this library to support the new architecture?

@zubko
Copy link

zubko commented Nov 16, 2024

Hey, this is what I meant of rather removing any support of the new architecture so RN could apply some compatibility layer to it (hopefully). You could not say this lib doesn't support new architecture at all, it's just that the new arch config is a moving target and the config is outdated here.

I've tested this patch now with RN 76.2 and new architecture enabled.

react-native-ultimate-config+6.0.1.patch

... I wonder why does this lib need to pass the constants from the native layer to JS instead of just always generating them for the JS (like the override setting does or like it does for react-native-web case). Maybe some security considerations as it will be harder to get those values from native binaries than from the Hermes bundle. Otherwise, this all could be greatly simplified. We need these configs on the native side for sure, but I don't think we really need that connection between native and JS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

9 participants