Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save krisrok/f55ea7cf89010a9f54a9271953f952fd to your computer and use it in GitHub Desktop.
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)
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());
}
}
}
@marvpaul
Copy link

marvpaul commented Mar 2, 2021

Works great - thank you!

@anomal3
Copy link

anomal3 commented Nov 4, 2023

i love you bro...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment