Skip to content

Instantly share code, notes, and snippets.

@rainbow23
Last active January 20, 2016 06:29
Show Gist options
  • Save rainbow23/824b9cdb81267acf1a4b to your computer and use it in GitHub Desktop.
Save rainbow23/824b9cdb81267acf1a4b to your computer and use it in GitHub Desktop.
Unity > Xcodeビルド時 pbx, plistを編集できた
using UnityEngine;
using System.Collections;
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
public class AddFrameworkPostProcessBuild : MonoBehaviour {
[PostProcessBuild ]
public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
{
if (buildTarget != BuildTarget.iPhone) return;
string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
PBXProject proj = new PBXProject();
proj.ReadFromFile(projPath);
string target = proj.TargetGuidByName("Unity-iPhone");
proj.AddFrameworkToProject(target, "ImageIO.framework", false);
proj.AddBuildProperty (target, "LIBRARY_SEARCH_PATHS", "$(inherited)");
proj.AddBuildProperty (target, "LIBRARY_SEARCH_PATHS", "$(SRCROOT)");
proj.AddBuildProperty (target, "LIBRARY_SEARCH_PATHS", "$(SRCROOT)/Libraries");
proj.WriteToFile(projPath);
var plistPath = Path.Combine(path, "Info.plist");
var plist = new PlistDocument();
plist.ReadFromFile(plistPath);
//HTTP接続を行う
PlistElementDict rootDict = plist.root;
PlistElementDict urlTypes = rootDict.CreateDict("NSAppTransportSecurity");
urlTypes.SetBoolean("NSAllowsArbitraryLoads", true);
//plist.WriteToFile(plistPath);
// 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