/// <summary> /// Adds an external project dependency to the project. /// </summary> /// <param name="path">The path to the external Xcode project (the .xcodeproj file).</param> /// <param name="projectPath">The project path to the new project.</param> /// <param name="sourceTree">The source tree the path is relative to. The [[PBXSourceTree.Group]] tree is not supported.</param> internal static void AddExternalProjectDependency(this PBXProject proj, 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); // note: we are duplicating products group for the project reference. Otherwise Xcode crashes. PBXGroupData productGroup = PBXGroupData.CreateRelative("Products"); proj.GroupsAddDuplicate(productGroup); // don't use GroupsAdd here PBXFileReferenceData fileRef = PBXFileReferenceData.CreateFromFile(path, Path.GetFileName(projectPath), sourceTree); proj.FileRefsAdd(path, projectPath, null, fileRef); proj.CreateSourceGroup(PBXPath.GetDirectory(projectPath)).children.AddGUID(fileRef.guid); proj.project.project.AddReference(productGroup.guid, fileRef.guid); }