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

iOS: Undefined symbols for architecture arm64 in ___lunar_console_destroy #184

Open
fknr opened this issue Nov 10, 2020 · 8 comments
Open

Comments

@fknr
Copy link

fknr commented Nov 10, 2020

We recently updated from 1.6.2 to 1.8.0 and after that we noticed that sometimes our ios builds fail with this error message:

[12:49:42]: ▸ �[35m�[33m⚠️ ld: arm64 function not 4-byte aligned: _unwind_tester from /Users/macmini22/jenkins/workspace/tend_Frontend-multibranch_master/frontend/BuildPipeline/builds/ios/Libraries/libiPhone-lib.a(unwind_test_arm64.o)�[0m
[12:49:44]: ▸ �[35m�[31m❌ Undefined symbols for architecture arm64�[0m
[12:49:44]: ▸ �[35m> Symbol: ___lunar_console_destroy�[0m
[12:49:44]: ▸ �[35m> Referenced from: _PlatformIOS___lunar_console_destroy_mD0698819CB28342B7F21B9CCDC0DF4DBCB3797E4 in LunarConsole.o�[0m
[12:49:47]: ▸ �[35m�[31m❌ ld: symbol(s) not found for architecture arm64�[0m
[12:49:47]: ▸ �[35m�[31m❌ clang: error: linker command failed with exit code 1 (use -v to see invocation)�[0m

The strange thing is that in most in most of the builds it works and also building the same code again fixes the issue.
We are on Unity 2019.4.13f1 and build with XCode 12.1 (also happened on 11.3.x before)

@weeeBox
Copy link
Member

weeeBox commented Nov 11, 2020

Hey @fknr, can you check if lunar_unity_native_interface.m file is included in your Xcode project?

@hfarrow
Copy link

hfarrow commented Feb 10, 2021

I experience a similar problem intermittently with both 1.6.1 and 1.8.1. It's relatively rare but it seems that the Xcode project is not modified to include LunarConsole files.

I don't have an example in front of me but going from memory, if you look in Xcode at the LunarConsole folder it's empty. I usually delete the Xcode project, and rebuild from Unity to fix it. I've been meaning to snoop around the build code but haven't had time so far.

@weeeBox
Copy link
Member

weeeBox commented Feb 11, 2021

Yes, I have seen it myself before. Not sure about the best solution at this point. One of the possible ways might be to forcibly update the Xcode project on every build.

@idbrii
Copy link

idbrii commented Feb 24, 2021

FYI, I had similar errors on LunarConsole 1.8.1 and Unity 2019.4.7 and I did not have lunar_unity_native_interface.m in my Xcode project.

Undefined symbols for architecture arm64:
  "___lunar_console_destroy", referenced from:
      _PlatformIOS___lunar_console_destroy_mD0698819CB28342B7F21B9CCDC0DF4DBCB3797E4 in LunarConsole.o
      _PlatformIOS_Destroy_m9A947243D241014A09E4F7B860D28C161B0B172E in LunarConsole.o
     (maybe you meant: _PlatformIOS___lunar_console_destroy_mD0698819CB28342B7F21B9CCDC0DF4DBCB3797E4)
  "___lunar_console_action_unregister", referenced from:
      _PlatformIOS___lunar_console_action_unregister_mF2271A0C4E29AC18C67D4162405C7986F512B53E in LunarConsole.o
      _PlatformIOS_OnActionUnregistered_mA795A6E80A8B1866AC32AA2809B20D7BF68BDAF0 in LunarConsole.o
     (maybe you meant: _PlatformIOS___lunar_console_action_unregister_mF2271A0C4E29AC18C67D4162405C7986F512B53E)
...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I didn't have any luck trying to fix it after several attempts of deleting my build output directory, flipping the LUNAR_CONSOLE_EXPORT_IOS_FILES define, and messing with plugin import settings. But then when I reverted all my changes, defined LUNAR_CONSOLE_EXPORT_IOS_FILES, deleted my build output directory again, and restarted Unity it built correctly.

Restarting Unity seems to be the new link in the chain, so maybe if anyone else is encountering this issue, try that.

@AntonPetrov83
Copy link

AntonPetrov83 commented Mar 8, 2021

Hi, I have this issue in my CI setup.

This code is not executed because UNITY_IOS is not defined if the current platform is not the iOS:

#if UNITY_IOS || UNITY_IPHONE
        [PostProcessBuild(1000)]
        static void OnPostprocessBuild(BuildTarget target, string buildPath)
        {
            if (LunarConsoleConfig.consoleEnabled)
            {
                if (target == BuildTarget.iOS)
                {
                    OnPostprocessIOS(buildPath);
                }
            }
        }

When building from a script the current platform is switched when you invoke BuildPipeline.BuildPlayer(). So when you build Android you have your code compiled with Android as the current platform and this code is not there yet. So if you start building iOS next then this code won't execute. It will be executed on the next run after the current platform is switched to iOS.

See this issue: https://issuetracker.unity3d.com/issues/unity-ios-is-defined-and-the-post-processing-code-using-unityeditor-dot-ios-dot-xcode-is-called-only-then-if-ios-is-the-active-platform

In my case it was okay to remove those directives because I am forced to have Android and iOS support installed everywhere.

@hfarrow
Copy link

hfarrow commented Mar 8, 2021

Interesting, I'm pretty sure I have had my active platform set to iOS before running a build, even when building from a script and still ran into this problem. I'll see if that is the case the next time I hit the problem.

Our build script only builds the active target. I'll also add a log statement to trust function so I can see if ran after a failed build.

@AntonPetrov83
Copy link

AntonPetrov83 commented Mar 8, 2021

Interesting, I'm pretty sure I have had my active platform set to iOS before running a build, even when building from a script and still ran into this problem. I'll see if that is the case the next time I hit the problem.

Our build script only builds the active target. I'll also add a log statement to trust function so I can see if ran after a failed build.

I think we can reproduce it in the editor: switch to non-iOS platform in Build Settings then execute an iOS build from the script through MenuItem.

@hfarrow
Copy link

hfarrow commented Mar 8, 2021

It makes sense now. I realized my build script will silently switch to iOS or Android targets if the active target is Standalone.

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

5 participants