/// <summary> /// Removes the dependant project. /// </summary> /// <param name = "project">The project.</param> /// <param name = "targetName">Name of the target.</param> public void RemoveDependantProject(XcodeProject project, String targetName) { lock (this.syncRoot) { // Get the native target PBXNativeTarget target = project.GetDefaultTarget() as PBXNativeTarget; if (target == null) { return; } // Get the product reference PBXFileReference productReference = target.ProductReference; // Add a dummy group for references PBXGroup referenceGroup = this.AddGroup("References"); // Find the reference proxy String path = Path.GetFileName(productReference.Path); PBXReferenceProxy referenceProxy = referenceGroup.Children.OfType <PBXReferenceProxy>().FirstOrDefault(r => r.Path == path); if (referenceProxy == null) { return; } this.RemoveDependantProject(referenceProxy); } }
/// <summary> /// Clears the dependant projects. /// </summary> /// <param name="targetName">Name of the target.</param> /// <returns>A list of files.</returns> public void ClearDependantProjects(String targetName) { lock (this.syncRoot) { List <PBXReferenceProxy> proxies = new List <PBXReferenceProxy> (this.DependantProjects); for (int i = 0; i < proxies.Count; i++) { PBXReferenceProxy referenceProxy = proxies [i]; this.RemoveDependantProject(referenceProxy); } } }
/// <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); } }
/// <summary> /// Adds the dependant project. /// </summary> /// <param name = "project">The project.</param> /// <param name = "targetName">Name of the target.</param> public void AddDependantProject(XcodeProject project, String targetName) { lock (this.syncRoot) { // Get the native target PBXNativeTarget target = project.GetDefaultTarget() as PBXNativeTarget; if (target == null) { return; } // Get the product reference PBXFileReference productReference = target.ProductReference; // Add a dummy group for references PBXGroup referecenGroup = this.AddGroup("References"); // Add file reference PBXFileReference fileReference = this.AddFile(String.Empty, project.ProjectFolder) as PBXFileReference; // Add proxy PBXContainerItemProxy itemProxy = new PBXContainerItemProxy(); itemProxy.ContainerPortal = fileReference; itemProxy.ProxyType = 2; // TODO: Find other values itemProxy.RemoteInfo = Path.GetFileNameWithoutExtension(fileReference.Name); itemProxy.RemoteGlobalIDString = project.Document.Mapping [productReference]; // Add reference proxy PBXReferenceProxy referenceProxy = new PBXReferenceProxy(); referenceProxy.RemoteRef = itemProxy; referenceProxy.SourceTree = PBXSourceTree.BuildProductDir; referenceProxy.FileType = productReference.ExplicitFileType; referenceProxy.Path = Path.GetFileName(productReference.Path); // Add reference proxy referecenGroup.AddChild(referenceProxy); // Add association this.Project.AddProjectReference(referecenGroup, fileReference); } }