/// <summary> /// Removes the group. /// </summary> /// <param name = "groups">The groups.</param> /// <returns></returns> public PBXGroup RemoveGroup(String groups) { lock (this.syncRoot) { // Only keep the n-1 groups List <String> parts = groups.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).ToList(); String last = parts.Last(); parts.RemoveAt(parts.Count - 1); // Go to the parent group PBXGroup g, group = this.Document.Project.MainGroup; foreach (String part in parts) { g = group.FindGroup(part); if (g == null) { // For each group not found, create it g = new PBXGroup(part); group.AddChild(g); } group = g; } // If the group to delete exists, remove it g = group.FindGroup(last); if (g != null) { group.RemoveChild(g); } return(g); } }
/// <summary> /// Removes the file. /// </summary> /// <param name = "groups">The groups.</param> /// <param name = "file">The file.</param> /// <returns></returns> public PBXFileReference RemoveFile(String groups, String file) { lock (this.syncRoot) { // Prepare the group that contains the file PBXGroup group = this.GetGroup(groups); PBXFileReference fileReference = null; PBXFileElement result = null; // Extract information String name = Path.GetFileName(file); String parentDir = Path.GetDirectoryName(file); // If the file is localized, search for the variant group if (Path.GetExtension(parentDir).Equals(".lproj")) { PBXVariantGroup variantGroup = group.FindVariantGroup(name); if (variantGroup != null) { // The file is named like the language name = Path.GetFileNameWithoutExtension(parentDir); } group = variantGroup; result = variantGroup; } if (group != null) { // Search for the file and remove it fileReference = group.FindFileReference(name); if (fileReference != null) { group.RemoveChild(fileReference); } } if (result == null) { result = fileReference; } return(fileReference); } }
/// <summary> /// Removes the dependant project. /// </summary> /// <param name="referenceProxy">The reference proxy.</param> private void RemoveDependantProject(PBXReferenceProxy referenceProxy) { lock (this.syncRoot) { // Add a dummy group for references PBXGroup referenceGroup = this.AddGroup("References"); // Get proxies references PBXContainerItemProxy containerItemProxy = referenceProxy.RemoteRef; PBXFileReference fileReference = containerItemProxy.ContainerPortal; // Remove file reference this.Project.MainGroup.RemoveChild(fileReference); // Remove proxy referenceGroup.RemoveChild(referenceProxy); // Remove association this.Project.RemoveProjectReference(fileReference); } }