public void RemoveFileFromBuild(string targetGuid, string fileGuid) { PBXBuildFileData data = this.BuildFilesGetForSourceFile(targetGuid, fileGuid); if (data != null) { this.BuildFilesRemove(targetGuid, fileGuid); string guid = data.guid; if (guid != null) { foreach (KeyValuePair <string, PBXSourcesBuildPhaseData> pair in this.sources.GetEntries()) { pair.Value.files.RemoveGUID(guid); } foreach (KeyValuePair <string, PBXResourcesBuildPhaseData> pair2 in this.resources.GetEntries()) { pair2.Value.files.RemoveGUID(guid); } foreach (KeyValuePair <string, PBXCopyFilesBuildPhaseData> pair3 in this.copyFiles.GetEntries()) { pair3.Value.files.RemoveGUID(guid); } foreach (KeyValuePair <string, PBXFrameworksBuildPhaseData> pair4 in this.frameworks.GetEntries()) { pair4.Value.files.RemoveGUID(guid); } } } }
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); }
public void EmbedFramework(string target, string framework, bool weak, bool codeSignOnCopy, bool removeHeadersOnCopy) { var refs = FileRefsGetByProjectPath(framework); if (refs == null) { UnityEngine.Debug.LogWarning("Cannot Embed framework " + framework + ". Framework not found."); return; } var fileGuid = refs.guid; var file = PBXBuildFileData.CreateFromFile(fileGuid, weak, null); var embedFrameworks = GetEmbedFrameworks(target); foreach (var embedFramework in embedFrameworks.files.AsEnumerable()) { var buildFile = BuildFilesGet(embedFramework); if (buildFile.fileRef == fileGuid) { UnityEngine.Debug.Log("Framework " + framework + " already added to Embed Frameworks."); return; } } file.codeSignOnCopy = codeSignOnCopy; file.removeHeadersOnCopy = removeHeadersOnCopy; buildFiles.AddEntry(file); embedFrameworks.files.AddGUID(file.guid); }
// 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 RefreshBuildFilesMapForBuildFileGuidList(Dictionary <string, PBXBuildFileData> mapForTarget, FileGUIDListBase list) { foreach (string index in (IEnumerable <string>)list.files) { PBXBuildFileData pbxBuildFileData = this.buildFiles[index]; mapForTarget[pbxBuildFileData.fileRef] = pbxBuildFileData; } }
// targetGuid is the guid of the target that contains the section that contains the buildFile public void BuildFilesAdd(string targetGuid, PBXBuildFileData buildFile) { if (!m_FileGuidToBuildFileMap.ContainsKey(targetGuid)) { m_FileGuidToBuildFileMap[targetGuid] = new Dictionary <string, PBXBuildFileData>(); } m_FileGuidToBuildFileMap[targetGuid][buildFile.fileRef] = buildFile; buildFiles.AddEntry(buildFile); }
public void BuildFilesRemove(string targetGuid, string fileGuid) { PBXBuildFileData data = this.BuildFilesGetForSourceFile(targetGuid, fileGuid); if (data != null) { this.m_FileGuidToBuildFileMap[targetGuid].Remove(data.fileRef); this.buildFiles.RemoveEntry(data.guid); } }
public void BuildFilesRemove(string targetGuid, string fileGuid) { PBXBuildFileData forSourceFile = this.BuildFilesGetForSourceFile(targetGuid, fileGuid); if (forSourceFile == null) { return; } this.m_FileGuidToBuildFileMap[targetGuid].Remove(forSourceFile.fileRef); this.buildFiles.RemoveEntry(forSourceFile.guid); }
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 static PBXBuildFileData CreateFromFile(string fileRefGUID, bool weak, string compileFlags) { PBXBuildFileData buildFile = new PBXBuildFileData(); buildFile.guid = PBXGUID.Generate(); buildFile.SetPropertyString("isa", "PBXBuildFile"); buildFile.fileRef = fileRefGUID; buildFile.compileFlags = compileFlags; buildFile.weak = weak; buildFile.codeSignOnCopy = false; buildFile.removeHeadersOnCopy = false; buildFile.assetTags = new List <string>(); return(buildFile); }
public void AddAssetTagForFile(string targetGuid, string fileGuid, string tag) { PBXBuildFileData data = this.BuildFilesGetForSourceFile(targetGuid, fileGuid); if (data != null) { if (!data.assetTags.Contains(tag)) { data.assetTags.Add(tag); } if (!this.project.project.knownAssetTags.Contains(tag)) { this.project.project.knownAssetTags.Add(tag); } } }
public void SetCompileFlagsForFile(string targetGuid, string fileGuid, List <string> compileFlags) { PBXBuildFileData data = this.BuildFilesGetForSourceFile(targetGuid, fileGuid); if (data != null) { if (compileFlags == null) { data.compileFlags = null; } else { data.compileFlags = string.Join(" ", compileFlags.ToArray()); } } }
public List <string> GetCompileFlagsForFile(string targetGuid, string fileGuid) { PBXBuildFileData data = this.BuildFilesGetForSourceFile(targetGuid, fileGuid); if (data == null) { return(null); } if (data.compileFlags == null) { return(new List <string>()); } return(new List <string> { data.compileFlags }); }
// Returns the guid of the new target internal string AddAppExtension(string mainTarget, string name, string infoPlistPath) { string ext = ".appex"; var newTarget = CreateNewTarget(name, ext, "com.apple.product-type.app-extension"); SetDefaultAppExtensionReleaseBuildFlags(buildConfigs[BuildConfigByName(newTarget.guid, "Release")], infoPlistPath); SetDefaultAppExtensionDebugBuildFlags(buildConfigs[BuildConfigByName(newTarget.guid, "Debug")], infoPlistPath); var sourcesBuildPhase = PBXSourcesBuildPhaseData.Create(); sources.AddEntry(sourcesBuildPhase); newTarget.phases.AddGUID(sourcesBuildPhase.guid); var resourcesBuildPhase = PBXResourcesBuildPhaseData.Create(); resources.AddEntry(resourcesBuildPhase); newTarget.phases.AddGUID(resourcesBuildPhase.guid); var frameworksBuildPhase = PBXFrameworksBuildPhaseData.Create(); frameworks.AddEntry(frameworksBuildPhase); newTarget.phases.AddGUID(frameworksBuildPhase.guid); var copyFilesBuildPhase = PBXCopyFilesBuildPhaseData.Create("Embed App Extensions", "13"); copyFiles.AddEntry(copyFilesBuildPhase); nativeTargets[mainTarget].phases.AddGUID(copyFilesBuildPhase.guid); var containerProxy = PBXContainerItemProxyData.Create(project.project.guid, "1", newTarget.guid, name); containerItems.AddEntry(containerProxy); var targetDependency = PBXTargetDependencyData.Create(newTarget.guid, containerProxy.guid); targetDependencies.AddEntry(targetDependency); nativeTargets[mainTarget].dependencies.AddGUID(targetDependency.guid); var buildAppCopy = PBXBuildFileData.CreateFromFile(FindFileGuidByProjectPath("Products/" + name + ext), false, ""); BuildFilesAdd(mainTarget, buildAppCopy); copyFilesBuildPhase.files.AddGUID(buildAppCopy.guid); AddFile(infoPlistPath, name + "/Supporting Files/Info.plist", PBXSourceTree.Source); return(newTarget.guid); }
public void RemoveAssetTagForFile(string targetGuid, string fileGuid, string tag) { PBXBuildFileData data = this.BuildFilesGetForSourceFile(targetGuid, fileGuid); if (data != null) { data.assetTags.Remove(tag); foreach (PBXBuildFileData data2 in this.BuildFilesGetAll()) { if (data2.assetTags.Contains(tag)) { return; } } this.project.project.knownAssetTags.Remove(tag); } }
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 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); }
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); }
/// <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 void BuildCommentMapForBuildFiles(GUIDToCommentMap comments, List <string> guids, string sectName) { foreach (string str in guids) { PBXBuildFileData data = this.BuildFilesGet(str); if (data != null) { PBXFileReferenceData data2 = this.FileRefsGet(data.fileRef); if (data2 != null) { comments.Add(str, $"{data2.name} in {sectName}"); } else { PBXReferenceProxyData data3 = this.references[data.fileRef]; if (data3 != null) { comments.Add(str, $"{data3.path} in {sectName}"); } } } } }
private void BuildCommentMapForBuildFiles(GUIDToCommentMap comments, List <string> guids, string sectName) { foreach (string guid in guids) { PBXBuildFileData pbxBuildFileData = this.BuildFilesGet(guid); if (pbxBuildFileData != null) { PBXFileReferenceData fileReferenceData = this.FileRefsGet(pbxBuildFileData.fileRef); if (fileReferenceData != null) { comments.Add(guid, string.Format("{0} in {1}", (object)fileReferenceData.name, (object)sectName)); } else { PBXReferenceProxyData referenceProxyData = this.references[pbxBuildFileData.fileRef]; if (referenceProxyData != null) { comments.Add(guid, string.Format("{0} in {1}", (object)referenceProxyData.path, (object)sectName)); } } } } }
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); }
void BuildFilesAdd(string targetGuid, PBXBuildFileData buildFile) { m_Data.BuildFilesAdd(targetGuid, buildFile); }
/** 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); }
private void BuildFilesAdd(string targetGuid, PBXBuildFileData buildFile) { this.m_Data.BuildFilesAdd(targetGuid, buildFile); }