Skip to content

Instantly share code, notes, and snippets.

@yosun
Created December 23, 2017 11:25
Show Gist options
  • Save yosun/af058a39c400ac5fb47ed2157499381a to your computer and use it in GitHub Desktop.
Save yosun/af058a39c400ac5fb47ed2157499381a to your computer and use it in GitHub Desktop.
PostProcessor to include photo lib permissions
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using System;
using System.IO;
//=============================================================================
// This PostProcessor does all annoying Xcode steps automatically for us
//=============================================================================
public class PostProcessor
{
[PostProcessBuild]
public static void OnPostProcessBuild(BuildTarget target, string path)
{
if(target != BuildTarget.iOS) { return; }
string plistPath = Path.Combine(path, "Info.plist");
PlistDocument plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));
PlistElementDict rootDict = plist.root;
rootDict.SetString("NSPhotoLibraryUsageDescription", "Can we save your polygon photos and videos to your photo album?");
rootDict.SetString("NSPhotoLibraryAddUsageDescription", "Can we save your polygon photos and videos to your photo album?");
File.WriteAllText(plistPath, plist.WriteToString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment