react-native-unity-view icon indicating copy to clipboard operation
react-native-unity-view copied to clipboard

iOS build crash

Open fabioglimb opened this issue 5 years ago • 28 comments

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?

fabioglimb avatar Apr 07 '20 11:04 fabioglimb

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

hanthuyen8 avatar Apr 07 '20 11:04 hanthuyen8

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?

matthewgertner avatar Apr 13 '20 15:04 matthewgertner

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?

matthewgertner avatar Apr 13 '20 16:04 matthewgertner

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:

hanthuyen8 avatar Apr 13 '20 16:04 hanthuyen8

@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.

hanthuyen8 avatar Apr 13 '20 16:04 hanthuyen8

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.

asmadsen avatar Apr 13 '20 16:04 asmadsen

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 avatar Apr 14 '20 07:04 matthewgertner

@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 avatar Apr 16 '20 13:04 asmadsen

@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.

matthewgertner avatar Apr 16 '20 13:04 matthewgertner

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 avatar Apr 16 '20 14:04 asmadsen

@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.

matthewgertner avatar Apr 21 '20 14:04 matthewgertner

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.

matthewgertner avatar Apr 21 '20 14:04 matthewgertner

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?

dmobisoft avatar May 08 '20 15:05 dmobisoft

Screen Shot 2020-05-08 at 9 56 56 PM

dmobisoft avatar May 08 '20 15:05 dmobisoft

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?

hanthuyen8 avatar May 08 '20 15:05 hanthuyen8

Hi hanthuyen8, Thanks for reply, I had install react native unity view module, but only use react-native link module.

dmobisoft avatar May 08 '20 16:05 dmobisoft

Screen Shot 2020-05-08 at 11 25 17 PM

dmobisoft avatar May 08 '20 16:05 dmobisoft

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?

hanthuyen8 avatar May 08 '20 16:05 hanthuyen8

Yes, i did

dmobisoft avatar May 08 '20 17:05 dmobisoft

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.

hanthuyen8 avatar May 08 '20 17:05 hanthuyen8

Hi, Do you have sample, I tried download demo and run but not luck

dmobisoft avatar May 08 '20 17:05 dmobisoft

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

hanthuyen8 avatar May 08 '20 17:05 hanthuyen8

ok Thank you so much

dmobisoft avatar May 08 '20 18:05 dmobisoft

@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.

Hi! Where are those files located? the .meta files

ceyanesb avatar Feb 03 '21 01:02 ceyanesb

@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.

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?

Hyncha avatar Feb 03 '21 04:02 Hyncha

@matthewgertner hello mate, what's the folder of these .meta files?

Thanks for your help!

jdnichollsc avatar May 08 '21 17:05 jdnichollsc

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

nimiththomas avatar May 19 '21 16:05 nimiththomas

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?

antila3567 avatar Sep 27 '21 15:09 antila3567