Created
October 17, 2018 20:28
-
-
Save krisrok/f55ea7cf89010a9f54a9271953f952fd to your computer and use it in GitHub Desktop.
Auto-enable ITunes file sharing for Unity app (put script in an Editor-folder)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using UnityEditor; | |
using UnityEditor.Callbacks; | |
using UnityEditor.iOS.Xcode; | |
public class EnableFileSharingPostBuildProcessor | |
{ | |
[PostProcessBuild] | |
public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject) | |
{ | |
if (buildTarget == BuildTarget.iOS) | |
{ | |
// Get plist | |
string plistPath = pathToBuiltProject + "/Info.plist"; | |
PlistDocument plist = new PlistDocument(); | |
plist.ReadFromString(File.ReadAllText(plistPath)); | |
// Get root | |
PlistElementDict rootDict = plist.root; | |
rootDict.SetBoolean("UIFileSharingEnabled", true); | |
// Write to file | |
File.WriteAllText(plistPath, plist.WriteToString()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works great - thank you!