private string AddFileImpl(string path, string projectPath, PBXSourceTree tree, bool isFolderReference) { PBXFileReferenceData data; path = PBXPath.FixSlashes(path); projectPath = PBXPath.FixSlashes(projectPath); if (!isFolderReference && (Path.GetExtension(path) != Path.GetExtension(projectPath))) { throw new Exception("Project and real path extensions do not match"); } string str = this.FindFileGuidByProjectPath(projectPath); if (str == null) { str = this.FindFileGuidByRealPath(path); } if (str != null) { return(str); } if (isFolderReference) { data = PBXFileReferenceData.CreateFromFolderReference(path, PBXPath.GetFilename(projectPath), tree); } else { data = PBXFileReferenceData.CreateFromFile(path, PBXPath.GetFilename(projectPath), tree); } PBXGroupData parent = this.CreateSourceGroup(PBXPath.GetDirectory(projectPath)); parent.children.AddGUID(data.guid); this.FileRefsAdd(path, projectPath, parent, data); return(data.guid); }
// The same file can be referred to by more than one project path. private string AddFileImpl(string path, string projectPath, PBXSourceTree tree, bool isFolderReference) { path = PBXPath.FixSlashes(path); projectPath = PBXPath.FixSlashes(projectPath); if (!isFolderReference && Path.GetExtension(path) != Path.GetExtension(projectPath)) { throw new Exception("Project and real path extensions do not match"); } string guid = FindFileGuidByProjectPath(projectPath); if (guid == null) { guid = FindFileGuidByRealPath(path); } if (guid == null) { PBXFileReferenceData fileRef; if (isFolderReference) { fileRef = PBXFileReferenceData.CreateFromFolderReference(path, PBXPath.GetFilename(projectPath), tree); } else { fileRef = PBXFileReferenceData.CreateFromFile(path, PBXPath.GetFilename(projectPath), tree); } PBXGroupData parent = CreateSourceGroup(PBXPath.GetDirectory(projectPath)); parent.children.AddGUID(fileRef.guid); FileRefsAdd(path, projectPath, parent, fileRef); guid = fileRef.guid; } return(guid); }
void RefreshMapsForGroupChildren(string projectPath, string realPath, PBXSourceTree realPathTree, PBXGroupData parent) { var children = new List <string>(parent.children); foreach (string guid in children) { PBXFileReferenceData fileRef = fileRefs[guid]; string pPath; string rPath; PBXSourceTree rTree; if (fileRef != null) { pPath = PBXPath.Combine(projectPath, fileRef.name); PBXPath.Combine(realPath, realPathTree, fileRef.path, fileRef.tree, out rPath, out rTree); if (!m_ProjectPathToFileRefMap.ContainsKey(pPath)) { m_ProjectPathToFileRefMap.Add(pPath, fileRef); } if (!m_FileRefGuidToProjectPathMap.ContainsKey(fileRef.guid)) { m_FileRefGuidToProjectPathMap.Add(fileRef.guid, pPath); } if (!m_RealPathToFileRefMap[rTree].ContainsKey(rPath)) { m_RealPathToFileRefMap[rTree].Add(rPath, fileRef); } if (!m_GuidToParentGroupMap.ContainsKey(guid)) { m_GuidToParentGroupMap.Add(guid, parent); } continue; } PBXGroupData gr = groups[guid]; if (gr != null) { pPath = PBXPath.Combine(projectPath, gr.name); PBXPath.Combine(realPath, realPathTree, gr.path, gr.tree, out rPath, out rTree); if (!m_ProjectPathToGroupMap.ContainsKey(pPath)) { m_ProjectPathToGroupMap.Add(pPath, gr); } if (!m_GroupGuidToProjectPathMap.ContainsKey(gr.guid)) { m_GroupGuidToProjectPathMap.Add(gr.guid, pPath); } if (!m_GuidToParentGroupMap.ContainsKey(guid)) { m_GuidToParentGroupMap.Add(guid, parent); } RefreshMapsForGroupChildren(pPath, rPath, rTree, gr); } } }
public static string GetFullPath(string path) { if (PBXPath.IsPathRooted(path)) { return(path); } return(PBXPath.Combine(PBXPath.GetCurrentDirectory(), path)); }
public string FindFileGuidByProjectPath(string path) { path = PBXPath.FixSlashes(path); PBXFileReferenceData data = this.FileRefsGetByProjectPath(path); if (data != null) { return(data.guid); } return(null); }
internal void RemoveFilesByProjectPathRecursive(string projectPath) { projectPath = PBXPath.FixSlashes(projectPath); PBXGroupData parent = this.GroupsGetByProjectPath(projectPath); if (parent != null) { this.RemoveGroupChildrenRecursive(parent); this.RemoveGroupIfEmpty(parent); } }
public string FindFileGuidByProjectPath(string path) { path = PBXPath.FixSlashes(path); var fileRef = FileRefsGetByProjectPath(path); if (fileRef != null) { return(fileRef.guid); } return(null); }
public AssetFolder OpenNamespacedFolder(string relativeBasePath, string namespacePath) { AssetFolder assetFolder = this.OpenFolder(relativeBasePath); foreach (string name in PBXPath.Split(namespacePath)) { assetFolder = assetFolder.OpenFolder(name); assetFolder.providesNamespace = true; } return(assetFolder); }
// Write the actual file to the disk. // If you don't call this method nothing will change. public void WriteToFile() { File.WriteAllText(m_PBXProjectPath, project.WriteToString()); if (m_Entitlements != null) { m_Entitlements.WriteToFile(PBXPath.Combine(m_BuildPath, m_EntitlementFilePath)); } if (m_InfoPlist != null) { m_InfoPlist.WriteToFile(PBXPath.Combine(m_BuildPath, "Info.plist")); } }
public AssetFolder OpenNamespacedFolder(string relativeBasePath, string namespacePath) { AssetFolder folder = this.OpenFolder(relativeBasePath); string[] strArray = PBXPath.Split(namespacePath); foreach (string str in strArray) { folder = folder.OpenFolder(str); folder.providesNamespace = true; } return(folder); }
internal void RemoveFilesByProjectPathRecursive(string projectPath) { projectPath = PBXPath.FixSlashes(projectPath); PBXGroupData gr = GroupsGetByProjectPath(projectPath); if (gr == null) { return; } RemoveGroupChildrenRecursive(gr); RemoveGroupIfEmpty(gr); }
// Creates a directory structure with "provides namespace" attribute. // First, retrieves or creates the directory at relativeBasePath, creating parent // directories if needed. Effectively calls OpenFolder(relativeBasePath). // Then, relative to this directory, creates namespacePath directories with "provides // namespace" attribute set. Fails if the attribute can't be set. public AssetFolder OpenNamespacedFolder(string relativeBasePath, string namespacePath) { var folder = OpenFolder(relativeBasePath); var pathItems = PBXPath.Split(namespacePath); foreach (var pathItem in pathItems) { folder = folder.OpenFolder(pathItem); folder.providesNamespace = true; } return(folder); }
private void RefreshMapsForGroupChildren(string projectPath, string realPath, PBXSourceTree realPathTree, PBXGroupData parent) { foreach (string key1 in new List <string>((IEnumerable <string>)parent.children)) { PBXFileReferenceData fileReferenceData = this.fileRefs[key1]; string resPath; PBXSourceTree resTree; if (fileReferenceData != null) { string key2 = PBXPath.Combine(projectPath, fileReferenceData.name); PBXPath.Combine(realPath, realPathTree, fileReferenceData.path, fileReferenceData.tree, out resPath, out resTree); if (!this.m_ProjectPathToFileRefMap.ContainsKey(key2)) { this.m_ProjectPathToFileRefMap.Add(key2, fileReferenceData); } if (!this.m_FileRefGuidToProjectPathMap.ContainsKey(fileReferenceData.guid)) { this.m_FileRefGuidToProjectPathMap.Add(fileReferenceData.guid, key2); } if (!this.m_RealPathToFileRefMap[resTree].ContainsKey(resPath)) { this.m_RealPathToFileRefMap[resTree].Add(resPath, fileReferenceData); } if (!this.m_GuidToParentGroupMap.ContainsKey(key1)) { this.m_GuidToParentGroupMap.Add(key1, parent); } } else { PBXGroupData parent1 = this.groups[key1]; if (parent1 != null) { string str = PBXPath.Combine(projectPath, parent1.name); PBXPath.Combine(realPath, realPathTree, parent1.path, parent1.tree, out resPath, out resTree); if (!this.m_ProjectPathToGroupMap.ContainsKey(str)) { this.m_ProjectPathToGroupMap.Add(str, parent1); } if (!this.m_GroupGuidToProjectPathMap.ContainsKey(parent1.guid)) { this.m_GroupGuidToProjectPathMap.Add(parent1.guid, str); } if (!this.m_GuidToParentGroupMap.ContainsKey(key1)) { this.m_GuidToParentGroupMap.Add(key1, parent); } this.RefreshMapsForGroupChildren(str, resPath, resTree, parent1); } } } }
public static void Combine(string path1, PBXSourceTree tree1, string path2, PBXSourceTree tree2, out string resPath, out PBXSourceTree resTree) { if (tree2 == PBXSourceTree.Group) { resPath = PBXPath.Combine(path1, path2); resTree = tree1; } else { resPath = path2; resTree = tree2; } }
private AssetFolder OpenFolderForResource(string relativePath) { List <string> list = PBXPath.Split(relativePath).ToList <string>(); list.RemoveAt(list.Count - 1); AssetFolder root = this.root; foreach (string str in list) { root = root.OpenFolder(str); } return(root); }
private AssetFolder OpenFolderForResource(string relativePath) { List <string> list = Enumerable.ToList <string>((IEnumerable <string>)PBXPath.Split(relativePath)); list.RemoveAt(list.Count - 1); AssetFolder assetFolder = this.root; foreach (string name in list) { assetFolder = assetFolder.OpenFolder(name); } return(assetFolder); }
public void WriteToFile() { File.WriteAllText(this.m_PBXProjectPath, this.project.WriteToString()); if (this.m_Entitlements != null) { this.m_Entitlements.WriteToFile(PBXPath.Combine(this.m_BuildPath, this.m_EntitlementFilePath)); } if (this.m_InfoPlist == null) { return; } this.m_InfoPlist.WriteToFile(PBXPath.Combine(this.m_BuildPath, "Info.plist")); }
public string FindFileGuidByRealPath(string path) { path = PBXPath.FixSlashes(path); foreach (PBXSourceTree tree in FileTypeUtils.AllAbsoluteSourceTrees()) { string str = this.FindFileGuidByRealPath(path, tree); if (str != null) { return(str); } } return(null); }
public static string GetCurrentDirectory() { if (Environment.OSVersion.Platform != PlatformID.MacOSX && Environment.OSVersion.Platform != PlatformID.Unix) { throw new Exception("PBX project compatible current directory can only obtained on OSX"); } string path = PBXPath.FixSlashes(Directory.GetCurrentDirectory()); if (!PBXPath.IsPathRooted(path)) { return("/" + path); } return(path); }
public string FindFileGuidByRealPath(string path) { path = PBXPath.FixSlashes(path); foreach (var tree in FileTypeUtils.AllAbsoluteSourceTrees()) { string res = FindFileGuidByRealPath(path, tree); if (res != null) { return(res); } } return(null); }
AssetFolder OpenFolderForResource(string relativePath) { var pathItems = PBXPath.Split(relativePath).ToList(); // remove path filename pathItems.RemoveAt(pathItems.Count - 1); AssetFolder folder = root; foreach (var pathItem in pathItems) { folder = folder.OpenFolder(pathItem); } return(folder); }
public string FindFileGuidByRealPath(string path, PBXSourceTree sourceTree) { if (sourceTree == PBXSourceTree.Group) { throw new Exception("sourceTree must not be PBXSourceTree.Group"); } path = PBXPath.FixSlashes(path); PBXFileReferenceData data = this.FileRefsGetByRealPath(path, sourceTree); if (data != null) { return(data.guid); } return(null); }
// sourceTree must not be PBXSourceTree.Group public string FindFileGuidByRealPath(string path, PBXSourceTree sourceTree) { if (sourceTree == PBXSourceTree.Group) { throw new Exception("sourceTree must not be PBXSourceTree.Group"); } path = PBXPath.FixSlashes(path); var fileRef = FileRefsGetByRealPath(path, sourceTree); if (fileRef != null) { return(fileRef.guid); } return(null); }
/// Creates source group identified by sourceGroup, if needed, and returns it. /// If sourceGroup is empty or null, root group is returned private PBXGroupData CreateSourceGroup(string sourceGroup) { sourceGroup = PBXPath.FixSlashes(sourceGroup); if (sourceGroup == null || sourceGroup == "") { return(GroupsGetMainGroup()); } PBXGroupData gr = GroupsGetByProjectPath(sourceGroup); if (gr != null) { return(gr); } // the group does not exist -- create new gr = GroupsGetMainGroup(); var elements = PBXPath.Split(sourceGroup); string projectPath = null; foreach (string pathEl in elements) { if (projectPath == null) { projectPath = pathEl; } else { projectPath += "/" + pathEl; } PBXGroupData child = GetPBXGroupChildByName(gr, pathEl); if (child != null) { gr = child; } else { PBXGroupData newGroup = PBXGroupData.Create(pathEl, pathEl, PBXSourceTree.Group); gr.children.AddGUID(newGroup.guid); GroupsAdd(projectPath, gr, newGroup); gr = newGroup; } } return(gr); }
private PlistDocument GetOrCreateEntitlementDoc() { if (this.m_Entitlements == null) { this.m_Entitlements = new PlistDocument(); if (File.Exists(PBXPath.Combine(this.m_BuildPath, this.m_EntitlementFilePath))) { this.m_Entitlements.ReadFromFile(PBXPath.Combine(this.m_BuildPath, this.m_EntitlementFilePath)); } else { this.m_Entitlements.Create(); } } return(this.m_Entitlements); }
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 void AddExternalProjectDependency(string path, string projectPath, PBXSourceTree sourceTree) { if (sourceTree == PBXSourceTree.Group) { throw new Exception("sourceTree must not be PBXSourceTree.Group"); } path = PBXPath.FixSlashes(path); projectPath = PBXPath.FixSlashes(projectPath); PBXGroupData gr = PBXGroupData.CreateRelative("Products"); this.GroupsAddDuplicate(gr); PBXFileReferenceData fileRef = PBXFileReferenceData.CreateFromFile(path, Path.GetFileName(projectPath), sourceTree); this.FileRefsAdd(path, projectPath, null, fileRef); this.CreateSourceGroup(PBXPath.GetDirectory(projectPath)).children.AddGUID(fileRef.guid); this.project.project.AddReference(gr.guid, fileRef.guid); }
// Allow user to add a Capability public bool AddCapability(string targetGuid, PBXCapabilityType capability, string entitlementsFilePath = null, bool addOptionalFramework = false) { // If the capability requires entitlements then you have to provide the name of it or we don't add the capability. if (capability.requiresEntitlements && entitlementsFilePath == "") { throw new Exception("Couldn't add the Xcode Capability " + capability.id + " to the PBXProject file because this capability requires an entitlement file."); } var p = project.project; // If an entitlement with a different name was added for another capability // we don't add this capacity. if (p.entitlementsFile != null && entitlementsFilePath != null && p.entitlementsFile != entitlementsFilePath) { if (p.capabilities.Count > 0) { throw new WarningException("Attention, it seems that you have multiple entitlements file. Only one will be added the Project : " + p.entitlementsFile); } return(false); } // Add the capability only if it doesn't already exist. if (p.capabilities.Contains(new PBXCapabilityType.TargetCapabilityPair(targetGuid, capability))) { throw new WarningException("This capability has already been added. Method ignored"); } p.capabilities.Add(new PBXCapabilityType.TargetCapabilityPair(targetGuid, capability)); // Add the required framework. if (capability.framework != "" && !capability.optionalFramework || (capability.framework != "" && capability.optionalFramework && addOptionalFramework)) { AddFrameworkToProject(targetGuid, capability.framework, false); } // Finally add the entitlement code signing if it wasn't added before. if (entitlementsFilePath != null && p.entitlementsFile == null) { p.entitlementsFile = entitlementsFilePath; AddFileImpl(entitlementsFilePath, entitlementsFilePath, PBXSourceTree.Source, false); SetBuildProperty(targetGuid, "CODE_SIGN_ENTITLEMENTS", PBXPath.FixSlashes(entitlementsFilePath)); } return(true); }
public AssetFolder OpenFolder(string relativePath) { if (relativePath == null) { return(this.root); } string[] strArray = PBXPath.Split(relativePath); if (strArray.Length == 0) { return(this.root); } AssetFolder assetFolder = this.root; foreach (string name in strArray) { assetFolder = assetFolder.OpenFolder(name); } return(assetFolder); }
public AssetFolder OpenFolder(string relativePath) { if (relativePath == null) { return(this.root); } string[] strArray = PBXPath.Split(relativePath); if (strArray.Length == 0) { return(this.root); } AssetFolder root = this.root; foreach (string str in strArray) { root = root.OpenFolder(str); } return(root); }