public static string AddFileToEmbedLibraries( this PBXProject proj, string targetGuid, string fileGuid) { PBXNativeTargetData nativeTarget = proj.nativeTargets[targetGuid]; string index = proj.AddCopyFilesBuildPhase(targetGuid, "Embed Libraries", "", "10"); PBXCopyFilesBuildPhaseData copyFile = proj.copyFiles[index]; PBXBuildFileData buildFile = proj.FindFrameworkByFileGuid(copyFile, fileGuid); if (buildFile == null) { buildFile = PBXBuildFileData.CreateFromFile(fileGuid, false, (string)null); proj.BuildFilesAdd(targetGuid, buildFile); copyFile.files.AddGUID(buildFile.guid); } proj.AddBuildProperty(targetGuid, "FRAMEWORK_SEARCH_PATHS", "$(inherited)"); proj.AddBuildProperty(targetGuid, "FRAMEWORK_SEARCH_PATHS", "$(PROJECT_DIR)"); proj.AddBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", "@executable_path/Frameworks"); proj.AddBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", "@executable_path/../Frameworks"); buildFile.codeSignOnCopy = true; buildFile.removeHeadersOnCopy = true; return(buildFile.guid); }
internal PBXNativeTargetData CreateNewTarget(string name, string ext, string type) { // create build configurations var releaseBuildConfig = XCBuildConfigurationData.Create("Release"); buildConfigs.AddEntry(releaseBuildConfig); var debugBuildConfig = XCBuildConfigurationData.Create("Debug"); buildConfigs.AddEntry(debugBuildConfig); var buildConfigList = XCConfigurationListData.Create(); configs.AddEntry(buildConfigList); buildConfigList.buildConfigs.AddGUID(releaseBuildConfig.guid); buildConfigList.buildConfigs.AddGUID(debugBuildConfig.guid); // create build file reference string fullName = name + ext; var productFileRef = AddFile(fullName, "Products/" + fullName, PBXSourceTree.Build); var newTarget = PBXNativeTargetData.Create(name, productFileRef, type, buildConfigList.guid); nativeTargets.AddEntry(newTarget); project.project.targets.Add(newTarget.guid); return(newTarget); }
// Embeds Framework to the project. // Creates a copy phase called 'Embed Frameworks', adds 'filename' framework there and sets LD_RUNPATH_SEARCH_PATHS to "$(inherited) @executable_path/Frameworks public void EmbedFramework(string targetGuid, string fileGuid) { PBXNativeTargetData target = nativeTargets[targetGuid]; PBXBuildFileData frameworkEmbedFileData = null; var embedFrameworkPhase = FindEmbedFrameworkPhase(); if (embedFrameworkPhase == null) { embedFrameworkPhase = PBXCopyFilesBuildPhaseData.Create("Embed Frameworks", "10"); copyFiles.AddEntry(embedFrameworkPhase); target.phases.AddGUID(embedFrameworkPhase.guid); } else { frameworkEmbedFileData = FindFrameworkByFileGuid(embedFrameworkPhase, fileGuid); } if (frameworkEmbedFileData == null) { frameworkEmbedFileData = PBXBuildFileData.CreateFromFile(fileGuid, false, null); frameworkEmbedFileData.codeSignOnCopy = true; frameworkEmbedFileData.removeHeadersOnCopy = true; BuildFilesAdd(targetGuid, frameworkEmbedFileData); embedFrameworkPhase.files.AddGUID(frameworkEmbedFileData.guid); } frameworkEmbedFileData.AddCodeSignOnCopy(); AddBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks"); }
private void AddBuildFileImpl(string targetGuid, string fileGuid, bool weak, string compileFlags) { PBXNativeTargetData target = this.nativeTargets[targetGuid]; PBXFileReferenceData data2 = this.FileRefsGet(fileGuid); string extension = Path.GetExtension(data2.path); if (FileTypeUtils.IsBuildable(extension, data2.isFolderReference) && (this.BuildFilesGetForSourceFile(targetGuid, fileGuid) == null)) { PBXBuildFileData buildFile = PBXBuildFileData.CreateFromFile(fileGuid, weak, compileFlags); this.BuildFilesAdd(targetGuid, buildFile); this.BuildSectionAny(target, extension, data2.isFolderReference).files.AddGUID(buildFile.guid); } }
public string BuildConfigByName(string targetGuid, string name) { PBXNativeTargetData target = nativeTargets[targetGuid]; foreach (string guid in configs[target.buildConfigList].buildConfigs) { var buildConfig = buildConfigs[guid]; if (buildConfig != null && buildConfig.name == name) { return(buildConfig.guid); } } return(null); }
public string BuildConfigByName(string targetGuid, string name) { PBXNativeTargetData data = this.nativeTargets[targetGuid]; foreach (string str in (IEnumerable <string>) this.configs[data.buildConfigList].buildConfigs) { XCBuildConfigurationData data2 = this.buildConfigs[str]; if ((data2 != null) && (data2.name == name)) { return(data2.guid); } } return(null); }
public FileGUIDListBase BuildSectionAny(PBXNativeTargetData target, string path, bool isFolderRef) { string ext = Path.GetExtension(path); var phase = FileTypeUtils.GetFileType(ext, isFolderRef); switch (phase) { case PBXFileType.Framework: foreach (var guid in target.phases) { if (frameworks.HasEntry(guid)) { return(frameworks[guid]); } } break; case PBXFileType.Resource: foreach (var guid in target.phases) { if (resources.HasEntry(guid)) { return(resources[guid]); } } break; case PBXFileType.Source: foreach (var guid in target.phases) { if (sources.HasEntry(guid)) { return(sources[guid]); } } break; case PBXFileType.CopyFile: foreach (var guid in target.phases) { if (copyFiles.HasEntry(guid)) { return(copyFiles[guid]); } } break; } return(null); }
public void AddExternalLibraryDependency(string targetGuid, string filename, string remoteFileGuid, string projectPath, string remoteInfo) { PBXNativeTargetData target = this.nativeTargets[targetGuid]; filename = PBXPath.FixSlashes(filename); projectPath = PBXPath.FixSlashes(projectPath); string containerRef = this.FindFileGuidByRealPath(projectPath); if (containerRef == null) { throw new Exception("No such project"); } string guid = null; foreach (ProjectReference reference in this.project.project.projectReferences) { if (reference.projectRef == containerRef) { guid = reference.group; break; } } if (guid == null) { throw new Exception("Malformed project: no project in project references"); } PBXGroupData data2 = this.GroupsGet(guid); string extension = Path.GetExtension(filename); if (!FileTypeUtils.IsBuildableFile(extension)) { throw new Exception("Wrong file extension"); } PBXContainerItemProxyData data3 = PBXContainerItemProxyData.Create(containerRef, "2", remoteFileGuid, remoteInfo); this.containerItems.AddEntry(data3); string typeName = FileTypeUtils.GetTypeName(extension); PBXReferenceProxyData data4 = PBXReferenceProxyData.Create(filename, typeName, data3.guid, "BUILT_PRODUCTS_DIR"); this.references.AddEntry(data4); PBXBuildFileData buildFile = PBXBuildFileData.CreateFromFile(data4.guid, false, null); this.BuildFilesAdd(targetGuid, buildFile); this.BuildSectionAny(target, extension, false).files.AddGUID(buildFile.guid); data2.children.AddGUID(data4.guid); }
public static void AddFileToEmbedFrameworks(this PBXProject proj, string targetGuid, string fileGuid) { PBXNativeTargetData nativeTargetData = proj.nativeTargets[targetGuid]; string index = proj.AddCopyFilesBuildPhase(targetGuid, "Embed Frameworks", "", "10"); PBXCopyFilesBuildPhaseData phase = proj.copyFiles[index]; PBXBuildFileData buildFile = proj.FindFrameworkByFileGuid(phase, fileGuid); if (buildFile == null) { buildFile = PBXBuildFileData.CreateFromFile(fileGuid, false, (string)null); proj.BuildFilesAdd(targetGuid, buildFile); phase.files.AddGUID(buildFile.guid); } proj.SetBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", "@executable_path/Frameworks"); buildFile.codeSignOnCopy = true; buildFile.removeHeadersOnCopy = true; }
internal static void AddExternalLibraryDependency(this PBXProject proj, string targetGuid, string filename, string remoteFileGuid, string projectPath, string remoteInfo) { PBXNativeTargetData target = proj.nativeTargets[targetGuid]; filename = PBXPath.FixSlashes(filename); projectPath = PBXPath.FixSlashes(projectPath); string fileGuidByRealPath = proj.FindFileGuidByRealPath(projectPath); if (fileGuidByRealPath == null) { throw new Exception("No such project"); } string guid = (string)null; foreach (ProjectReference projectReference in proj.project.project.projectReferences) { if (projectReference.projectRef == fileGuidByRealPath) { guid = projectReference.group; break; } } if (guid == null) { throw new Exception("Malformed project: no project in project references"); } PBXGroupData pbxGroupData = proj.GroupsGet(guid); string extension = Path.GetExtension(filename); if (!FileTypeUtils.IsBuildableFile(extension)) { throw new Exception("Wrong file extension"); } PBXContainerItemProxyData containerItemProxyData = PBXContainerItemProxyData.Create(fileGuidByRealPath, "2", remoteFileGuid, remoteInfo); proj.containerItems.AddEntry(containerItemProxyData); string typeName = FileTypeUtils.GetTypeName(extension); PBXReferenceProxyData referenceProxyData = PBXReferenceProxyData.Create(filename, typeName, containerItemProxyData.guid, "BUILT_PRODUCTS_DIR"); proj.references.AddEntry(referenceProxyData); PBXBuildFileData fromFile = PBXBuildFileData.CreateFromFile(referenceProxyData.guid, false, (string)null); proj.BuildFilesAdd(targetGuid, fromFile); proj.BuildSectionAny(target, extension, false).files.AddGUID(fromFile.guid); pbxGroupData.children.AddGUID(referenceProxyData.guid); }
public FileGUIDListBase BuildSectionAny(PBXNativeTargetData target, string path, bool isFolderRef) { switch (FileTypeUtils.GetFileType(Path.GetExtension(path), isFolderRef)) { case PBXFileType.Framework: foreach (string str2 in (IEnumerable <string>)target.phases) { if (this.frameworks.HasEntry(str2)) { return(this.frameworks[str2]); } } break; case PBXFileType.Source: foreach (string str4 in (IEnumerable <string>)target.phases) { if (this.sources.HasEntry(str4)) { return(this.sources[str4]); } } break; case PBXFileType.Resource: foreach (string str3 in (IEnumerable <string>)target.phases) { if (this.resources.HasEntry(str3)) { return(this.resources[str3]); } } break; case PBXFileType.CopyFile: foreach (string str5 in (IEnumerable <string>)target.phases) { if (this.copyFiles.HasEntry(str5)) { return(this.copyFiles[str5]); } } break; } return(null); }
public static PBXNativeTargetData Create(string name, string productRef, string productType, string buildConfigList) { var res = new PBXNativeTargetData(); res.guid = PBXGUID.Generate(); res.SetPropertyString("isa", "PBXNativeTarget"); res.buildConfigList = buildConfigList; res.phases = new GUIDList(); res.SetPropertyList("buildRules", new List <string>()); res.dependencies = new GUIDList(); res.name = name; res.productReference = productRef; res.SetPropertyString("productName", name); res.SetPropertyString("productReference", productRef); res.SetPropertyString("productType", productType); return(res); }
/// <summary> /// Configures file for embed framework section for the given native target. /// /// This function also internally calls <code>proj.AddFileToBuild(targetGuid, fileGuid)</code> /// to ensure that the framework is added to the list of linked frameworks. /// /// If the target has already configured the given file as embedded framework, this function has /// no effect. /// /// A projects containing multiple native targets, a single file or folder reference can be /// configured to be built in all, some or none of the targets. The file or folder reference is /// added to appropriate build section depending on the file extension. /// </summary> /// <param name="proj">A project passed as this argument.</param> /// <param name="targetGuid">The GUID of the target as returned by [[TargetGuidByName()]].</param> /// <param name="fileGuid">The file GUID returned by [[AddFile]] or [[AddFolderReference]].</param> public static void AddFileToEmbedFrameworks(this PBXProject proj, string targetGuid, string fileGuid) { PBXNativeTargetData target = proj.nativeTargets[targetGuid]; var phaseGuid = proj.AddCopyFilesBuildPhase(targetGuid, "Embed Frameworks", "", "10"); var phase = proj.copyFiles[phaseGuid]; var frameworkEmbedFileData = proj.FindFrameworkByFileGuid(phase, fileGuid); if (frameworkEmbedFileData == null) { frameworkEmbedFileData = PBXBuildFileData.CreateFromFile(fileGuid, false, null); proj.BuildFilesAdd(targetGuid, frameworkEmbedFileData); phase.files.AddGUID(frameworkEmbedFileData.guid); } frameworkEmbedFileData.codeSignOnCopy = true; frameworkEmbedFileData.removeHeadersOnCopy = true; }
private PBXBuildFileData AddBuildFileImpl(string targetGuid, string fileGuid, bool weak, string compileFlags) { PBXNativeTargetData target = nativeTargets[targetGuid]; PBXFileReferenceData fileRef = FileRefsGet(fileGuid); string ext = Path.GetExtension(fileRef.path); if (FileTypeUtils.IsBuildable(ext, fileRef.isFolderReference) && BuildFilesGetForSourceFile(targetGuid, fileGuid) == null) { PBXBuildFileData buildFile = PBXBuildFileData.CreateFromFile(fileGuid, weak, compileFlags); BuildFilesAdd(targetGuid, buildFile); BuildSectionAny(target, ext, fileRef.isFolderReference).files.AddGUID(buildFile.guid); return(buildFile); } return(null); }
internal PBXNativeTargetData CreateNewTarget(string name, string ext, string type) { XCBuildConfigurationData data = XCBuildConfigurationData.Create("Release"); this.buildConfigs.AddEntry(data); XCBuildConfigurationData data2 = XCBuildConfigurationData.Create("Debug"); this.buildConfigs.AddEntry(data2); XCConfigurationListData data3 = XCConfigurationListData.Create(); this.configs.AddEntry(data3); data3.buildConfigs.AddGUID(data.guid); data3.buildConfigs.AddGUID(data2.guid); string path = name + ext; string productRef = this.AddFile(path, "Products/" + path, PBXSourceTree.Build); PBXNativeTargetData data4 = PBXNativeTargetData.Create(name, productRef, type, data3.guid); this.nativeTargets.AddEntry(data4); this.project.project.targets.Add(data4.guid); return(data4); }
internal string AddAppExtension(string mainTarget, string name, string infoPlistPath) { string ext = ".appex"; PBXNativeTargetData data = this.CreateNewTarget(name, ext, "com.apple.product-type.app-extension"); this.SetDefaultAppExtensionReleaseBuildFlags(this.buildConfigs[this.BuildConfigByName(data.guid, "Release")], infoPlistPath); this.SetDefaultAppExtensionDebugBuildFlags(this.buildConfigs[this.BuildConfigByName(data.guid, "Debug")], infoPlistPath); PBXSourcesBuildPhaseData data2 = PBXSourcesBuildPhaseData.Create(); this.sources.AddEntry(data2); data.phases.AddGUID(data2.guid); PBXResourcesBuildPhaseData data3 = PBXResourcesBuildPhaseData.Create(); this.resources.AddEntry(data3); data.phases.AddGUID(data3.guid); PBXFrameworksBuildPhaseData data4 = PBXFrameworksBuildPhaseData.Create(); this.frameworks.AddEntry(data4); data.phases.AddGUID(data4.guid); PBXCopyFilesBuildPhaseData data5 = PBXCopyFilesBuildPhaseData.Create("Embed App Extensions", "13"); this.copyFiles.AddEntry(data5); this.nativeTargets[mainTarget].phases.AddGUID(data5.guid); PBXContainerItemProxyData data6 = PBXContainerItemProxyData.Create(this.project.project.guid, "1", data.guid, name); this.containerItems.AddEntry(data6); PBXTargetDependencyData data7 = PBXTargetDependencyData.Create(data.guid, data6.guid); this.targetDependencies.AddEntry(data7); this.nativeTargets[mainTarget].dependencies.AddGUID(data7.guid); PBXBuildFileData buildFile = PBXBuildFileData.CreateFromFile(this.FindFileGuidByProjectPath("Products/" + name + ext), false, ""); this.BuildFilesAdd(mainTarget, buildFile); data5.files.AddGUID(buildFile.guid); this.AddFile(infoPlistPath, name + "/Supporting Files/Info.plist", PBXSourceTree.Source); return(data.guid); }
public FileGUIDListBase BuildSectionAny(PBXNativeTargetData target, string path, bool isFolderRef) { switch (FileTypeUtils.GetFileType(Path.GetExtension(path), isFolderRef)) { case PBXFileType.NotBuildable: return((FileGUIDListBase)null); case PBXFileType.Framework: using (IEnumerator <string> enumerator = ((IEnumerable <string>)target.phases).GetEnumerator()) { while (enumerator.MoveNext()) { string current = enumerator.Current; if (this.frameworks.HasEntry(current)) { return((FileGUIDListBase)this.frameworks[current]); } } break; } case PBXFileType.Source: using (IEnumerator <string> enumerator = ((IEnumerable <string>)target.phases).GetEnumerator()) { while (enumerator.MoveNext()) { string current = enumerator.Current; if (this.sources.HasEntry(current)) { return((FileGUIDListBase)this.sources[current]); } } break; } case PBXFileType.Header: using (IEnumerator <string> enumerator = ((IEnumerable <string>)target.phases).GetEnumerator()) { while (enumerator.MoveNext()) { string current = enumerator.Current; if (this.headers.HasEntry(current)) { return((FileGUIDListBase)this.headers[current]); } } break; } case PBXFileType.Resource: using (IEnumerator <string> enumerator = ((IEnumerable <string>)target.phases).GetEnumerator()) { while (enumerator.MoveNext()) { string current = enumerator.Current; if (this.resources.HasEntry(current)) { return((FileGUIDListBase)this.resources[current]); } } break; } case PBXFileType.CopyFile: using (IEnumerator <string> enumerator = ((IEnumerable <string>)target.phases).GetEnumerator()) { while (enumerator.MoveNext()) { string current = enumerator.Current; if (this.copyFiles.HasEntry(current)) { return((FileGUIDListBase)this.copyFiles[current]); } } break; } case PBXFileType.ShellScript: using (IEnumerator <string> enumerator = ((IEnumerable <string>)target.phases).GetEnumerator()) { while (enumerator.MoveNext()) { string current = enumerator.Current; if (this.shellScripts.HasEntry(current)) { return((FileGUIDListBase)this.shellScripts[current]); } } break; } } throw new Exception(string.Format("The given path {0} does not refer to a file in a known build section", (object)path)); }
/** This function must be called only after the project the library is in has * been added as a dependency via AddExternalProjectDependency. projectPath must be * the same as the 'path' parameter passed to the AddExternalProjectDependency. * remoteFileGuid must be the guid of the referenced file as specified in * PBXFileReference section of the external project * * TODO: what. is remoteInfo entry in PBXContainerItemProxy? Is in referenced project name or * referenced library name without extension? */ public void AddExternalLibraryDependency(string targetGuid, string filename, string remoteFileGuid, string projectPath, string remoteInfo) { PBXNativeTargetData target = nativeTargets[targetGuid]; filename = Utils.FixSlashesInPath(filename); projectPath = Utils.FixSlashesInPath(projectPath); // find the products group to put the new library in string projectGuid = FindFileGuidByRealPath(projectPath); if (projectGuid == null) { throw new Exception("No such project"); } string productsGroupGuid = null; foreach (var proj in project.project.projectReferences) { if (proj.projectRef == projectGuid) { productsGroupGuid = proj.group; break; } } if (productsGroupGuid == null) { throw new Exception("Malformed project: no project in project references"); } PBXGroupData productGroup = GroupsGet(productsGroupGuid); // verify file extension string ext = Path.GetExtension(filename); if (!FileTypeUtils.IsBuildableFile(ext)) { throw new Exception("Wrong file extension"); } // create ContainerItemProxy object var container = PBXContainerItemProxyData.Create(projectGuid, "2", remoteFileGuid, remoteInfo); containerItems.AddEntry(container); // create a reference and build file for the library string typeName = FileTypeUtils.GetTypeName(ext); var libRef = PBXReferenceProxyData.Create(filename, typeName, container.guid, "BUILT_PRODUCTS_DIR"); references.AddEntry(libRef); PBXBuildFileData libBuildFile = PBXBuildFileData.CreateFromFile(libRef.guid, false, null); BuildFilesAdd(targetGuid, libBuildFile); BuildSectionAny(target, ext, false).files.AddGUID(libBuildFile.guid); // add to products folder productGroup.children.AddGUID(libRef.guid); }
FileGUIDListBase BuildSectionAny(PBXNativeTargetData target, string path, bool isFolderRef) { return(m_Data.BuildSectionAny(target, path, isFolderRef)); }
private FileGUIDListBase BuildSectionAny(PBXNativeTargetData target, string path, bool isFolderRef) => this.m_Data.BuildSectionAny(target, path, isFolderRef);
// This function returns a build section that a particular file should be automatically added to. // Returns null for non-buildable file types. // Throws an exception if the file should be added to a section, but that particular section does not exist for given target // Note that for unknown file types we add them to resource build sections public FileGUIDListBase BuildSectionAny(PBXNativeTargetData target, string path, bool isFolderRef) { string ext = Path.GetExtension(path); var phase = FileTypeUtils.GetFileType(ext, isFolderRef); switch (phase) { case PBXFileType.Framework: foreach (var guid in target.phases) { if (frameworks.HasEntry(guid)) { return(frameworks[guid]); } } break; case PBXFileType.Resource: foreach (var guid in target.phases) { if (resources.HasEntry(guid)) { return(resources[guid]); } } break; case PBXFileType.Source: foreach (var guid in target.phases) { if (sources.HasEntry(guid)) { return(sources[guid]); } } break; case PBXFileType.CopyFile: foreach (var guid in target.phases) { if (copyFiles.HasEntry(guid)) { return(copyFiles[guid]); } } break; case PBXFileType.ShellScript: foreach (var guid in target.phases) { if (shellScripts.HasEntry(guid)) { return(shellScripts[guid]); } } break; case PBXFileType.NotBuildable: return(null); } throw new Exception(String.Format("The given path {0} does not refer to a file in a known build section", path)); }
FileGUIDListBase BuildSectionAny(PBXNativeTargetData target, string path, bool isFolderRef) { return m_Data.BuildSectionAny(target, path, isFolderRef); }