using UnityEngine;
using System.Collections;
using UnityEditor.Callbacks;
using UnityEditor;
using System;
using UnityEditor.iOS.Xcode;
using System.IO;
public class AutoIncrement : MonoBehaviour {
[PostProcessBuild]
public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
{
if (buildTarget == BuildTarget.iOS)
{
// Get plist
string plistPath = pathToBuiltProject + "/Info.plist";
var plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));
// Get root
var rootDict = plist.root;
// Change value of NSCameraUsageDescription in Xcode plist
var buildKey = "NSCameraUsageDescription";
rootDict.SetString(buildKey, "Taking screenshots");
var buildKey2 = "ITSAppUsesNonExemptEncryption";
rootDict.SetString(buildKey2, "false");
// Write to file
File.WriteAllText(plistPath, plist.WriteToString());
}
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
[PostProcessBuild]
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
{
//A new build has happened so lets increase our version number
BumpBundleVersion();
}
// Bump version number in PlayerSettings.bundleVersion
private static void BumpBundleVersion()
{
float versionFloat;
if (float.TryParse(PlayerSettings.bundleVersion, out versionFloat))
{
versionFloat += 0.01f;
PlayerSettings.bundleVersion = versionFloat.ToString();
}
}
[MenuItem("Leman/Build iOS Development", false, 10)]
public static void CustomBuild()
{
BumpBundleVersion();
var levels= new String[] { "Assets\\ShootTheBall\\Scenes\\MainScene.unity" };
BuildPipeline.BuildPlayer(levels,
"iOS", BuildTarget.iOS, BuildOptions.Development);
}
}