Editing (augmenting) info.plist

  1. 4 years ago

    Jason K

    28 Jul 2015 Pre-Release Testers

    In order to use Game Center in an app, that app needs to have the "gamekit" key added to its info.plist file. According to the release notes on this feature:

    Any items USER plists create that duplicate keys the IDE creates will be over written by the IDE (basically you can't replace or augment entries the IDE creates)
    Only top level keys are dealt with (keys that are immediately children of PLIST > DICT in the Plist XML format)

    In order to add this key so that the app works properly with Game Center it must be added to the UIRequiredDeviceCapabilities array which Xojo already creates with the "armv7" key. What is the best way to set the "gamekit" key in the info.plist file so that the app works correctly? Or do I need a feature request?

    Thanks,
    Jason

    I was using the information in this thread to try to make my own mods to my app's plist file, and discovered a couple of gotchas along the way which may possibly be of interest to others following in the same footsteps:

    (1) My app’s name had spaces in it, and looking at the Xojo build step command, whilst CurrentBuildLocation produces an escaped path, it looks as though CurrentBuildAppName is not escaped. So I had to do it myself, with the crude but seems to work addition of

    CurrentBuildAppName.ReplaceAll( " ", "\ " )

    (2) As pointed out above, if using this on OSX, don't forget to add the Contents folder to your path.

    (3) I had to add in the ".app" extension to the path

    Putting these together with the example GameKit command above, I found this worked for me (on OSX):

    Dim App As String = CurrentBuildLocation + "/" + CurrentBuildAppName.ReplaceAll( " ", "\ " )

    call DoShellCommand("/usr/libexec/PlistBuddy -c ""Add :UIRequiredDeviceCapabilities:0 string gamekit"" " + App + ".app/Contents/Info.plist" )

  2. Michel B

    29 Jul 2015 Pre-Release Testers RubberViews.com

    Would'nt that help ? https://forum.xojo.com/24288-gamekit-error-application-is-not-allowed-to-run-in-production

  3. Norman P

    29 Jul 2015 Xojo Inc, Pre-Release Testers, Xojo Pro Seeking work. npalardy@great-w...

    @Jason K Or do I need a feature request?

    No need
    See 38737

  4. Jason K

    29 Jul 2015 Pre-Release Testers

    @Norman P No need
    See 38737

    Ok great! Is there another way to do this in the mean time while I wait for r3? Maybe with a post build script? I tried to make one similar to how Retina is enabled but it didn't properly edit the plist.

  5. Norman P

    29 Jul 2015 Xojo Inc, Pre-Release Testers, Xojo Pro Seeking work. npalardy@great-w...

    post build using defaults write would be the way I'd try

  6. Jason K

    29 Jul 2015 Pre-Release Testers
    Edited 4 years ago

    I tried the following before with no success:

     Dim App As String = CurrentBuildLocation + "/""" + CurrentBuildAppName
      Call DoShellCommand("/usr/bin/defaults write " + App + "/Info UIRequiredDeviceCapabilities -array gamekit armv7")

    Maybe there was a problem with my post build script? I'll be honest that my knowledge of defaults is very limited so that could be the problem.

  7. Norman P

    29 Jul 2015 Xojo Inc, Pre-Release Testers, Xojo Pro Seeking work. npalardy@great-w...

    Seems about right
    The only thing I can think of that might affect this is the "domain" argument may need to actually be the full path to the plist including the plist extension

  8. Jason K

    29 Jul 2015 Pre-Release Testers

    Just tried that and unfortunately there was no change.

  9. Norman P

    29 Jul 2015 Xojo Inc, Pre-Release Testers, Xojo Pro Seeking work. npalardy@great-w...

    try the command manually after you do a build in terminal to get the right command & syntax
    once you have that the shell will be darned close to the same

  10. Jason K

    29 Jul 2015 Pre-Release Testers

    I've been trying a variety of combinations and google searches for 45 minutes now haven't been able to make any progress. I guess I'll have to wait for someone who is more knowledgeable about using defaults to help me fix this.

  11. Norman P

    29 Jul 2015 Xojo Inc, Pre-Release Testers, Xojo Pro Seeking work. npalardy@great-w...

    What version of OS X are you on ?
    That may be relevant

  12. Greg O

    29 Jul 2015 Xojo Inc
    Edited 4 years ago

    Defaults Write only works for plists in the preferences directory now. You've got to use plist buddy to modify a plist in a particular location.

  13. Greg O

    29 Jul 2015 Xojo Inc

    From the Defaults man page:

    WARNING: The defaults command will be changed in an upcoming
    major release to only operate on preferences domains. General
    plist manipulation utilities will be folded into a different
    command-line program.

  14. Norman P

    29 Jul 2015 Xojo Inc, Pre-Release Testers, Xojo Pro Seeking work. npalardy@great-w...

    There IS an alternative tool apple ships called PlistBuddy which might work better
    The reason I say this is defaults has this small note
    WARNING: The defaults command will be changed in an upcoming
    major release to only operate on preferences domains. General
    plist manipulation utilities will be folded into a different
    command-line program.

    so its possible that you ARE writing to a plist but its one IN your preferences dir and NOT the one you think your writing to

  15. Greg O

    29 Jul 2015 Xojo Inc

    Keep in mind that PlistBuddy is not in the default path. On my machine it's at:

    /usr/libexec/PlistBuddy
  16. Jason K

    29 Jul 2015 Pre-Release Testers

    OSX 10.10.4 so I think you are correct that it won't work. I'll look into PlistBuddy, thanks for the tip @Greg OLone and @Norman P!

  17. Norman P

    29 Jul 2015 Xojo Inc, Pre-Release Testers, Xojo Pro Seeking work. npalardy@great-w...
    Edited 4 years ago

    its in /usr/libexec/PlistBuddy

    and it has a simpler command line interface

    something like

    /usr/libexec/PlistBuddy -c "Add :UIRequiredDeviceCapabilities: String gamekit" "..... FULL PATH TO YOUR PLIST HERE"

  18. Jason K

    29 Jul 2015 Pre-Release Testers

    Yeah I came up with the same thing you did but it doesn't seem to work in a build script, only in terminal. Time to do some more digging.

  19. Jason K

    29 Jul 2015 Pre-Release Testers

    Ok, for anyone else who may need this, the following works properly:

    Dim App As String = CurrentBuildLocation + "/" + CurrentBuildAppName  
    call DoShellCommand("/usr/libexec/PlistBuddy -c ""Add :UIRequiredDeviceCapabilities:0 string gamekit"" " + App + "/Info.plist" )
  20. Jason K

    29 Jul 2015 Pre-Release Testers

    Thank you both for your help.

  21. Newer ›

or Sign Up to reply!