// 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 = Utils.FixSlashesInPath(path); projectPath = Utils.FixSlashesInPath(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, Utils.GetFilenameFromPath(projectPath), tree); } else { fileRef = PBXFileReferenceData.CreateFromFile(path, Utils.GetFilenameFromPath(projectPath), tree); } PBXGroupData parent = CreateSourceGroup(Utils.GetDirectoryFromPath(projectPath)); parent.children.AddGUID(fileRef.guid); FileRefsAdd(path, projectPath, parent, fileRef); guid = fileRef.guid; } return(guid); }
// sourceTree must not be PBXSourceTree.Group public void AddExternalProjectDependency(string path, string projectPath, PBXSourceTree sourceTree) { if (sourceTree == PBXSourceTree.Group) throw new Exception("sourceTree must not be PBXSourceTree.Group"); path = Utils.FixSlashesInPath(path); projectPath = Utils.FixSlashesInPath(projectPath); // note: we are duplicating products group for the project reference. Otherwise Xcode crashes. PBXGroupData productGroup = PBXGroupData.CreateRelative("Products"); GroupsAddDuplicate(productGroup); // don't use GroupsAdd here PBXFileReferenceData fileRef = PBXFileReferenceData.CreateFromFile(path, Path.GetFileName(projectPath), sourceTree); FileRefsAdd(path, projectPath, null, fileRef); CreateSourceGroup(Utils.GetDirectoryFromPath(projectPath)).children.AddGUID(fileRef.guid); project.project.AddReference(productGroup.guid, fileRef.guid); }