Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined symbols for architecture arm64: "_onUnitySceneLoaded" #221

Closed
Kingtous opened this issue Oct 3, 2020 · 22 comments
Closed

Undefined symbols for architecture arm64: "_onUnitySceneLoaded" #221

Kingtous opened this issue Oct 3, 2020 · 22 comments

Comments

@Kingtous
Copy link

Kingtous commented Oct 3, 2020

using Flutter 1.22 stable and flutter-unity-view-widget 2.0.0+2.

I've no idea about the solution for iOS build.

the error shows below:

 ld: warning: arm64 function not 4-byte aligned: _unwind_tester from /Users/kingtous/projects/cishi-app/ios/UnityLibrary/Libraries/libiPhone-lib.a(unwind_test_arm64.o)
    Undefined symbols for architecture arm64:
      "_onUnitySceneLoaded", referenced from:
          _NativeAPI_onUnitySceneLoaded_m4741E4A6C2A3A84DC595DCA9E6715B0779372985 in Assembly-CSharp.o
         (maybe you meant: _NativeAPI_onUnitySceneLoaded_m4741E4A6C2A3A84DC595DCA9E6715B0779372985)
      "_onUnityMessage", referenced from:
          _NativeAPI_onUnityMessage_mD44345499E1125EA37D67E2892D48D89B448B012 in Assembly-CSharp.o
         (maybe you meant: _NativeAPI_onUnityMessage_mD44345499E1125EA37D67E2892D48D89B448B012)
    ld: symbol(s) not found for architecture arm64

Does this mean there's a problem in my unityLibrary?

@Kingtous
Copy link
Author

Kingtous commented Oct 3, 2020

the full log shows below:

Running pod install...
Running Xcode build...
Xcode build done.                                           14.5s
Failed to build iOS app
Error output from Xcode build:
↳
    2020-10-03 22:01:44.748 xcodebuild[5088:732449]  DTDeviceKit: deviceType from 2ea7bb242f78168621b05382a3cd2af4414df957 was NULL
    ** BUILD FAILED **


Xcode's output:

    ld: warning: arm64 function not 4-byte aligned: _unwind_tester from /Users/kingtous/projects/cishi-app/ios/UnityLibrary/Libraries/libiPhone-lib.a(unwind_test_arm64.o)
    Undefined symbols for architecture arm64:
      "_onUnitySceneLoaded", referenced from:
          _NativeAPI_onUnitySceneLoaded_m4741E4A6C2A3A84DC595DCA9E6715B0779372985 in Assembly-CSharp.o
         (maybe you meant: _NativeAPI_onUnitySceneLoaded_m4741E4A6C2A3A84DC595DCA9E6715B0779372985)
      "_onUnityMessage", referenced from:
          _NativeAPI_onUnityMessage_mD44345499E1125EA37D67E2892D48D89B448B012 in Assembly-CSharp.o
         (maybe you meant: _NativeAPI_onUnityMessage_mD44345499E1125EA37D67E2892D48D89B448B012)
    ld: symbol(s) not found for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

@juicycleff
Copy link
Owner

@Kingtous please clean your build properly and remove the unityframework from runner and add it again. Should fix it

@Antriadus
Copy link

Antriadus commented Oct 5, 2020

@juicycleff I've hot the same problem, and cleaning build and adding unityframework again did not repaired problem. For me changing Api Compability Level (in Unity Player Settings) from .Net Standard 2.0 to .NET 4.x repaired iOS build.

@Kingtous
Copy link
Author

Kingtous commented Oct 6, 2020

@Kingtous please clean your build properly and remove the unityframework from runner and add it again. Should fix it

not working. I'll try changing api compatibility level mentioned by @Antriadus then.

@Kingtous
Copy link
Author

Kingtous commented Oct 6, 2020

@juicycleff I've hot the same problem, and cleaning build and adding unityframework again did not repaired problem. For me changing Api Compability Level (in Unity Player Settings) from .Net Standard 2.0 to .NET 4.x repaired iOS build.

I've changed to .NET 4.x but it's not working, neither

@Kingtous
Copy link
Author

Kingtous commented Oct 6, 2020

DemoAPP from this repository also has this issue now. It seems that there is a bug when upgrading to iOS 14 SDK.
I was able to build it when I dev for iOS 13+.

@Kingtous
Copy link
Author

Kingtous commented Oct 6, 2020

finally I delete FlutterUnityIntegration in my unity project and reimport FlutterUnityPackage.unitypackage, which solveed my iOS build.

@artificerchris
Copy link

artificerchris commented Oct 7, 2020

Hey all, I'm having this issue too when running the build through my CI, manually editing the project at that point isn't really a viable solution. I tried toggling between different .net versions to no avail.

Edit: Just downloaded the example project and ran it too, it also fails with this same error.

@Kingtous
Copy link
Author

Kingtous commented Oct 9, 2020

Hey all, I'm having this issue too when running the build through my CI, manually editing the project at that point isn't really a viable solution. I tried toggling between different .net versions to no avail.

Edit: Just downloaded the example project and ran it too, it also fails with this same error.

try to what i have done.

@artificerchris
Copy link

artificerchris commented Oct 12, 2020

try to what i have done.

I have, none of those things work for me for iOS.

@juicycleff
Copy link
Owner

Will test and fix any issues in the example and also the unity package. But most times this is due to your ios project. Will update the project with a fix

@artificerchris
Copy link

I'm not sure if it's helpful, but the problem only started for me after the iOS 14 release. I have a machine that hasn't been upgraded yet an the same project builds on it fine, move the exact same files to the iOS 14 build tool machine and it fails.

@vertis
Copy link

vertis commented Nov 16, 2020

When reimporting the FlutterUnityIntegration I noticed that the meta files for NativeCallProxy.h and NativeCallProxy.mm were different. Re-importing did fix the problem for me.

Specifically:

--- a/Assets/FlutterUnityIntegration/Plugins/iOS/NativeCallProxy.h.meta
+++ b/Assets/FlutterUnityIntegration/Plugins/iOS/NativeCallProxy.h.meta
@@ -6,22 +6,81 @@ PluginImporter:
   iconMap: {}
   executionOrder: {}
   defineConstraints: []
-  isPreloaded: 0
+  isPreloaded: 1
   isOverridable: 0
   isExplicitlyReferenced: 0
   validateReferences: 1
   platformData:
+  - first:
+      : Any
+    second:
+      enabled: 0
+      settings:
+        Exclude Android: 1
+        Exclude Editor: 1
+        Exclude Linux64: 1
+        Exclude OSXUniversal: 1
+        Exclude Win: 1
+        Exclude Win64: 1
+        Exclude iOS: 0
+        Exclude tvOS: 0
+  - first:
+      Android: Android
+    second:
+      enabled: 0
+      settings:
+        CPU: ARMv7
   - first:
       Any:
     second:
-      enabled: 1
+      enabled: 0
       settings: {}
   - first:
       Editor: Editor
     second:
       enabled: 0
       settings:
+        CPU: AnyCPU
         DefaultValueInitialized: true
+        OS: AnyOS
+  - first:
+      Standalone: Linux64
+    second:
+      enabled: 0
+      settings:
+        CPU: AnyCPU
+  - first:
+      Standalone: OSXUniversal
+    second:
+      enabled: 0
+      enabled: 0
+      settings:
+        CPU: x86_64
+  - first:
+      Standalone: Win
+    second:
+      enabled: 0
+      settings:
+        CPU: x86
+  - first:
+      Standalone: Win64
+    second:
+      enabled: 0
+      settings:
+        CPU: x86_64
+  - first:
+      iPhone: iOS
+    second:
+      enabled: 1
+      settings:
+        AddToEmbeddedBinaries: false
+        CPU: AnyCPU
+        CompileFlags:
+        FrameworkDependencies:
+  - first:
+      tvOS: tvOS
+    second:
+      enabled: 1
+      settings: {}
   userData:
   assetBundleName:
   assetBundleVariant:

