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
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?
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.
We’re adding custom url schemes using a PostProcessBuild method and PlistCS :
protected virtual void PostprocessXcodePlist() {
// set plist path
string plistPath = "...";
// read plist
Dictionary<string, object> dict;
dict = (Dictionary<string, object>)Plist.readPlist(plistPath);
// update plist
dict["CFBundleURLTypes"] = new List<object> {
new Dictionary<string,object> {
{ "CFBundleURLName", PlayerSettings.iPhoneBundleIdentifier },
{ "CFBundleURLSchemes", new List<object> { PlayerSettings.iPhoneBundleIdentifier } }
}
};
// write plist
Plist.writeXml(dict, plistPath);
}
lukelutman:
We’re adding custom url schemes using a PostProcessBuild method and PlistCS :
protected virtual void PostprocessXcodePlist() {
// set plist path
string plistPath = "...";
// read plist
Dictionary<string, object> dict;
dict = (Dictionary<string, object>)Plist.readPlist(plistPath);
// update plist
dict["CFBundleURLTypes"] = new List<object> {
new Dictionary<string,object> {
{ "CFBundleURLName", PlayerSettings.iPhoneBundleIdentifier },
{ "CFBundleURLSchemes", new List<object> { PlayerSettings.iPhoneBundleIdentifier } }
}
};
// write plist
Plist.writeXml(dict, plistPath);
}
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
I don’t know much about PlistCS, it was just the simplest thing I could find written in C#
What should the plist path be set to? Is there a default value?
Look at http://docs.unity3d.com/ScriptReference/Callbacks.PostProcessBuildAttribute.html
The second parameter is path to built project. Just append “/info.plist”.