// 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 AddDynamicFrameworkToProject(string targetGuid, string frameworkPathInProject) { var fileGuid = FindFileGuidByProjectPath(frameworkPathInProject); if (fileGuid == null) { Debug.LogError("Framework not found: " + frameworkPathInProject); return; } // add file reference as embed framework var embedFrameworkFileData = FindEmbeddedFramework(fileGuid); if (embedFrameworkFileData == null) { embedFrameworkFileData = PBXBuildFileData.CreateFromFramework(fileGuid); BuildFilesAdd(targetGuid, embedFrameworkFileData); } // add "Embed Frameworks" section var embedFrameworksSection = FindEmbeddedFrameworkSection(); if (embedFrameworksSection == null) { embedFrameworksSection = PBXCopyFilesBuildPhaseData.Create("Embed Frameworks", "10"); copyFiles.AddEntry(embedFrameworksSection); } var frameworkAlreadyAdded = false; foreach (var fileEntry in embedFrameworksSection.files) { if (fileEntry == embedFrameworkFileData.guid) { frameworkAlreadyAdded = true; } } if (!frameworkAlreadyAdded) { embedFrameworksSection.files.AddGUID(embedFrameworkFileData.guid); } // add "Embed Frameworks" section to "Build phases" var targetPhases = nativeTargets[targetGuid].phases; if (!targetPhases.Contains(embedFrameworksSection.guid)) { targetPhases.AddGUID(embedFrameworksSection.guid); } foreach (var buildConfigEntry in buildConfigs.GetEntries()) { XCBuildConfigurationData configurationData = buildConfigEntry.Value; configurationData.AddProperty("LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks"); } }
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.assetTags = new List <string>(); return(buildFile); }
private void 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); } }
/** 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); }
// 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 static PBXBuildFileData CreateFromFramework(string fileRefGUID) { PBXBuildFileData buildFile = new PBXBuildFileData(); buildFile.guid = PBXGUID.Generate(); buildFile.SetPropertyString("isa", "PBXBuildFile"); buildFile.fileRef = fileRefGUID; PBXElementDict settingsDict = new PBXElementDict(); PBXElementArray elementArray = new PBXElementArray(); elementArray.AddString("CodeSignOnCopy"); elementArray.AddString("RemoveHeadersOnCopy"); settingsDict["ATTRIBUTES"] = elementArray; buildFile.m_Properties["settings"] = settingsDict; buildFile.assetTags = new List <string>(); return(buildFile); }
public void AddDynamicFrameworkToProject(string targetGuid, string frameworkPathInProject) { var fileGuid = FindFileGuidByProjectPath(frameworkPathInProject); if (fileGuid == null) { Debug.LogError("Framework not found: " + frameworkPathInProject); return; } // add file reference as embed framework var embedFrameworkFileData = FindEmbeddedFramework(fileGuid); if (embedFrameworkFileData == null) { embedFrameworkFileData = PBXBuildFileData.CreateFromFramework(fileGuid); BuildFilesAdd(targetGuid, embedFrameworkFileData); } // add "Embed Frameworks" section var embedFrameworksSection = FindEmbeddedFrameworkSection(targetGuid); if (embedFrameworksSection == null) { embedFrameworksSection = PBXCopyFilesBuildPhaseData.Create("Embed Frameworks", "10"); copyFiles.AddEntry(embedFrameworksSection); } var frameworkAlreadyAdded = false; foreach (var fileEntry in embedFrameworksSection.files) { if (fileEntry == embedFrameworkFileData.guid) { frameworkAlreadyAdded = true; } } if (!frameworkAlreadyAdded) { embedFrameworksSection.files.AddGUID(embedFrameworkFileData.guid); } // add "Embed Frameworks" section to "Build phases" var targetPhases = nativeTargets[targetGuid].phases; if (!targetPhases.Contains(embedFrameworksSection.guid)) { targetPhases.AddGUID(embedFrameworksSection.guid); } CheckRuntimeSearchPath(); }
void BuildFilesAdd(string targetGuid, PBXBuildFileData buildFile) { m_Data.BuildFilesAdd(targetGuid, buildFile); }