public override bool PostprocessBuild(BuildTarget target, string buildPath, string dataPath) { if (!PathsValid) { Debug.LogError("Paths not valid: " + m_errorMessage); return false; } BuildPath = Path.GetFullPath(buildPath); try{ UniqueIds = new Dictionary<string, XcodeObject>(); //Load pbxproj file Console.WriteLine("Loading .xcodeproj at " + buildPath + "/" + kProjectPath); StreamReader reader = new StreamReader(buildPath + "/" + kProjectPath); reader.ReadLine(); //Eat explicit encoding header XcodeObject proj = new XcodeObject(reader, UniqueIds); reader.Close(); //Setup important properties FindRequiredFrameworks(); ObjectRoot = proj.children["objects"]; ObjectRoot.DefinePreExistingObjects(); ProjectObject = ObjectRoot.children[proj.literals["rootObject"]]; RootGroup = ObjectRoot.children[ProjectObject.literals["mainGroup"]]; List<XcodeObject> mainTargetBuildPhases = ProjectObject.ParseIDList("targets")[0].ParseIDList("buildPhases"); MainTargetFrameworkPhase = mainTargetBuildPhases.Find(delegate(XcodeObject obj){return obj.literals["isa"] == "PBXFrameworksBuildPhase";}); MainTargetResourcePhase = mainTargetBuildPhases.Find(delegate(XcodeObject obj){return obj.literals["isa"] == "PBXResourcesBuildPhase";}); MainTargetSourcePhase = mainTargetBuildPhases.Find(delegate(XcodeObject obj){return obj.literals["isa"] == "PBXSourcesBuildPhase";}); //Remove secondary targets (currently only the non-functional simulator target) string[] buildTargetIDs = XcodeObject.SplitPCSVList(ProjectObject.literals["targets"]); ProjectObject.literals.Remove("targets"); ProjectObject.AddLiteralListElement("targets", buildTargetIDs[0]); //Add required frameworks Console.WriteLine("Adding required frameworks"); foreach(string frameworkPath in RequiredFrameworks){ Console.WriteLine(">\t" + frameworkPath); AddSDKFramework(frameworkPath); } //Add files Console.WriteLine("Adding specified directories and frameworks"); for(int i = 0; i < m_paths.Length; i++){ if (!m_paths[i].isFrameworkLink) { Console.WriteLine("DIR>\t"+m_paths[i].path); AddDirectoryRecursively(m_paths[i].path, buildPath, RootGroup); } else if (!RequiredFrameworks.Contains(m_paths[i].path)) { Console.WriteLine("FWK>\t"+m_paths[i].path); AddSDKFramework(m_paths[i].path); } } //Save modified file Console.WriteLine("Saving .xcodeproj file"); StreamWriter writer = new StreamWriter(buildPath + "/" + kProjectPath); //Overwrite .pbxproj file writer.Write("// !$*UTF8*$!\n"); //Explicit format header proj.Save(writer, 0); writer.Close(); } catch(Exception e){ Debug.LogError(e.ToString()); return false; } return true; }