Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Customizing URL types directly from Unity

Discussion in 'iOS and tvOS' started by liortal, Jan 8, 2015.

  1. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,415
    Hey,

    We have a requirement to set our game to respond to a custom URL scheme.

    Normally, this is done in XCode using the Info->URL Types menu.

    Is there any way to automate this so we won't have to enter it every time Unity creates a new project ?

    If not, does the new XCode manipulation project address this in any way ?

    Thx
    Lior
     
  2. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,495
    If you use any of the Prime31 plugins you'll find a menu option to do 'Info.plist Additions'. This has a section for CFBundle URL schemes - perhaps this is helpful?
     
  3. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,415
    We do not use Prime31, but I guess the Info.plist hint is good enough to try and see whether we can create some auto-patching process that will do what we need.
     
  4. lukelutman

    lukelutman

    Joined:
    Feb 20, 2013
    Posts:
    5
    We're adding custom url schemes using a PostProcessBuild method and PlistCS:

    Code (CSharp):
    1. protected virtual void PostprocessXcodePlist() {
    2.  
    3.     // set plist path
    4.     string plistPath = "...";
    5.    
    6.     // read plist
    7.     Dictionary<string, object> dict;
    8.     dict = (Dictionary<string, object>)Plist.readPlist(plistPath);
    9.    
    10.     // update plist
    11.     dict["CFBundleURLTypes"] = new List<object> {
    12.         new Dictionary<string,object> {
    13.             { "CFBundleURLName", PlayerSettings.iPhoneBundleIdentifier },
    14.             { "CFBundleURLSchemes", new List<object> { PlayerSettings.iPhoneBundleIdentifier } }
    15.         }
    16.     };
    17.    
    18.     // write plist
    19.     Plist.writeXml(dict, plistPath);
    20.    
    21. }
     
  5. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,415
    Thanks, I already figured out that this info is stored in the Info.plist but i didn't want to do this myself as i am not so familiar with the XCode project structure.

    Is this project (PlistCS) proven and "battle-tested" so i can count on it working ?

    Thanks for the link BTW :)
     
  6. lukelutman

    lukelutman

    Joined:
    Feb 20, 2013
    Posts:
    5
    I don't know much about PlistCS, it was just the simplest thing I could find written in C# :)
     
  7. madclouds

    madclouds

    Joined:
    Nov 6, 2013
    Posts:
    30

    What should the plist path be set to? Is there a default value?
     
  8. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,495
unityunity