/// <summary> /// Gets the frameworks. /// </summary> /// <param name="targetName">Name of the target.</param> /// <returns>A list of frameworks.</returns> public IEnumerable <String> GetFrameworks(String targetName) { PBXTarget target = this.GetTarget(targetName); if (target == null) { yield break; } PBXBuildPhase phase = GetTargetPhase <PBXFrameworksBuildPhase> (target); if (phase == null) { yield break; } foreach (PBXBuildFile buildFile in phase.Files) { String extension = Path.GetExtension(buildFile.FileRef.Name); if (extension.Equals(".framework")) { yield return(Path.GetFileNameWithoutExtension(buildFile.FileRef.Name)); } } }
/// <summary> /// Adds the file. /// </summary> /// <param name = "groups">The groups.</param> /// <param name = "file">The file.</param> /// <param name = "targetName">Name of the target.</param> /// <returns></returns> public PBXBuildFile AddFile(String groups, String file, String targetName) { lock (this.syncRoot) { PBXFileElement fileElement = this.AddFile(groups, file); PBXTarget target = this.GetTarget(targetName); if (target == null) { return(null); } PBXBuildPhase phase = GetTargetPhase(target, file); if (phase == null) { return(null); } PBXBuildFile buildFile = phase.FindFile(fileElement); if (buildFile == null) { buildFile = new PBXBuildFile(fileElement); phase.AddFile(buildFile); } return(buildFile); } }
/// <summary> /// Adds the framework. /// </summary> /// <param name = "groups">The groups.</param> /// <param name = "framework">The framework.</param> /// <param name = "targetName">Name of the target.</param> /// <returns></returns> public PBXBuildFile AddFramework(String groups, String framework, String targetName) { lock (this.syncRoot) { // Test for presence in System String path = String.Format(CultureInfo.CurrentCulture, "/System/Library/Frameworks/{0}.framework/{0}", framework); if (File.Exists(path)) { goto bail; } // Test for presence in Library path = String.Format(CultureInfo.CurrentCulture, "/Library/Frameworks/{0}.framework/{0}", framework); if (File.Exists(path)) { goto bail; } // Fallback: Assume it is a system framework path = String.Format(CultureInfo.CurrentCulture, "/System/Library/Frameworks/{0}.framework/{0}", framework); bail: String file = Path.GetDirectoryName(path); PBXTarget target = this.GetTarget(targetName); PBXBuildPhase phase = GetTargetPhase <PBXFrameworksBuildPhase> (target); PBXFileElement fileElement = this.AddFile(groups, file, PBXSourceTree.Absolute); PBXBuildFile buildFile = phase.FindFile(fileElement); if (buildFile == null) { buildFile = new PBXBuildFile(fileElement); phase.AddFile(buildFile); } return(buildFile); } }
/// <summary> /// Adds the library. /// </summary> /// <param name = "groups">The groups.</param> /// <param name = "library">The library.</param> /// <param name = "targetName">Name of the target.</param> /// <returns></returns> public PBXBuildFile AddLibrary(String groups, String library, String targetName) { lock (this.syncRoot) { PBXTarget target = this.GetTarget(targetName); PBXBuildPhase phase = GetTargetPhase <PBXFrameworksBuildPhase> (target); PBXFileElement fileElement = this.AddFile(groups, library, PBXSourceTree.Group); PBXBuildFile buildFile = phase.FindFile(fileElement); if (buildFile == null) { buildFile = new PBXBuildFile(fileElement); phase.AddFile(buildFile); } return(buildFile); } }
/// <summary> /// Gets the files. /// </summary> /// <param name="pattern">The pattern.</param> /// <param name="targetName">Name of the target.</param> /// <returns>A list of files.</returns> public IEnumerable <PBXBuildFile> GetFiles(String pattern, String targetName) { PBXTarget target = this.GetTarget(targetName); if (target == null) { yield break; } PBXBuildPhase phase = GetTargetPhase(target, pattern); if (phase == null) { yield break; } foreach (PBXBuildFile buildFile in phase.Files) { yield return(buildFile); } }
/// <summary> /// Removes the build phase. /// </summary> /// <param name = "phase">The phase.</param> public void RemoveBuildPhase(PBXBuildPhase phase) { this.buildPhases.Remove(phase); }
/// <summary> /// Adds the build phase. /// </summary> /// <param name = "phase">The phase.</param> public void AddBuildPhase(PBXBuildPhase phase) { this.buildPhases.Add(phase); }