react-native-unity-view
react-native-unity-view copied to clipboard
iOS build crash
Hi, when i try to run the example on this repo and even with another unity project, i get this build error in xcode
Undefined symbols for architecture arm64: "_onUnityMessage", referenced from: _UnityMessageManager_onUnityMessage_m8A904C01129EA827FDD76B08B34FAF9A6C4B5E36 in Assembly-CSharp.o (maybe you meant: _UnityMessageManager_onUnityMessage_m8A904C01129EA827FDD76B08B34FAF9A6C4B5E36) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
i've done correctly all the steps, i'm on unity 2019.3.0f6. Any idea how to solve this problem?
You must export project by using the build script of asmadsen. It will inject _onUnityMessage function to an .c file (i cant remember the name) of unityframework
I'm getting the same error. When you say "export project by using the build script of asmadsen" do you mean using the ReactNative/Export IOS option in Unity? If so, that's what I'm doing but still having this problem. I searched all the sources in my project (including the Pods and exported Unity project) and I'm not seeing the definition of onUnityMessage anywhere. Where exactly should it be defined?
I'm still trying to get my head around the codebase but I see that @asmadsen removed onUnityMessage from the iOS sources (https://github.com/asmadsen/react-native-unity-view/commit/05ab481f407e569ee2a3e78f646b67cf466528dc#diff-a9497c27e0f7d865a4cd461b56624e78L159). Was this a mistake or is the function supposed to be linked in from somewhere else?
If you look at the XCodePostBuild.cs file, you will see at line 187 that injects the UnityAppController.mm file onUnityMessage function.
This is the onUnityMessage function in the UnityAppController.mm file after successful export:
@matthewgertner
When you say "export project by using the build script of asmadsen" do you mean using the ReactNative/Export IOS option in Unity?
Yes.
Hi, sorry for not responding.
I belive that onUnityMessage was removed because of some issues with Unity not being able to send messages exactly once to ReactNative. The development got halted because of changes in functionality that didn't need it. But I have some uncommitted changes that might work, I will try it out and get back to you.
Thanks, @asmadsen. Is there some obvious workaround to get it to build in the meantime? I guess I can just patch the package locally if there's no better way.
@matthewgertner Are you trying to run the application on a physical device? Because the simulator usually has a lot of issues, so trying to run it on a physical device might be easier
@asmadsen I was trying to archive it so I can upload it to TestFlight for testing. I did actually manage to get it to run on my device so you're probably right about that being easier. But I have to admit I can't understand why I didn't get the same linker error since presumably that missing function would be as issue when building for the device as well.
I don't have any problem with archiving an app.
What you can do, is check if the PostExport hook in Unity has been run. Just check if the file ios/UnityExport/classes/UnityAppController.mm contains // Added by https://github.com/asmadsen/react-native-unity-view anywhere.
There seems to be an issue with Unity not running the PostExport hook I haven't found any better solution than to delete the UnityExport folder and re exporting the project from Unity
@asmadsen I believe I figured this out. Not sure if this is something anyone else is experiencing but we had the .meta files for your build scripts checked into our repo. Seems like that prevented them from running correctly. When I deleted them and let Unity regenerate them, it started injecting the onUnityMessage as expected.
Totally strange BTW since it looks like the .meta files it generated are exactly the same as the ones in the repo. But somehow when I deleted them and let Unity regenerate them it magically started working.
Hello All, I get error : diff: /Podfile.lock: No such file or directory diff: /Manifest.lock: No such file or directory error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation. when tried config UnityConfig.xcconfig in Configurations.
Any solution help me?
Hello All, I get error : diff: /Podfile.lock: No such file or directory diff: /Manifest.lock: No such file or directory error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation. when tried config UnityConfig.xcconfig in Configurations.
Any solution help me?
Have you tried installing react native unity view module and running the pod install command in xcode?
Hi hanthuyen8, Thanks for reply, I had install react native unity view module, but only use react-native link module.
Hi hanthuyen8, Thanks for reply, I had install react native unity view module, but only use react-native link module.
So have you tried running the pod install command?
Yes, i did
Yes, i did
Well, I think the problem lies in the pod. I think you try removing the pod, removing react-native unity view and reinstalling it.
Hi, Do you have sample, I tried download demo and run but not luck
Hi, Do you have sample, I tried download demo and run but not luck
Sorry, the whole source code for all react-native has been on my company computer. I only have unity export for ios. Give it a try. https://dtpeducationvn-my.sharepoint.com/:u:/g/personal/nhannh_dtp-education_com/EcW8xT0FMMJIlRy6nbRmSWkBZfk5s2Aa7MxGlpVaNoty5g?e=PvmC0J
ok Thank you so much
@asmadsen I believe I figured this out. Not sure if this is something anyone else is experiencing but we had the
.metafiles for your build scripts checked into our repo. Seems like that prevented them from running correctly. When I deleted them and let Unity regenerate them, it started injecting theonUnityMessageas expected.
Hi! Where are those files located? the .meta files
@asmadsen I believe I figured this out. Not sure if this is something anyone else is experiencing but we had the
.metafiles for your build scripts checked into our repo. Seems like that prevented them from running correctly. When I deleted them and let Unity regenerate them, it started injecting theonUnityMessageas expected.
Hello, I just tried your solution of deleting the .meta files for the iOS build and it finally worked, however I do not see the messages on the console. The game has a button to test communication and it works fine on Android, I can see the messages in the console but with iOS they don't show up, any ideas?
@matthewgertner hello mate, what's the folder of these .meta files?
Thanks for your help!
In the xcodepostbuild.cs replace
#if UNITY_IOS with
#if UNITY_ANDROID #else
This really fixed the problem for me.I think it has something to do with unity not compiling #if UNITY_IOS statement for some reason and all the commands in the xcodepostbuild.cs are not executed.Changing the if statement worked for me
In the xcodepostbuild.cs replace
#if UNITY_IOS with
#if UNITY_ANDROID #else
This really fixed the problem for me.I think it has something to do with unity not compiling #if UNITY_IOS statement for some reason and all the commands in the xcodepostbuild.cs are not executed.Changing the if statement worked for me
can you send example of code or screenshot?