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

ReactNativeConfig.h name collision w/ React Native 0.68 iOS #667

Closed
jeremy303 opened this issue Jun 27, 2022 · 12 comments · Fixed by #724
Closed

ReactNativeConfig.h name collision w/ React Native 0.68 iOS #667

jeremy303 opened this issue Jun 27, 2022 · 12 comments · Fixed by #724

Comments

@jeremy303
Copy link

React Native 0.68 iOS introduces <react/config/ReactNativeConfig.h> in AppDelegate.mm as part of optional new-architecture support, conflicting with react-native-config's ReactNativeConfig.h.

It seems the docs should be updated to make it clear these are different classes and provide an example of how to work around the name collision.

Thanks!

@romainbriand
Copy link

@HolySamosa have you found any solution?

@Miyagee
Copy link

Miyagee commented Jul 11, 2022

Having the same issue. Seems like either this library have to rename the class or RN have to rename the class 🤔

@romainbriand
Copy link

Having the same issue. Seems like either this library have to rename the class or RN have to rename the class 🤔

Unfortunately, I had to disable the "native" usage of this lib and hard-coded some values in the native part of app (for our iOS Widget) 😢

Not an expert on this topic but I think the problem comes from this mechanism:

Name conflicts between dynamic shared libraries are not discovered at compile time, link time, or runtime. The dlsym function uses string matching to find symbols. If two libraries use the same name for a function, the dynamic loader returns the first one that matches the symbol name given to dlsym.

https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryUsageGuidelines.html#//apple_ref/doc/uid/TP40001928-SW9

Without being 100% sure, I guess the author here should probably "alias" the class. I guess the package is not named properly since the origin:

A good way to solve collision problems in Objective-C is adopt a prefix to differentiate your class name from other class names, and this is the technique already used by Apple itself, lets think about the array class, it is called NSArray [...]
https://stackoverflow.com/a/12880582

Or maybe move the library to Swift, which supports namespacing :)

I wish I had skills to offer a fix!

@sagark1510
Copy link

@pedro @luancurti any solution for this. I can't build my app due this on 0.69.1

@zrg-team
Copy link

zrg-team commented Aug 4, 2022

the error still there

Cordobo pushed a commit to Cordobo/react-native-config that referenced this issue Aug 12, 2022
@exs6350
Copy link

exs6350 commented Aug 30, 2022

There is no fix unless you fork this and rename. The author will need to rename the package/podspec because of the name clash with newer versions of react which introduced a "ReactNativeConfig" package in 0.68 and higher.

@luancurti
Copy link
Collaborator

Feel free to make a pull request @exs6350 with this solution

@philpettican118
Copy link
Contributor

Hi @luancurti , if we need to rename the package/podspec to fix the issue, do you have any preferences what the new package should be called?

@jeremy303
Copy link
Author

Sorry, I thought I had long ago replied with my work around. In my case, I've opted out of the "new architecture" for the time being, and I commented out all code in the RCT_NEW_ARCH_ENABLED code blocks.

Also, regarding preferences for the new name, might I suggest TheRealReactNativeConfig. ;-)

@jeremy303
Copy link
Author

My poor attempt at humor aside, Apple recommends using 3 letter prefixes for class names.

So RNC as a prefix seems to be a natural choice.

@philpettican118 @luancurti

@philpettican118
Copy link
Contributor

@pedro @luancurti please see PR changes. I added an example 0.68.5 project for Android and iOS which seem to work as expected. I don't have access to windows though so I haven't added an example project or been able to test on windows.

@jeremy303
Copy link
Author

This is so awesome. Thanks @philpettican118, for your great work! 🍺

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

Successfully merging a pull request may close this issue.

8 participants