public static string AddNewFileReference(IIgorModule ModuleInst, string ProjectPath, string Filename, TreeEnum TreeBase, string Path = "", int FileEncoding = -1, string LastKnownFileType = "", string Name = "") { if(IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath)) { XCProject CurrentProject = new XCProject(ProjectPath); CurrentProject.Backup(); foreach(KeyValuePair<string, PBXFileReference> CurrentFileRef in CurrentProject.fileReferences) { if(CurrentFileRef.Value.name == Filename) { IgorDebug.Log(ModuleInst, "The file " + Filename + " is already referenced in the XCodeProj."); return CurrentFileRef.Value.guid; } } PBXFileReference NewFile = new PBXFileReference(Filename, TreeBase); if(Path != "") { if(NewFile.ContainsKey("path")) { NewFile.Remove("path"); } NewFile.Add("path", Path); } if(FileEncoding != -1) { if(NewFile.ContainsKey("fileEncoding")) { NewFile.Remove("fileEncoding"); } NewFile.Add("fileEncoding", FileEncoding); } if(LastKnownFileType != "") { if(NewFile.ContainsKey("lastKnownFileType")) { NewFile.Remove("lastKnownFileType"); } NewFile.Add("lastKnownFileType", LastKnownFileType); } if(Name != "") { if(NewFile.ContainsKey("name")) { NewFile.Remove("name"); } NewFile.Add("name", Name); } CurrentProject.fileReferences.Add(NewFile); IgorDebug.Log(ModuleInst, "File " + Filename + " has been added to the XCodeProj."); CurrentProject.Save(); return NewFile.guid; } return ""; }