public bool AddOtherCFlags( string flag ) { //Debug.Log( "INIZIO 1" ); PBXList flags = new PBXList(); flags.Add( flag ); return AddOtherCFlags( flags ); }
public bool AddOtherCFlags(string flag) { PBXList flags = new PBXList(); flags.Add(flag); return(AddOtherCFlags(flags)); }
protected bool AddSearchPaths(string path, string key, bool recursive = true) { PBXList paths = new PBXList(); paths.Add(path); return(AddSearchPaths(paths, key, recursive)); }
public static void SortGUIDIntoGroup(IIgorModule ModuleInst, string ProjectPath, string FileGUID, string GroupPath) { if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath)) { XCProject CurrentProject = new XCProject(ProjectPath); CurrentProject.Backup(); if (IgorAssert.EnsureTrue(ModuleInst, CurrentProject != null, "XCodeProj couldn't be loaded.")) { bool bFoundGroup = false; foreach (KeyValuePair <string, PBXGroup> CurrentGroup in CurrentProject.groups) { if (CurrentGroup.Value.path == GroupPath) { if (IgorAssert.EnsureTrue(ModuleInst, CurrentGroup.Value.ContainsKey("children"), "XCodeProj PBXGroup " + GroupPath + " doesn't have a children array.")) { object GroupChildrenObj = CurrentGroup.Value.data["children"]; if (IgorAssert.EnsureTrue(ModuleInst, GroupChildrenObj != null, "XCodeProj PBXGroup " + GroupPath + " has a children key, but it can't be retrieved.")) { if (IgorAssert.EnsureTrue(ModuleInst, typeof(PBXList).IsAssignableFrom(GroupChildrenObj.GetType()), "XCodeProj PBXGroup " + GroupPath + " has a children key, but it can't be cast to PBXList.")) { PBXList GroupChildrenList = (PBXList)GroupChildrenObj; if (IgorAssert.EnsureTrue(ModuleInst, GroupChildrenList != null, "XCodeProj casted Children List is null.")) { if (GroupChildrenList.Contains(FileGUID)) { IgorDebug.Log(ModuleInst, "FileGUID " + FileGUID + " has already been added to the Group " + CurrentGroup.Key + "."); } else { GroupChildrenList.Add(FileGUID); CurrentGroup.Value.data["children"] = GroupChildrenList; IgorDebug.Log(ModuleInst, "Added the " + FileGUID + " file to the Group " + CurrentGroup.Key + "."); } } } } bFoundGroup = true; break; } } } IgorAssert.EnsureTrue(ModuleInst, bFoundGroup, "Couldn't find a PBXGroup with path " + GroupPath + " in the XCodeProj."); CurrentProject.Save(); } } }
//CodeSignOnCopy public bool AddCodeSignOnCopy() { if( !_data.ContainsKey( SETTINGS_KEY ) ) _data[ SETTINGS_KEY ] = new PBXDictionary(); var settings = _data[ SETTINGS_KEY ] as PBXDictionary; if( !settings.ContainsKey( ATTRIBUTES_KEY ) ) { var attributes = new PBXList(); attributes.Add( "CodeSignOnCopy" ); attributes.Add( "RemoveHeadersOnCopy" ); settings.Add( ATTRIBUTES_KEY, attributes ); } else { var attributes = settings[ ATTRIBUTES_KEY ] as PBXList; attributes.Add( "CodeSignOnCopy" ); attributes.Add( "RemoveHeadersOnCopy" ); } return true; }
public bool SetWeakLink(bool weak = false) { PBXDictionary settings = null; PBXList attributes = null; if (!_data.ContainsKey(SETTINGS_KEY)) { if (weak) { attributes = new PBXList(); attributes.Add(WEAK_VALUE); settings = new PBXDictionary(); settings.Add(ATTRIBUTES_KEY, attributes); _data.Add(SETTINGS_KEY, settings); } return(true); } settings = _data[SETTINGS_KEY] as PBXDictionary; if (!settings.ContainsKey(ATTRIBUTES_KEY)) { if (weak) { attributes = new PBXList(); attributes.Add(WEAK_VALUE); settings.Add(ATTRIBUTES_KEY, attributes); return(true); } else { return(false); } } else { attributes = settings[ATTRIBUTES_KEY] as PBXList; } if (weak) { attributes.Add(WEAK_VALUE); } else { attributes.Remove(WEAK_VALUE); } settings.Add(ATTRIBUTES_KEY, attributes); this.Add(SETTINGS_KEY, settings); return(true); }
//CodeSignOnCopy public bool AddCodeSignOnCopy() { if (!_data.ContainsKey(SETTINGS_KEY)) { _data[SETTINGS_KEY] = new PBXDictionary(); } var settings = _data[SETTINGS_KEY] as PBXDictionary; if (!settings.ContainsKey(ATTRIBUTES_KEY)) { var attributes = new PBXList(); attributes.Add("CodeSignOnCopy"); attributes.Add("RemoveHeadersOnCopy"); settings.Add(ATTRIBUTES_KEY, attributes); } else { var attributes = settings[ATTRIBUTES_KEY] as PBXList; attributes.Add("CodeSignOnCopy"); attributes.Add("RemoveHeadersOnCopy"); } return(true); }
public bool SetWeakLink( bool weak = false ) { PBXDictionary settings = null; PBXList attributes = null; _data.Remove(SETTINGS_KEY); if( !_data.ContainsKey( SETTINGS_KEY ) ) { if( weak ) { attributes = new PBXList(); attributes.Add( WEAK_VALUE ); settings = new PBXDictionary(); settings.Add( ATTRIBUTES_KEY, attributes ); _data.Add( SETTINGS_KEY, settings ); } return true; } settings = _data[ SETTINGS_KEY ] as PBXDictionary; if( !settings.ContainsKey( ATTRIBUTES_KEY ) ) { if( weak ) { attributes = new PBXList(); attributes.Add( WEAK_VALUE ); settings.Add( ATTRIBUTES_KEY, attributes ); return true; } else { return false; } } else { attributes = settings[ ATTRIBUTES_KEY ] as PBXList; } if( weak ) { attributes.Add( WEAK_VALUE ); } else { attributes.Remove( WEAK_VALUE ); } settings.Add( ATTRIBUTES_KEY, attributes ); this.Add( SETTINGS_KEY, settings ); return true; }
protected bool AddSearchPaths( PBXList paths, string key, bool recursive = true, bool quoted = false ) //we want no quoting whenever we can get away with it { //Debug.Log ("AddSearchPaths " + paths + key + (recursive?" recursive":"") + " " + (quoted?" quoted":"")); bool modified = false; if( !ContainsKey( BUILDSETTINGS_KEY ) ) this.Add( BUILDSETTINGS_KEY, new PBXSortedDictionary() ); foreach( string path in paths ) { string currentPath = path; //Debug.Log ("path " + currentPath); if( !((PBXDictionary)_data[BUILDSETTINGS_KEY]).ContainsKey( key ) ) { ((PBXDictionary)_data[BUILDSETTINGS_KEY]).Add( key, new PBXList() ); } else if( ((PBXDictionary)_data[BUILDSETTINGS_KEY])[key] is string ) { PBXList list = new PBXList(); list.Add( ((PBXDictionary)_data[BUILDSETTINGS_KEY])[key] ); ((PBXDictionary)_data[BUILDSETTINGS_KEY])[key] = list; } //Xcode uses space as the delimiter here, so if there's a space in the filename, we *must* quote. Escaping with slash may work when you are in the Xcode UI, in some situations, but it doesn't work here. if (currentPath.Contains(@" ")) quoted = true; if (quoted) { //if it ends in "/**", it wants to be recursive, and the "/**" needs to be _outside_ the quotes if (currentPath.EndsWith("/**")) { currentPath = "\\\"" + currentPath.Replace("/**", "\\\"/**"); } else { currentPath = "\\\"" + currentPath + "\\\""; } } //Debug.Log ("currentPath = " + currentPath); if( !((PBXList)((PBXDictionary)_data[BUILDSETTINGS_KEY])[key]).Contains( currentPath ) ) { ((PBXList)((PBXDictionary)_data[BUILDSETTINGS_KEY])[key]).Add( currentPath ); modified = true; } } return modified; }
protected bool AddSearchPaths(PBXList paths, string key, bool recursive = true) { bool modified = false; if (!ContainsKey(BUILDSETTINGS_KEY)) { this.Add(BUILDSETTINGS_KEY, new PBXDictionary()); } foreach (string path in paths) { string currentPath = path; if (recursive && !path.EndsWith("/**")) { currentPath += "/**"; } if (!((PBXDictionary)_data[BUILDSETTINGS_KEY]).ContainsKey(key)) { ((PBXDictionary)_data[BUILDSETTINGS_KEY]).Add(key, new PBXList()); } else if (((PBXDictionary)_data[BUILDSETTINGS_KEY])[key] is string) { PBXList list = new PBXList(); list.Add(((PBXDictionary)_data[BUILDSETTINGS_KEY])[key]); ((PBXDictionary)_data[BUILDSETTINGS_KEY])[key] = list; } currentPath = "\\\"" + currentPath + "\\\""; if (!((PBXList)((PBXDictionary)_data[BUILDSETTINGS_KEY])[key]).Contains(currentPath)) { ((PBXList)((PBXDictionary)_data[BUILDSETTINGS_KEY])[key]).Add(currentPath); modified = true; } } return(modified); }
protected bool AddSearchPaths( PBXList paths, string key, bool recursive = true ) { bool modified = false; if( !ContainsKey( BUILDSETTINGS_KEY ) ) this.Add( BUILDSETTINGS_KEY, new PBXDictionary() ); foreach( string path in paths ) { string currentPath = path; if( recursive && !path.EndsWith( "/**" ) ) currentPath += "/**"; // Debug.Log( "adding: " + currentPath ); if( !((PBXDictionary)_data[BUILDSETTINGS_KEY]).ContainsKey( key ) ) { ((PBXDictionary)_data[BUILDSETTINGS_KEY]).Add( key, new PBXList() ); } else if( ((PBXDictionary)_data[BUILDSETTINGS_KEY])[key] is string ) { PBXList list = new PBXList(); list.Add( ((PBXDictionary)_data[BUILDSETTINGS_KEY])[key] ); ((PBXDictionary)_data[BUILDSETTINGS_KEY])[key] = list; } currentPath = "\\\"" + currentPath + "\\\""; if( !((PBXList)((PBXDictionary)_data[BUILDSETTINGS_KEY])[key]).Contains( currentPath ) ) { ((PBXList)((PBXDictionary)_data[BUILDSETTINGS_KEY])[key]).Add( currentPath ); modified = true; } } return modified; }
protected bool AddSearchPaths( string path, string key, bool recursive = true ) { PBXList paths = new PBXList(); paths.Add( path ); return AddSearchPaths( paths, key, recursive ); }
public bool AddOtherLinkerFlags( string flag ) { PBXList flags = new PBXList(); flags.Add( flag ); return AddOtherLinkerFlags( flags ); }
private PBXList ParseArray() { PBXList list = new PBXList(); bool complete = false; while( !complete ) { switch( NextToken() ) { case END_OF_FILE: Debug.Log( "Error: Reached end of file inside a list: " + list ); complete = true; break; case ARRAY_END_TOKEN: complete = true; break; case ARRAY_ITEM_DELIMITER_TOKEN: break; default: StepBackward(); list.Add( ParseValue() ); break; } } return list; }
public static void AddFramework(IIgorModule ModuleInst, string ProjectPath, string Filename, TreeEnum TreeBase, string Path = "", int FileEncoding = -1, string LastKnownFileType = "", string Name = "") { string FrameworkFileRefGUID = AddNewFileReference(ModuleInst, ProjectPath, Filename, TreeBase, Path, FileEncoding, LastKnownFileType, Name); if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath)) { XCProject CurrentProject = new XCProject(ProjectPath); CurrentProject.Backup(); if (IgorAssert.EnsureTrue(ModuleInst, CurrentProject != null, "XCodeProj couldn't be loaded.")) { bool bFoundFrameworksGroup = false; foreach (KeyValuePair <string, PBXGroup> CurrentGroup in CurrentProject.groups) { if (CurrentGroup.Value.name == "Frameworks") { if (IgorAssert.EnsureTrue(ModuleInst, CurrentGroup.Value.ContainsKey("children"), "XCodeProj Frameworks PBXGroup doesn't have a children array.")) { object FrameworkChildrenObj = CurrentGroup.Value.data["children"]; if (IgorAssert.EnsureTrue(ModuleInst, FrameworkChildrenObj != null, "XCodeProj Frameworks PBXGroup has a children key, but it can't be retrieved.")) { if (IgorAssert.EnsureTrue(ModuleInst, typeof(PBXList).IsAssignableFrom(FrameworkChildrenObj.GetType()), "XCodeProj Frameworks PBXGroup has a children key, but it can't be cast to PBXList.")) { PBXList FrameworkChildrenList = (PBXList)FrameworkChildrenObj; if (IgorAssert.EnsureTrue(ModuleInst, FrameworkChildrenList != null, "XCodeProj casted Framework Children List is null.")) { if (FrameworkChildrenList.Contains(FrameworkFileRefGUID)) { IgorDebug.Log(ModuleInst, "Framework " + Filename + " has already been added to the Framework Group " + CurrentGroup.Key + "."); } else { FrameworkChildrenList.Add(FrameworkFileRefGUID); CurrentGroup.Value.data["children"] = FrameworkChildrenList; IgorDebug.Log(ModuleInst, "Added the " + Filename + " framework to the Framework Group " + CurrentGroup.Key + "."); } } } } bFoundFrameworksGroup = true; break; } } } IgorAssert.EnsureTrue(ModuleInst, bFoundFrameworksGroup, "Couldn't find a Frameworks PBXGroup in the XCodeProj."); CurrentProject.Save(); } } string FrameworkBuildFileGUID = AddNewBuildFile(ModuleInst, ProjectPath, FrameworkFileRefGUID); if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath)) { XCProject CurrentProject = new XCProject(ProjectPath); CurrentProject.Backup(); if (IgorAssert.EnsureTrue(ModuleInst, CurrentProject != null, "XCodeProj couldn't be loaded.")) { foreach (KeyValuePair <string, PBXFrameworksBuildPhase> CurrentTarget in CurrentProject.frameworkBuildPhases) { if (IgorAssert.EnsureTrue(ModuleInst, CurrentTarget.Value.ContainsKey("files"), "XCodeProj Framework Build Phase doesn't have a files array.")) { object FrameworkFilesObj = CurrentTarget.Value.data["files"]; if (IgorAssert.EnsureTrue(ModuleInst, FrameworkFilesObj != null, "XCodeProj Framework Build Phase has a files key, but it can't be retrieved.")) { if (IgorAssert.EnsureTrue(ModuleInst, typeof(PBXList).IsAssignableFrom(FrameworkFilesObj.GetType()), "XCodeProj Framework Build Phase has a files key, but it can't be cast to PBXList.")) { PBXList FrameworkFilesList = (PBXList)FrameworkFilesObj; if (IgorAssert.EnsureTrue(ModuleInst, FrameworkFilesList != null, "XCodeProj casted Framework File List is null.")) { if (FrameworkFilesList.Contains(FrameworkBuildFileGUID)) { IgorDebug.Log(ModuleInst, "Framework " + Filename + " has already been added to the Framework Build Phase " + CurrentTarget.Key + "."); } else { FrameworkFilesList.Add(FrameworkBuildFileGUID); CurrentTarget.Value.data["files"] = FrameworkFilesList; IgorDebug.Log(ModuleInst, "Added the " + Filename + " framework to the Framework Build Phase " + CurrentTarget.Key + "."); } } } } } } CurrentProject.Save(); } } }
// flattens framework search paths into the target level, to fix some incompatibilities with other plugins private static void FlattenFrameworks(XCProject project) { var allFrameworkSearchPaths = new HashSet <string>(); // collect & remove search paths from the project level { var projectBuildConfigListId = project.project.data["buildConfigurationList"] as string; var buildConfigurations = GetBuildConfigurations(project, projectBuildConfigListId); foreach (var xcBuildConfig in buildConfigurations) { // collect all unique search paths if (xcBuildConfig.buildSettings.ContainsKey("FRAMEWORK_SEARCH_PATHS")) { var frameworkSearchPaths = xcBuildConfig.buildSettings["FRAMEWORK_SEARCH_PATHS"]; foreach (var searchPath in SafeToStringList(frameworkSearchPaths)) { allFrameworkSearchPaths.Add(searchPath); } // remove from project level, all items will be moved to target level xcBuildConfig.buildSettings.Remove("FRAMEWORK_SEARCH_PATHS"); } } } // collect framework search paths from target level foreach (var target in project.nativeTargets.Values) { var configurationListId = target.data["buildConfigurationList"] as string; var buildConfigurations = GetBuildConfigurations(project, configurationListId); foreach (var xcBuildConfig in buildConfigurations) { // collect all unique search paths if (xcBuildConfig.buildSettings.ContainsKey("FRAMEWORK_SEARCH_PATHS")) { var frameworkSearchPaths = xcBuildConfig.buildSettings["FRAMEWORK_SEARCH_PATHS"]; foreach (var searchPath in SafeToStringList(frameworkSearchPaths)) { allFrameworkSearchPaths.Add(searchPath); } // remove, we'll build a new list to add later xcBuildConfig.buildSettings.Remove("FRAMEWORK_SEARCH_PATHS"); } } } // the double quoted ""$(inherited)"" causes all sorts of issues, remove it allFrameworkSearchPaths.Remove("\"\\\"$(inherited)\\\"\""); // rebuild framework search paths for the target level var finalFrameworkSearchPaths = new PBXList(); foreach (var searchPath in allFrameworkSearchPaths) { finalFrameworkSearchPaths.Add(searchPath); } // set FRAMEWORK_SEARCH_PATHS for each native target foreach (var target in project.nativeTargets.Values) { var configurationListId = target.data["buildConfigurationList"] as string; var buildConfigurations = GetBuildConfigurations(project, configurationListId); foreach (var xcBuildConfig in buildConfigurations) { xcBuildConfig.buildSettings.Add("FRAMEWORK_SEARCH_PATHS", finalFrameworkSearchPaths); } } }