Search Unity

GameCenter not Linking GameKit (OSX) - SOLVED

Discussion in 'iOS and tvOS' started by MrEsquire, Nov 5, 2015.

  1. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Hi,

    I know many people do not develop for OSX due to the complexities,but after spending many hours implementing plugins and getting my game work correctly to Apple standards I was rejected for the following reason: "The app has the Game Center entitlement without linking against the GameKit framework"

    I tried to search forums and found only this thread: some people have opposite problem.
    http://forum.unity3d.com/threads/ur...ecause-gamekit-framework-linked.261354/page-3

    I also noticed this change in older version of 4.6x
    (none) - OSX: Now GameKit is loaded dynamically, it should help with Mac App Store submissions for games, which are not using Game Center.

    Now it is mentioned by developer @jonas echterhoff
    "Unity 5 will automatically add or remove the GameKit linkage as needed if GameCenter if used or not"


    I'm not sure what is going on, I'm using Unity 4.6.9 with Mac App Store Toolkit. I have got Game Center enabled in Entitlements as of course needed (using Prime31 plugin) Upgrading to Unity 5 is not a option(and I think it dont even work in Unity 5)

    Can someone please tell me how to link against GameKit framework or a Unity hack.

    Thank you.
     
  2. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,563
    Apple had changed the rules on this several times.

    • Originally we would always link against GameKit, regardless of the content using it or not.
    • Then, Apple started complaining about that, and enforce not linking to GameKit, unless you'd used it.
    • So what we did then is that we would never link to GameKit, and load it dynamically instead (This was the 4.6x release you mentioned).
    • Then, Apple started complaining about that as well, and enforce not linking GameKit when you would not use it, and enforce linking GameKit when you would use it.
    • This was more difficult to solve for us, because we don't actually link the MacStandalonePlayer executable at player build time - we always use the same binary, and just changed the managed mono dlls. So what we had to do now, was to patch the binary to remove or install GameKit linkage depending on whether it is needed or not. This change is in Unity 5, which should work.
    So, your options are now: Either update to Unity 5, or patch the binary yourself to add GameKit linkage. We are using optool to do that in the Unity 5 player build process, but we cannot provide any support for patching the binary yourself using optool.
     
  3. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Thanks for the detailed reply, much appreciated - clears up some stuff.
    Maybe Apple once again changed there mind as it seems all the new iOS9 stuff etc has some impact, but who knows maybe its just the reviewer I got to check app being strict on me.

    I cannot upgrade to Unity 5 because the game is complex and being build on 4.6 when Unity 5 came out. So cannot spend months more work on this. This is something I did not expect from Apple and assumed there would not be issues, cannot plan ahead for such things.

    So seems optool my only option now, ok I check the internet to see if I can find a guide on how to do this as when I downloaded optool and opened in Xcode 7.1, OSX El Capitan could not run in Xcode. I just hope this thread gives bit more visibility as the old thread is abit messy and oftopic.. Cheers.
     
  4. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,563
    Maybe you can take a shortcut, and download Unity 5, and uses the optool executable it uses, which should be at
    /Applications/Unity/Unity.app/Contents/PlaybackEngines/MacStandaloneSupport/optool - saves you the trouble of finding out how to build it (which was a bit tricky, IIRC).
     
  5. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Excellent will try this and report back;

    One more question:

    Do these steps still apply:

    "run:
    optool install -c weak -p /System/Library/Frameworks/GameKit.framework/Versions/A/GameKit -t <executable_path>

    This should probably work (you can only tell for sure once it passes MAS submission, of course), please give it a try, and let us know if it works. If it does, we might consider integrating this as part of our build pipeline"

    Now when I do run this, do I just normally build again in Unity and do nothing or have to run this against the Game.PKG which is generated for the Mac Store.

    Thanks
     
    arkon likes this.
  6. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,563
    This command should still be valid. You need to replace <executable_path> with the executable inside the .app you build, and do this before packaging it up to a .pkg file.
     
    MrEsquire likes this.
  7. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Ah, was worried you may say this - but guess only way for now.

    I use a tool called Mac App Store Toolkit (https://www.assetstore.unity3d.com/en/#!/content/9231)
    This enables user to enter all the App Certificates, Entitlements and many other things, and makes a Package file ready for upload, this does not have option for StoreKit but does link the Game Center correctly.

    It can create a .App file without the packaging and then I can do the required edits in optool, but I guess no way I can transfer this back into Unity and make a package file, so will manually need to package it.

    It can be done but that's why I hoped Unity may have a solution to save time, but I understand Apple cannot make up there mind about this and hence not much discussion for long time.. Its one those that keeps coming back once in a while issues.
     
  8. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    I managed to use optool and this was my output:

    Code (CSharp):
    1. Found FAT Header
    2. Found thin header...
    3. Found thin header...
    4. Inserting a LC_LOAD_WEAK_DYLIB command for architecture: x86
    5. Successfully inserted a LC_LOAD_WEAK_DYLIB command for x86
    6. Inserting a LC_LOAD_WEAK_DYLIB command for architecture: x86_64
    7. Successfully inserted a LC_LOAD_WEAK_DYLIB command for x86_64
    8. Writing executable to /Users/Esquire/Desktop/MyGame.app/Contents/MacOS/MyGame...
    Is this the expected result, do you remember?

    UPDATE:

    I get the following issue when uploading the .pkg file to Itunes, but I'm not sure if its to do with the tool or me packaging it.

    Invalid Signature - The main app bundle MyGame at path MyGame.app has following signing error(s): invalid signature (code or signature have been modified) In architecture: x86_64 . Refer to the Code Signing and Application Sandboxing Guide at http://developer.apple.com/library/...ceptual/CodeSigningGuide/AboutCS/AboutCS.html and Technical Note 2206 at https://developer.apple.com/library/mac/technotes/tn2206/_index.html for more information.
     
    Last edited: Nov 7, 2015
  9. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Update: If I sign the App then edit it with optool does that invalidate the signature?

    After many hours finally got the Invalid Signature error to go away. So I built OSX App withing Unity and then the .App edited it with optool, then I manually selected the .App within Unity using the Mac OSX Toolkit plugin, this then added the signature, entitlements and packaging. I then uploaded to the store and error was gone. So lets see what the review team come back with.

    I hope the process is correct and does not override the changes done buy optool?
     
  10. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,563
    Yes.

    This process sounds correct.
     
  11. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Thank you for all your help, Apple have accepted the game, so we know this process still works and optool is the one to use if anyone has similar issues. Cheers
     
    jonas-echterhoff likes this.
  12. Wriggler

    Wriggler

    Joined:
    Jun 7, 2013
    Posts:
    83
    Thanks for sharing this information guys. I just followed these instructions myself and optool appeared to work. Actually, optool was a pain to build so I was able to use the version included in Unity 5 as suggested. As of 5.3 it is located in /Applications/Unity/PlaybackEngines/MacStandaloneSupport/optool

    Hopefully Apple will approve my binary now!

    Ben
     
    MrEsquire likes this.
  13. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,088
    I've just been rejected with this same error:

    In my game my apple app ID has game centre enabled, the game has game centre things in it, it uses calls to Social and the Prime31 game centre plugin, so why isn't Unity linking in GameKit? OS x development is a right pain in the backside, so hit and miss. I wasted 2 weeks so far on something that should have just worked. It would probably better if Unity created an Xcode project same as IOS for OSX so we can at least tinker in Xcode to get things to work.

    Looks like I too need to use optool. Can Unity please give us an answer on this, why is GameKit not linked in when I'm using all gambit stuff in the game? Oh I'm using Unity 5.3.3P1 on a mac.
     
  14. Wriggler

    Wriggler

    Joined:
    Jun 7, 2013
    Posts:
    83
    Agreed. I never managed to get my app update approved - Apple came back with a different issue each time. After about 5 rejections I gave up - Mac App Store users are having to make do with a very old version for now. Definitely hoping Unity are able to improve this aspect of their software - OS X support is more trouble than it's worth right now. :-(

    Ben
     
  15. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,563
    If you use GameKit through a plugin (ie, Prime31), it is possible that Unity will not detect that usage, and not add the GameKit linkage for you. Basically, Unity will scan your assemblies for references to the UnityEngine.SocialPlatforms.GameCenter.GameCenterPlatform class, and if it finds any, it will add the GameKit linkage. If you access the GameKit framework through other means, Unity cannot know about that, so you will either need to add a bogus reference to UnityEngine.SocialPlatforms.GameCenter.GameCenterPlatform, or add the GameKit linkage yourself using optool.

    FYI, we have hired a new engineer to work on improving OS X support, and making an Xcode project you can edit is the current plan, AFAIK.
     
  16. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,088
    I use calls to Social and the GameKit isn't being included so there is a bug in Unity. I've just had to strip all game centre stuff out of my game and generate new ID, profiles etc. then re submit. Here is my code and the Bug where Social.LoadUsers still doesn't work.

    Code (CSharp):
    1. void Start()
    2. {
    3.   Social.localUser.Authenticate(ProcessAuthentication);      
    4. }
    5.  
    6. void ProcessAuthentication(bool success)
    7. {
    8.   D.logx("ProcessAuthentication");
    9.  
    10.   if(success)
    11.   {
    12.     D.logx("GameCentre Authenticated");
    13.     DoLeaderboard();
    14.   }
    15.   else
    16.   {
    17.     D.logx("GameCentre Failed to authenticate");
    18.   }
    19. }
    20.  
    21. void DoLeaderboard()
    22. {
    23.   D.logx("DoLeaderboard");
    24.  
    25.   Leaderboard = Social.CreateLeaderboard();
    26.   Leaderboard.id = "MyGamesID";
    27.   Leaderboard.range = new Range(1, 100);
    28.   Leaderboard.LoadScores(result => DidLoadScores(result));
    29. }
    30.  
    31. void DidLoadScores(bool result)
    32. {
    33.   int i = 0;
    34.   D.logx("DidLoadScores");
    35.  
    36.   NumScores = Leaderboard.scores.Length;
    37.   userIDs = new string[NumScores];
    38.   foreach(IScore score in Leaderboard.scores)
    39.   {
    40.     D.logx("DidLoadScores {0}  :  {1}", score.userID, score.value.ToString());
    41.   }
    42.  
    43.   Social.LoadUsers(userIDs, DidLoadProfiles); //<<<<----This command does Nothing on IOS and OSX, it used to work prior to 5.3
    44. }
    45.  
    46. void DidLoadProfiles(IUserProfile[] result)
    47. {
    48.   D.logx("DidLoadProfiles");
    49.  
    50.   foreach(IUserProfile profile in result)
    51.   {
    52.     D.logx("{0}",profile);
    53.   }
    54. }
    55.  
     
    Last edited: Mar 3, 2016
  17. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,563
    But do you reference the UnityEngine.SocialPlatforms.GameCenter.GameCenterPlatform class? As I wrote above, that is what triggers GameKit linkage.
     
  18. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,088
    I'm not sure what you mean 'reference' the code above was based on the Unity Docs, it makes calls to Social so shouldn't that be the reference? What form should the reference take? how should I change my code above to force GameKit to be linked?
     
  19. Wriggler

    Wriggler

    Joined:
    Jun 7, 2013
    Posts:
    83
    Hey Jonas,

    Thanks for posting this bit of insight, it has been really useful. I was able to put a bit of "dummy" code into one of my scripts, it looked like this:

    Code (CSharp):
    1. #if UNITY_STANDALONE_OSX
    2. using UnityEngine.SocialPlatforms.GameCenter;
    3. ...
    4. void Awake()
    5. {
    6.    GameCenterPlatform gcp = new GameCenterPlatform();
    7.    gcp = null;
    8. }
    9. #endif
    That must have encourage Unity to link the correct Game Center files, as this version passed Apple's testing and has finally been released. Thanks very much for your help!

    Ben
     
    kavanavak likes this.
  20. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    @jonas echterhoff

    Please, is there any estimative on this? On the current state, is virtually impossible to successfully publish an Mac App Store game created from Unity which uses In App Purchasing and Achievements.

    I have now 7 rejected binaries.
     
  21. Wriggler

    Wriggler

    Joined:
    Jun 7, 2013
    Posts:
    83
    Did you try adding a reference to GameCenterPlatform as per my post just above yours?

    Ben
     
  22. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Well as I started this posting and followed instructions by Unity developer, you can see I successfully uploaded to Mac both with StoreKit and Game Center without issues.

    7 rejected binaries I think your doing something wrong and not Unity issue.

    I keep telling everyone who has Mac build to download Mac Toolkit from asset store, it help you visually add the needed features. This best tool out there.
     
  23. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    Well, Mac Toolkit is not available anymore. :(

    One more rejected binary, but now only one error remaining : Using Unity 5.4.0b18

    - Also, the app uses the Game Center entitlement without linking agains the GameKit framework.

    And on my code I have :
    Code (csharp):
    1.  
    2. using UnityEngine.SocialPlatforms.GameCenter;
    3. UnityEngine.SocialPlatforms.GameCenter.GameCenterPlatform.ShowDefaultAchievementCompletionBanner(false);
    4. Social.localUser.Authenticate(success =>
    5.  
    This should be enough to GameKit be included in the build! What am i Missing?

    Thanks
     
  24. Wriggler

    Wriggler

    Joined:
    Jun 7, 2013
    Posts:
    83
    Looks like that should work to me. Perhaps the Unity folks in this thread can advise further? I also recommended you add the dummy code I posted above. It doesn't materially change anything, and solved my submission problems.

    Ben
     
  25. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,088
    you will be lucky getting an answer from unity, they don't give a toss about so many things. Social.LoadUsers(userIDs, DidLoadProfiles); still doesn't work so I would avoid Unitys implementation of game center with a barge pole. Currently and for the last year or more it's been impossible to get the player names from their ID's using the social api. Give up, I have.
     
  26. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    Did you know how can I check if the gamekit is linked to my project or not?
     
  27. Wriggler

    Wriggler

    Joined:
    Jun 7, 2013
    Posts:
    83
    You could try some of the terminal commands posted earlier in the thread, but in my experience it didn't really help. I just kept re-adding random bits of code and resubmitting to Apple until it worked...

    Ben
     
  28. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Sorry to say but I don't think you reading this thread properly, can you not see what the first posting was.
    jonas has clearly showed one how to solve this and I confirmed it does work.

    Yes Unity does not link to GameKit and so the solution above works to manually link it.
    I said use the MacOSX kit to help you as it contains a visual elements needed in process, its not available on store as developer stopped supporting it, to be honest Unity should buy this guys code or make own version of it.

    Without the toolkit the process can still be done with optool just longer as got sign the files.
     
  29. Jespertheend2

    Jespertheend2

    Joined:
    Jan 14, 2015
    Posts:
    23
    I was having the same problem. I tried the dummy code but that resulted in an error in the unity console saying there was a problem when running optool. Luckily I'm using a build script that also calls a shell script when it's done building. This script takes care of stuff like codesigning and changing the info.plist a bit. So I added the optool command to this script and I think I have something that's working now. But we'll see after apple is done reviewing it.
    If anyone is interested in my build script/workflow feel free to let me know.
     
  30. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    This issue still exists using Unity 5.5.2/ still need to do manual optool command line before uploading app with game center otherwise it get rejected.

    I been using a new MacOS helper tool and developer also does not understand this thread..

    Unity any plans for checkbox?
     
  31. Zwilnik

    Zwilnik

    Joined:
    Jul 22, 2014
    Posts:
    61
    Still a problem with Unity 2017.1.1f1 Just had our game rejected for not linking to GameKit (our plugin links against it in its bundle, but that link doesn't appear to end up in the signed app. Is anyone at Unity working on the Mac version at all?
     
  32. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Any updates on this in Unity 2017/2018??
     
  33. kosted

    kosted

    Joined:
    Mar 14, 2015
    Posts:
    91
    I'm facing the same issue. Did you find any solutions ?
     
  34. Davlin

    Davlin

    Joined:
    Feb 19, 2013
    Posts:
    54
    The issue returned in 2018.2
     
  35. Davlin

    Davlin

    Joined:
    Feb 19, 2013
    Posts:
    54
    Your app contains the Game Center entitlement, but it does not link against the GameKit framework.
     
  36. virgilcwyile

    virgilcwyile

    Joined:
    Jan 31, 2016
    Posts:
    26
    Same here, can anyone give proper command to run in OpTool?
    Its strange we cant update our games. Apple only accepts the games the first time we upload. There on they reject.
     
  37. jkampitakis

    jkampitakis

    Joined:
    Dec 27, 2015
    Posts:
    56
    We have the same issue here, trying to build using 2018.2.13f1