Apple Unity Plugins crashing on authentication

Hello,

I have implemented the apple’s unity plugins so i can use player’s game center informations to log in them. I followed the instructions on GitHub - apple/unityplugins and using Apple.Core and Apple.GameKit in my game. On my start scene i am calling the authentication method like “var player = await GKLocalPlayer.Authenticate();” and it is crashing the app immediately. i have tested through testflight and also ran the application through xcode, it is the same. The error i got from xcode is going like this


__Referenced from: <135CE991-5878-3356-855B-0EE3A58465F7> /private/var/containers/Bundle/Application/43C0628B-8BE1-4C04-9273-F9A5D1F2750E/**GameName.**app/Frameworks/UnityFramework.framework/UnityFramework__

__Reason: tried: '/usr/lib/swift/AppleCoreNative.framework/AppleCoreNative' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/AppleCoreNative.framework/AppleCoreNative' (no such file), '/usr/lib/swift/AppleCoreNative.framework/AppleCoreNative' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/AppleCoreNative.framework/AppleCoreNative' (no such file), '/private/var/containers/Bundle/Application/43C0628B-8BE1-4C04-9273-F9A5D1F2750E/The **GameName.**app/Frameworks/AppleCoreNative.framework/AppleCoreNative' (no such file), '/usr/lib/swift/AppleCoreNative.framework/AppleCoreNative' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/AppleCoreNative.framework/AppleCoreNative' (no such file), '/usr/lib/swift/AppleCoreNative.framework/AppleCoreNative' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/AppleCoreNative.framework/AppleCoreNative' (no such file), '/private/var/containers/Bundle/Application/43C0628B-8BE1-4C04-9273-F9A5D1F2750E/**GameName**.app/Frameworks/AppleCoreNative.framework/AppleCoreNative' (no such file), '/private/var/containers/Bundle/Application/43C0628B-8BE1-4C04-9273-F9A5D1F2750E/**GameName**.app/Frameworks/AppleCoreNative.framework/AppleCoreNative' (no such file), '/System/Library/Frameworks/AppleCoreNative.framework/AppleCoreNative' (no such file, not in dyld cache)__```

Has anyone experienced an error like this? I couldn't find any related example on the internet specific to these plugins so i am really open to any ideas right now.

I had the same issue. I was able to get past that error but then got the same error just with the GameKitWrapper Framework instead. I tried manually adding Frameworks, it did not work. Gave up and used the Sign In With Apple Unity plugin instead. Super annoying and wasted time. I hope they fix this or someone knows a solution.

Same error here, tried everything at Xcode level, not much success…
It must be linked with the version of Unity (2022.3.3f1 in my case)

Is this the issue?

We also facing the same issue, any suggestions?

Exactly same issue. It doesn’t seem to be related to MousePods link but it sucks to hear that the plugin will not work even if we manage to fix the library linking problem.

Update: Using this PR branch as base, then merging fixes from here and compiling it with included build script using 2020.3.33f1 Unity fixed above errors. Runtime testing is still ahead of me but at least it compiles and doesn’t crash at the first sight of GK methods during runtime.

@kogi_rc Is it possible to share the merged branch? We are stuck in this issue for weeks! Thanks.

I can’t share the branch but I can share commands to create it:

git clone https://github.com/dodgy-ltd/apple-unityplugins.git
cd .\apple-unityplugins
git remote add muzzkat https://github.com/muZZkat/unityplugins.git
git fetch muzzkat
git merge muzzkat/muzzkat/fix-fetch-items

Note: Please review and compare branches with original apple-unityplugins. It worked and it didn’t contain anything other than fixes at the time of posting but any of the branches may get updated in the future so be safe and verify what you’re merging.

Then the only extra thing I did was to change GKIdentityVerificationResponse.cs constructor at line 30 from internal to public. Ensure that you have Unity 2020.3.33f1 on your mac and compile with python3 build.py.

Idk if it solves all issues but it did work for us and we got GameCenter login working and the solution is usable on Windows machines, too.

Credit to dodgy-ltd and muZZkat who made the actual fixes and to MousePods who linked it here.

Build flow:

xcodebuild -sdk iphoneos -configuration Release -workspace /<REDACTED>/Unity-iPhone.xcworkspace -scheme Unity-iPhone build
xcodebuild -workspace /REDACTED/Unity-iPhone.xcworkspace -scheme Unity-iPhone archive -sdk iphoneos -configuration Release -archivePath /REDACTED/Build/ios/archive/Unity-iPhone
xcodebuild -exportArchive -archivePath Build/ios/archive/Unity-iPhone.xcarchive -exportOptionsPlist /path_to/exportOptions.plist -exportPath Build/ios/export

ExportOptions.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>compileBitcode</key>
    <false/>
    <key>method</key>
    <string>app-store</string>
    <key>provisioningProfiles</key>
    <dict>
        <key>REDACTED</key>
        <string>REDACTED</string>
    </dict>
    <key>signingCertificate</key>
    <string>REDACTED</string>
    <key>signingStyle</key>
    <string>manual</string>
    <key>stripSwiftSymbols</key>
    <true/>
    <key>teamID</key>
    <string>REDACTED</string>
    <key>thinning</key>
    <string><none></string>
</dict>
</plist>

Redacted company/bundle ids but I tried to include all relevant parts from our CI pipeline. I hope it helps at least a bit but tbh we were changing so many things in the build settings in the meantime that I’m not even sure what part did the trick.

4 Likes

@kogi_rc works! Thank you!

1 Like

@kogi_rc Your are one of the greatest developers, thanks for the details instructions. After several months of failed attempts, finally it works. Again, thank you!

2 Likes

@kogi_rc You are a life saver. it works like a charm. Thank you!

1 Like

How is this still not fixed for major release versions 4 months later?

Seems like a perpetual issue that upgrading anything is worse than sticking to years-old versions.

Thanks to community members for being the ones to fix it while companies with billions of dollars don’t give a single f*ck.

4 Likes

Hi, thank you for the detailed response. I’m experiencing a similar issue where the app crashes on startup with GameKitWrapper. I fetched and merged the branch muzzkat/muzzkat/fix-fetch-items, built python3 build.py with Unity 2020.3.33f1, and also updated the GKIdentityVerificationResponse.cs but I’m still getting this error. I’m a newbie to iOS development and xcode, hope someone can help. :frowning:

[558:64019] [DYMTLInitPlatform] platform initialization successful
[558:63833] Error loading /var/containers/Bundle/Application/<><>/Frameworks/UnityFramework.framework/UnityFramework:  dlopen(/var/containers/Bundle/Application/<>/<>/Frameworks/UnityFramework.framework/UnityFramework, 265): Library not loaded: @rpath/GameKitWrapper.framework/GameKitWrapper
  Referenced from: /var/containers/Bundle/Application/<>/<>.app/Frameworks/UnityFramework.framework/UnityFramework
  Reason: no suitable image found.  Did find:
    /private/var/containers/Bundle/Application/<>/<>.app/Frameworks/GameKitWrapper.framework/GameKitWrapper: missing LC_DYLD_INFO load command
    /private/var/containers/Bundle/Application/<>/<>.app/Frameworks/GameKitWrapper.framework/GameKitWrapper: missing LC_DYLD_INFO load command

@camillazi I wondered that the Unity editor version of your Unity project might be different from 2020.3.33f1.

If that is the case, you should either switch the editor version of your unity project to 2020.3.33f1 via Unity Hub, or switch the editor version of the Unity projects of the apple-unity plugins.

If you go with the latter one, then you need a few extra steps in the plugin build steps.

  • apply the patches from the awesome contributors to your local repo of apple/apple-unityplugins as @kogi_rc described above.

  • switch Unity editor version of the Unity project of each plugin source. For example, in the case of Apple.Core:

  • add the existing Unity project at plug-ins/Apple.Core/Apple.Core_Unity on Unity Hub

  • switch Unity editor version of Apple.Core_Unity project to the same version as your Unity project use

  • after the editor version switch complete and a Unity editor open, just close the editor

  • after repeating the steps above for the plugins you need, run python3 ./build.py

  • just in case, check the build outputs to see whether the plugins are built with the same Unity version as your Unity project

  • add the plugins from the built tarball files to your Unity project via the package manager

With my project using Apple.Core and Apple.Apple.GameKit, I confirmed it made the plugin work with Unity editor 2021.3.31f1 and 2022.3.11f1. My Xcode version is 15.0.1 in both case.

2 Likes

@kogi_rc Your solution not only resolved my issue but also significantly saved me a substantial amount of time. Thank you indeed.

@kogi_rc and @ycode thank you so much for your help with this. I never could’ve figured out how to get past this on my own lol.

@ycode @camillazi - I got it working in 2022.3.11.f1 with your steps above, but I also had to go into Edit > project settings > Apple Build Settings and change the minimum ios version to 14.0.

thanks to this comment for the 14.0 fix: GKLocalPlayer.Local.FetchItems() Error on Unity - #15 by AndreaMar

I haven’t actually built with any of my code that uses the plugins atm, but these threads at least got my app up and running with the packages in it. I really hope Apple gets the issue fixed officially soon.

1 Like

I’ve got a build working that can authenticate using the GKLocalPlayer.Authenticate(), so the changes made in my comment above definitely work. I also am able to use GKAccessPoint functions without issue.

But I can’t get all of the Game Kit features to work.

For instance, if I try to use the GKGameCenterViewController as shown in the plugin’s documentation:

var gameCenter = GKGameCenterViewController.Init(GKGameCenterViewController.GKGameCenterViewControllerState.Achievement);

it throws a C# exception about there not being a default constructor for the class.

More importantly though, I can’t seem to get GKAchievement.LoadAchievements() or GKAchievementDescription.LoadAchievementDescriptions() to work. Both of these functions cause the app to throw an exception at the xcode level (sorry if this is the incorrect way to describe it; I’m new to ios/xcode dev):

libc++abi: terminating due to uncaught exception of type Il2CppExceptionWrapper xcode

I have achievements configured in the dev portal for the app, and I am able to see them if I click on the GKAccessPoint and go to the app’s achievement list in the Game Center window.

I did delete a couple of them from the portal after testing and the removals weren’t reflected in the access point’s achievement list, so I’m not sure if the error I’m seeing is something wrong with the plugin, or if it’s something wrong with my app setup/connection.

Anyone have any experience with this?

I was experiencing the same error when trying to load achievements and post achievement progress to GameKit. I created a link.xml file in the /Assets/ folder which fixed my issue.

<linker>
  <assembly fullname="Apple.Core" ignoreIfMissing="1" preserve="all"/> 
  <assembly fullname="Apple.GameKit" ignoreIfMissing="1" preserve="all"/>
</linker>

Hope this helps someone else.

Andy

5 Likes

@An-mo you are a life saver thank you! That worked basically perfectly.

I got a different X Code error after adding the link.xml file:

Assertion failed: (false && "compact unwind compressed function offset doesn't fit in 24 bits"), function operator(), file Layout.cpp, line 5758.

but was able to resolve it with the help of this thread: Project won't build using Xode15 release candidate.

I had to add “-Id_classic” to the list in UnityFramework > Build Settings > Other Linker Flags

2 Likes

Thank you so much! I followed these steps plus @squigglebucket advice to update to minimum iOS version 14.0.

Build from Xcode is no longer crashing on startup. Thanks!