Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Apple Unity Plugins crashing on authentication

Discussion in 'iOS and tvOS' started by volkan-aydinli, Jun 19, 2023.

  1. volkan-aydinli

    volkan-aydinli

    Joined:
    Apr 8, 2018
    Posts:
    1
    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 https://github.com/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

    [B]023-06-19 15:07:54.991987+0300 [B]GameName[/B][23524:6527433] [general] Error loading /var/containers/Bundle/Application/43C0628B-8BE1-4C04-9273-F9A5D1F2750E/GameName.app/Frameworks/UnityFramework.framework/UnityFramework (146):  dlopen(/var/containers/Bundle/Application/43C0628B-8BE1-4C04-9273-F9A5D1F2750E/[B]GameName[/B].app/Frameworks/UnityFramework.framework/UnityFramework, 0x0109): Library not loaded: @rpath/AppleCoreNative.framework/AppleCoreNative[/B]

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

    [B] 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 [B]GameName.[/B]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/[B]GameName[/B].app/Frameworks/AppleCoreNative.framework/AppleCoreNative' (no such file), '/private/var/containers/Bundle/Application/43C0628B-8BE1-4C04-9273-F9A5D1F2750E/[B]GameName[/B].app/Frameworks/AppleCoreNative.framework/AppleCoreNative' (no such file), '/System/Library/Frameworks/AppleCoreNative.framework/AppleCoreNative' (no such file, not in dyld cache)[/B]



    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.
     
  2. mmhouston6

    mmhouston6

    Joined:
    Aug 13, 2018
    Posts:
    2
    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.
     
  3. vengefullfoot

    vengefullfoot

    Joined:
    Sep 24, 2018
    Posts:
    31
    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)
     
  4. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    753
  5. Telesto26

    Telesto26

    Joined:
    Dec 31, 2020
    Posts:
    13
    We also facing the same issue, any suggestions?
     
  6. kogi_rc

    kogi_rc

    Joined:
    Apr 23, 2019
    Posts:
    39
    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.
     
    Last edited: Jul 17, 2023
  7. Telesto26

    Telesto26

    Joined:
    Dec 31, 2020
    Posts:
    13
    @kogi_rc Is it possible to share the merged branch? We are stuck in this issue for weeks! Thanks.
     
  8. kogi_rc

    kogi_rc

    Joined:
    Apr 23, 2019
    Posts:
    39
    I can't share the branch but I can share commands to create it:
    Code (CSharp):
    1. git clone https://github.com/dodgy-ltd/apple-unityplugins.git
    2. cd .\apple-unityplugins
    3. git remote add muzzkat https://github.com/muZZkat/unityplugins.git
    4. git fetch muzzkat
    5. git merge muzzkat/muzzkat/fix-fetch-items
    6.  
    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:
    Code (CSharp):
    1. xcodebuild -sdk iphoneos -configuration Release -workspace /<REDACTED>/Unity-iPhone.xcworkspace -scheme Unity-iPhone build
    2. xcodebuild -workspace /REDACTED/Unity-iPhone.xcworkspace -scheme Unity-iPhone archive -sdk iphoneos -configuration Release -archivePath /REDACTED/Build/ios/archive/Unity-iPhone
    3. xcodebuild -exportArchive -archivePath Build/ios/archive/Unity-iPhone.xcarchive -exportOptionsPlist /path_to/exportOptions.plist -exportPath Build/ios/export
    ExportOptions.plist
    Code (CSharp):
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    3. <plist version="1.0">
    4. <dict>
    5.     <key>compileBitcode</key>
    6.     <false/>
    7.     <key>method</key>
    8.     <string>app-store</string>
    9.     <key>provisioningProfiles</key>
    10.     <dict>
    11.         <key>REDACTED</key>
    12.         <string>REDACTED</string>
    13.     </dict>
    14.     <key>signingCertificate</key>
    15.     <string>REDACTED</string>
    16.     <key>signingStyle</key>
    17.     <string>manual</string>
    18.     <key>stripSwiftSymbols</key>
    19.     <true/>
    20.     <key>teamID</key>
    21.     <string>REDACTED</string>
    22.     <key>thinning</key>
    23.     <string>&amp;lt;none&amp;gt;</string>
    24. </dict>
    25. </plist>
    26.  
    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.
     
    Last edited: Jul 25, 2023
    camillazi, chin13577 and wondermagic like this.
  9. lucillegames

    lucillegames

    Joined:
    Aug 31, 2018
    Posts:
    1
    kogi_rc likes this.
  10. Telesto26

    Telesto26

    Joined:
    Dec 31, 2020
    Posts:
    13
    @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!
     
    qball13z and kogi_rc like this.
  11. chin13577

    chin13577

    Joined:
    May 8, 2017
    Posts:
    16
    @kogi_rc You are a life saver. it works like a charm. Thank you!
     
    kogi_rc likes this.
  12. davemeta

    davemeta

    Joined:
    Jul 17, 2012
    Posts:
    17
    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.
     
    camillazi and qball13z like this.
  13. camillazi

    camillazi

    Joined:
    Sep 28, 2020
    Posts:
    5
    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. :(

    Code (CSharp):
    1. [558:64019] [DYMTLInitPlatform] platform initialization successful
    2. [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
    3.   Referenced from: /var/containers/Bundle/Application/<>/<>.app/Frameworks/UnityFramework.framework/UnityFramework
    4.   Reason: no suitable image found.  Did find:
    5.     /private/var/containers/Bundle/Application/<>/<>.app/Frameworks/GameKitWrapper.framework/GameKitWrapper: missing LC_DYLD_INFO load command
    6.     /private/var/containers/Bundle/Application/<>/<>.app/Frameworks/GameKitWrapper.framework/GameKitWrapper: missing LC_DYLD_INFO load command
     
  14. ycode

    ycode

    Joined:
    May 1, 2016
    Posts:
    4
    @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.
    1. apply the patches from the awesome contributors to your local repo of `apple/apple-unityplugins` as @kogi_rc described above.
    2. switch Unity editor version of the Unity project of each plugin source. For example, in the case of `Apple.Core`:
      1. add the existing Unity project at `plug-ins/Apple.Core/Apple.Core_Unity` on Unity Hub
      2. switch Unity editor version of `Apple.Core_Unity` project to the same version as your Unity project use
      3. after the editor version switch complete and a Unity editor open, just close the editor
    3. 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
    4. 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.
     
  15. lamyaslamyas

    lamyaslamyas

    Joined:
    Jan 6, 2023
    Posts:
    2
    @kogi_rc Your solution not only resolved my issue but also significantly saved me a substantial amount of time. Thank you indeed.