(With the + being the re-imported lines)

I'm not entirely certain how these came to be changed (did I do it while trying to build directly for testing, I don't remember).

YMMV of course.

@juicycleff
Copy link
Owner

Just reimport for unity for iOS removed unity framework and attach it again, solves this problem. It happens when the exported unity project native integration has changed and your project still references old files

@sandrush73
Copy link

Hi I have tried all the steps mentioned above and also tried using unity package FlutterUnityPackage-3.0.0.unitypackage but i still cant build
Undefined symbols for architecture arm64:
"__NativeShare_Share", referenced from:
_NativeShare__NativeShare_Share_mD7B457EC2F4BDC61F28DFF4BA10097FBB9575E50 in Assembly-CSharp-firstpass.o
(maybe you meant: _NativeShare__NativeShare_Share_mD7B457EC2F4BDC61F28DFF4BA10097FBB9575E50)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@andyshephard
Copy link

I had some unfortunate issues getting it to work by reimporting the project. It seemed to be because of the Cocoapod dependency, so in order to solve this I had to do the following (it's a bit long-winded but it worked):

  • Remove the Unity-iPhone.xcodeproj from my own project (Move to Trash).

  • Remove any lingering framework references from my project.

  • Comment out any flutter-unity-plugin code from my Xcode AND Flutter project.

  • Comment out the flutter-unity-plugin line in pubspec.yml and run 'pub get'.

  • Navigate to the 'ios' folder and run 'pod update' in order to ensure that the Cocoapod dependency was no longer present.

  • Reintroduce the flutter-unity-plugin in Flutter pubspec.yml and run 'pub get'.

  • Run 'pod install' in the 'ios' folder.

  • Re-create the UnityLibrary folder by running 'Export iOS' in Unity.

  • Add the Unity-iPhone.xcodeproj back to my project's xcworkspace.

  • Import the UnityFramework again by using the instructions in this repo's README.md

  • By this point you should be able to run the project in Xcode successfully.

  • Uncomment out all of the code in Flutter & Xcode so that it's making use of the flutter plugin.

  • Done.

@Ksen17
Copy link

Ksen17 commented May 26, 2021

No solution works for me

1 similar comment
@ernonemacher
Copy link

No solution works for me

@fch21
Copy link

fch21 commented Jun 17, 2021

This problem is caused by unity not using XCodePostBuild.cs, I could solve it by deleting this file and re-importing it into the unity project from the FlutterUnityIntegration-v4.1.0.unitypackage and then exporting the project to IOS again. If it doesn't work you can also try to delete the whole FlutterUnityIntegration folder and re-import the complete package.

@rzrobert
Copy link

Just reimport for unity for iOS removed unity framework and attach it again, solves this problem. It happens when the exported unity project native integration has changed and your project still references old files

Delete the file and re export the unity iPhone project, works for me

@TonyHoyleRps
Copy link
Contributor

2 years later and this bug is not fixed.. FFS. The 'solution' of editing files manually kind of works when you're developing, but it's a complete no go when compiling using CI. I've removed and readded both the FlutterUnityWidget and fuw projects (it's not clear which one is 'correct' but I've tried them all) loads of times. That is not a solution.

@g0josh
Copy link

g0josh commented Oct 13, 2023

If anyone is looking for solution to this, I had to remove the UNITY_IOS compile flag

  • around ExportAddressables(); at LearnItUnity/Assets/FlutterUnityIntegration/Editor/Build.cs:BuildIOS
  • LearnItUnity/Assets/FlutterUnityIntegration/Editor/XCodePostBuild.cs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests