Hello, I’m now trying to port @babylonjs/react-native-windows
to React Native’s New Architecture.
I successfully migrated my @babylonjs/react-native-macos
to New arch with very little modification and no errors, but at this time, Windows part is making some trouble.
What I did for migrating is:
- Made a React Native new arch app named
Playground
and place it to...\BabylonReactNative\Apps\Playground\0.74\
- Modified
...\BabylonReactNative\Apps\Playground\0.74\scripts\version.js
to support v0.74 - Modified
...\BabylonReactNative\Package\gulpfile.js
fromVisual Studio 16 2019
toVisual Studio 17 2022
- Modified
winrt::Windows::UI::Xaml
towinrt::Microsoft::UI::Xaml
at several files - Then made a package by following Github Readme
When I copied pacakge assets generated by npx gulp packUWP
to my newly created test app and ran, these error occured:
7>BabylonModule.obj : error LNK2019: unresolved external symbol "void __cdecl BabylonNative::Initialize(class facebook::jsi::Runtime &,class std::function<void __cdecl(class std::function<void __cdecl(void)>)>)" (?Initialize@Babylon
Native@@YAXAEAVRuntime@jsi@facebook@@V?$function@$$A6AXV?$function@$$A6AXXZ@std@@@Z@std@@@Z) referenced in function "public: __cdecl `public: void __cdecl winrt::BabylonReactNative::implementation::BabylonModule::CustomInitiali
ze(struct winrt::Microsoft::ReactNative::ReactPromise<bool> const &)'::`2'::<lambda_1>::operator()(class facebook::jsi::Runtime &)const " (??R<lambda_1>@?1??CustomInitialize@BabylonModule@implementation@
BabylonReactNative@winrt@@QEAAXAEBU?$ReactPromise@_N@ReactNative@Microsoft@5@@Z@QEBA@AEAVRuntime@jsi@facebook@@@Z)[C:\Users\jihoobyeon\Desktop\retry\node_modules\@babylonjs\reac
t-native-windows\windows\BabylonReactNative\BabylonReactNative.vcxproj]
7>BabylonModule.obj : error LNK2019: unresolved external symbol "void __cdecl BabylonNative::ResetView(void)" (?ResetView@BabylonNative@@YAXXZ) referenced in function "public: __cdecl `public: void __cdecl winrt::BabylonReactNative::implementation::Babylon
Module::ResetView(struct winrt::Microsoft::ReactNative::ReactPromise<bool> const &)'::`2'::<lambda_1>::operator()(void)const " (??R<lambda_1>@?1??ResetView@BabylonModule@implementation@BabylonReactNative
@winrt@@QEAAXAEBU?$ReactPromise@_N@ReactNative@Microsoft@5@@Z@QEBA@XZ) [C:\Users\jihoobyeon\Desktop\retry\node_modules\@babylonjs\react-native-windows\windows\BabylonReactNative\
BabylonReactNative.vcxproj]
7>EngineView.obj : error LNK2019: unresolved external symbol "void __cdecl BabylonNative::UpdateView(struct winrt::Microsoft::UI::Xaml::Controls::SwapChainPanel,unsigned __int64,unsigned __int64)" (?UpdateView@BabylonNative@@YAXUSwa
pChainPanel@Controls@Xaml@UI@Microsoft@winrt@@_K1@Z) referenced in function "private: void __cdecl winrt::BabylonReactNative::implementation::EngineView::OnSizeChanged(struct winrt::Windows::Foundation::IInspectable const &,str
uct winrt::Microsoft::UI::Xaml::SizeChangedEventArgs const &)" (?OnSizeChanged@EngineView@implementation@BabylonReactNative@winrt@@AEAAXAEBUIInspectable@Foundation@Windows@4@AEBUSizeChangedEventArgs@Xaml
@UI@Microsoft@4@@Z)[C:\Users\jihoobyeon\Desktop\retry\node_modules\@babylonjs\react-native-windows\windows\BabylonReactNative\BabylonReactNative.vcxproj]
7>EngineView.obj : error LNK2019: unresolved external symbol "void __cdecl BabylonNative::UpdateMSAA(unsigned char)" (?UpdateMSAA@BabylonNative@@YAXE@Z) referenced in function "public: void __cdecl winrt::BabylonReactNative::implementation::EngineView::Upd
ateProperties(struct winrt::Microsoft::ReactNative::IJSValueReader const &)" (?UpdateProperties@EngineView@implementation@BabylonReactNative@winrt@@QEAAXAEBUIJSValueReader@ReactNative@Microsoft@4@@Z)[C:\Users\jihoobyeon\Desktop\retry\node_modules\@babylonjs\react-native-windows\windows\BabylonReactNative\BabylonReactNative.vcxproj]
7>EngineView.obj : error LNK2019: unresolved external symbol "void __cdecl BabylonNative::UpdateAlphaPremultiplied(bool)" (?UpdateAlphaPremultiplied@BabylonNative@@YAX_N@Z) referenced in function "public: void __cdecl winrt::BabylonReactNative::implementat
ion::EngineView::UpdateProperties(struct winrt::Microsoft::ReactNative::IJSValueReader const &)" (?UpdateProperties@EngineView@implementation@BabylonReactNative@winrt@@QEAAXAEBUIJSValueReader@ReactNative
@Microsoft@4@@Z)[C:\Users\jihoobyeon\Desktop\retry\node_modules\@babylonjs\react-native-windows\windows\BabylonReactNative\BabylonReactNative.vcxproj]
7>EngineView.obj : error LNK2019: unresolved external symbol "void __cdecl BabylonNative::RenderView(void)" (?RenderView@BabylonNative@@YAXXZ) referenced in function "private: void __cdecl winrt::BabylonReactNative::implementation::EngineView::OnRendering(
void)" (?OnRendering@EngineView@implementation@BabylonReactNative@winrt@@AEAAXXZ) [C:\Users\jihoobyeon\Desktop\retry\node_modules\@babylonjs\react-native-windows\windows\BabylonR
eactNative\BabylonReactNative.vcxproj]
I guess BabylonReactNative.vcxproj
is unable to find ...\node_modules\@babylonjs\react-native-windows\windows\libs\*.lib
,
since I have tried these workarounds:
- Merging
BabylonNative.cpp
toBabylonNative.h
→ This leads toUnable to find file <Babylon/**/*.h>
- Then writing directly
#pragma comment(lib, "*.lib")
topch.h
→ This returns toLNK2019
error - Moving all header files manually to
...\node_modules\@babylonjs\react-native\shared\
folder
→ This leads to<napi/napi.h>
or else external header not found
So I’m still finding linking *.lib
files properly to the project…
ping @Cedric - who made most of recent commits for Babylon React Native