mrousavy / nitro

🔥 Insanely fast native C++, Swift or Kotlin modules with a statically compiled binding layer to JSI
https://nitro.margelo.com
MIT License
598 stars 15 forks source link

Nitro 0.6 - Cannot default-construct HybridObject! #93

Closed jpudysz closed 2 months ago

jpudysz commented 2 months ago

Hey! After upgrading from v.0.5.0 to v.0.6.0, I can no longer construct my Hybrid that depends on another Cxx Hybrid

 auto nativePlatform = Unistyles::NativePlatform::create(); // cxx <-> swift hybrid
 auto unistylesRuntime = std::make_shared<HybridUnistylesRuntime>(nativePlatform); // <- crashes here

Error:

libc++abi: terminating due to uncaught exception of type std::runtime_error: Cannot default-construct HybridObject!

It would be great to still support that, as I don't want to expose NativePlatform to JS.

mrousavy commented 2 months ago

Sorry there was a breaking change in 0.6.0 which I needed for Android. All specs now virtually inherit from HybridObject, so you need to explicitly call it's constructor. That's all you need to change:

 class SomeHybrid: SomeHybridSpec {
-  SomeHybrid() {}
+  SomeHybrid(): HybridObject(TAG) {}
 }