XCode build fail when add Apple.GameKit plugin for Unity: Undefined symbol

I have a Unity project, after setting up Apple.Gamekit plugin, it show up some error when build with XCode:

ld: warning: arm64 function not 4-byte aligned: _unwind_tester from /Users/mac/Documents/Bonex/BoneX_demo1/iOSBuild_demo2/Libraries/libiPhone-lib.a(unwind_test_arm64.o)

Undefined symbols for architecture arm64:
  "_GKLocalPlayer_Authenticate", referenced from:

_GKLocalPlayer_GKLocalPlayer_Authenticate_mA13EED25E9E6BC8EAA0DE8E36D389AC904B41435 in Apple.GameKit.o

     (maybe you meant: _GKLocalPlayer_GKLocalPlayer_Authenticate_mA13EED25E9E6BC8EAA0DE8E36D389AC904B41435, _GKLocalPlayer_Authenticate_m3BBD62A177560D3F93691F97581B484A6EBA0836 )

  "_GKLocalPlayer_GetIsMultiplayerGamingRestricted", referenced from:

      _GKLocalPlayer_GKLocalPlayer_GetIsMultiplayerGamingRestricted_m347F15CBE262C877190B5C7F4B55AFAD595705D5 in Apple.GameKit.o

     (maybe you meant: _GKLocalPlayer_GKLocalPlayer_GetIsMultiplayerGamingRestricted_m347F15CBE262C877190B5C7F4B55AFAD595705D5)

  "_GKLocalPlayer_GetIsPersonalizedCommunicationRestricted", referenced from:

      _GKLocalPlayer_GKLocalPlayer_GetIsPersonalizedCommunicationRestricted_mB1E3D7AE957AAA19E6ABBDCDEAD9821B09EB1DC1 in Apple.GameKit.o

     (maybe you meant: _GKLocalPlayer_GKLocalPlayer_GetIsPersonalizedCommunicationRestricted_mB1E3D7AE957AAA19E6ABBDCDEAD9821B09EB1DC1)

  "_GKLocalPlayer_GetIsUnderage", referenced from:

      _GKLocalPlayer_GKLocalPlayer_GetIsUnderage_mF266E6F8AA10922F3B02ED3A877D3C403EA46045 in Apple.GameKit.o

     (maybe you meant: _GKLocalPlayer_GKLocalPlayer_GetIsUnderage_mF266E6F8AA10922F3B02ED3A877D3C403EA46045)

  "_NSError_Free", referenced from:

      _NSError_NSError_Free_m0AFB1ED4BF090D6E5276479A1F53680D4FD47A4A in Apple.Core.o

     (maybe you meant: _NSError_NSError_Free_m0AFB1ED4BF090D6E5276479A1F53680D4FD47A4A)

ld: symbol(s) not found for architecture arm64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

The plugin I added, which is provided by Apple: https://github.com/apple/unityplugins

My : build appunityplugin used 2020.3.33f1 XCode to version 14.3.1

Please help! Thank you!!!

Answered by gravity168 in 761270022

Hi, to anyone faces this error. I found a workaround to solve this problem. First off, there is a commit fix for the finding asset ".framework" if you are using unity 2022. https://github.com/makeplayhappy/appleunityplugins/blob/find_framework_fix/plug-ins/Apple.Core/Apple.Core_Unity/Assets/Apple.Core/Editor/AppleFrameworkUtility.cs

If you are still facing this issue then follow these steps: (Please check the images) 1: Check the Apple.Core and Apple.Gamekit under Packages folder if they are empty in unity editor while in Finder/Explorer view there is a framework folders in them. 2: When you build to xcode from Unity Editor. Check the build logs, the empty path warning library printed as normal log. If you see it shows it cannot find the library path then go to next step. 3: If they are empty do this:

  • Open in Finder/Explorer and copy the "iOS" folder. Make sure you see under iOS folder contains the ".framework" file.

  • Copy it and paste it into the unity editor. For me I paste it under the Apple.Core folder under Assets folder (not in the Apple.Core folder under the Package folder)

Then try to build to xcode again. Check the build log carefully. It contains every informations we need to track. If it says it found the library. My solution is worked. Hope this help you guys.

Long Chau.

Accepted Answer

Hi, to anyone faces this error. I found a workaround to solve this problem. First off, there is a commit fix for the finding asset ".framework" if you are using unity 2022. https://github.com/makeplayhappy/appleunityplugins/blob/find_framework_fix/plug-ins/Apple.Core/Apple.Core_Unity/Assets/Apple.Core/Editor/AppleFrameworkUtility.cs

If you are still facing this issue then follow these steps: (Please check the images) 1: Check the Apple.Core and Apple.Gamekit under Packages folder if they are empty in unity editor while in Finder/Explorer view there is a framework folders in them. 2: When you build to xcode from Unity Editor. Check the build logs, the empty path warning library printed as normal log. If you see it shows it cannot find the library path then go to next step. 3: If they are empty do this:

  • Open in Finder/Explorer and copy the "iOS" folder. Make sure you see under iOS folder contains the ".framework" file.

  • Copy it and paste it into the unity editor. For me I paste it under the Apple.Core folder under Assets folder (not in the Apple.Core folder under the Package folder)

Then try to build to xcode again. Check the build log carefully. It contains every informations we need to track. If it says it found the library. My solution is worked. Hope this help you guys.

Long Chau.

This is my resolution:

  1. My folder Package -> Apple.GameKit -> Plugins is empty and I create new folder in Assets -> Apple.GameKit -> Plugins
  2. Goto folder download unityplugins-main and copy folder iOS in unityplugins-main/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Plugins. unityplugins-main is project download in here: https://github.com/apple/unityplugins

Folder iOS in unityplugins-main/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Plugins. is Empty. Also for the first solution Apple.Gamekit under Packages folder in Finder/Explorer view are also empty. Please help I am not able to build my game with GameKit. My Unity Version is 2022.3.13f1

XCode build fail when add Apple.GameKit plugin for Unity: Undefined symbol
 
 
Q