jpudysz / react-native-unistyles

Level up your React Native StyleSheet
https://unistyl.es
MIT License
1.55k stars 42 forks source link

fix: build fail on Android, cast float to double - support React Native 0.72 #270

Closed LeeMoonki closed 2 months ago

LeeMoonki commented 2 months ago

Summary

Hello, thank you very much for creating such a great open-source project. I installed version 2.9.1 to use react-native-unistyles. However, I encountered the following error while building the Android app.

[1/7] Building CXX object CMakeFiles/unistyles.dir/src/main/cxx/helpers.cpp.o
[2/7] Building CXX object CMakeFiles/unistyles.dir/.../node_modules/react-native-unistyles/cxx/UnistylesRuntime.cpp.o
[3/7] Building CXX object CMakeFiles/unistyles.dir/.../node_modules/react-native-unistyles/cxx/UnistylesModel.cpp.o
[4/7] Building CXX object CMakeFiles/unistyles.dir/.../node_modules/react-native-unistyles/cxx/UnistylesImpl.cpp.o
FAILED: CMakeFiles/unistyles.dir/.../node_modules/react-native-unistyles/cxx/UnistylesImpl.cpp.o

.gradle/caches/transforms-3/ef2d7697779c544a76e341d3d27be809/transformed/jetified-react-android-0.72.6-debug/prefab/modules/jsi/include/jsi/jsi.h:1102:43: error: no matching function for call to 'kindOf'
  /* implicit */ Value(T&& other) : Value(kindOf(other)) {
                                          ^~~~~~

error: static_assert failed due to requirement 'std::is_base_of<facebook::jsi::Symbol, float>::value || std::is_base_of<facebook::jsi::BigInt, float>::value || std::is_base_of<facebook::jsi::String, float>::value || std::is_base_of<facebook::jsi::Object, float>::value' "Value cannot be implicitly move-constructed from this type"
.gradle/caches/transforms-3/ef2d7697779c544a76e341d3d27be809/transformed/jetified-react-android-0.72.6-debug/prefab/modules/jsi/include/jsi/jsi.h:1102:43: error: no matching function for call to 'kindOf'
/node_modules/react-native-unistyles/cxx/UnistylesImpl.cpp:237:12: note: in instantiation of function template specialization 'facebook::jsi::Value::Value<float>' requested here
.gradle/caches/transforms-3/ef2d7697779c544a76e341d3d27be809/transformed/jetified-react-android-0.72.6-debug/prefab/modules/jsi/include/jsi/jsi.h:1350:30: note: candidate function not viable: no known conversion from 'float' to 'const facebook::jsi::Symbol' for 1st argument
.gradle/caches/transforms-3/ef2d7697779c544a76e341d3d27be809/transformed/jetified-react-android-0.72.6-debug/prefab/modules/jsi/include/jsi/jsi.h:1353:30: note: candidate function not viable: no known conversion from 'float' to 'const facebook::jsi::BigInt' for 1st argument
.gradle/caches/transforms-3/ef2d7697779c544a76e341d3d27be809/transformed/jetified-react-android-0.72.6-debug/prefab/modules/jsi/include/jsi/jsi.h:1356:30: note: candidate function not viable: no known conversion from 'float' to 'const facebook::jsi::String' for 1st argument
.gradle/caches/transforms-3/ef2d7697779c544a76e341d3d27be809/transformed/jetified-react-android-0.72.6-debug/prefab/modules/jsi/include/jsi/jsi.h:1359:30: note: candidate function not viable: no known conversion from 'float' to 'const facebook::jsi::Object' for 1st argument

So, I successfully built the project after modifying react-native-unistyles/cxx/UnistylesImpl.cpp as requested. I'm not sure why the implicit conversion fails, but there are no functional issues. I’m submitting this PR because other users might encounter the same problem.

vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-unistyles-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 28, 2024 6:05am
jpudysz commented 2 months ago

That's interesting! What's your RN version?

LeeMoonki commented 2 months ago

@jpudysz The version of react-native is 0.72.6. However, since the relevant code in the latest version of react-native is identical to that in version 0.72.6, I believe that the issue could also occur in the current version of React Native.

jpudysz commented 2 months ago

Were you able to compile it with 0.72? 😮 I thought that the minimal version is 0.73!

If that's the only change to compile I will accept this PR

LeeMoonki commented 2 months ago

@jpudysz When we initially created the app we're currently managing in-house, the version was 0.72, and there hasn't been any version change since then. I've confirmed that there won't be any issues with compilation as long as the requested changes are made. 🤓

jpudysz commented 2 months ago

Cool, thank you for the PR!

LeeMoonki commented 2 months ago

@jpudysz I should be the one thanking you for the quick response and implementation! 😁

jpudysz commented 2 months ago

Will release it later this week with some other minor improvements!

For now please keep your local changes 🙏

LeeMoonki commented 2 months ago

Will release it later this week with some other minor improvements!

For now please keep your local changes 🙏

ok ! thanks :)