Skip to content

Commit

Permalink
Copy reference to subproject before fixing relative path
Browse files Browse the repository at this point in the history
  • Loading branch information
swiftyfinch committed Mar 1, 2024
1 parent 7867bfb commit 671852a
Showing 1 changed file with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ extension PBXProj {
if let existingReference = projectReferences().first(where: { $0.name == reference.name }) {
containerPortal = .fileReference(existingReference)
} else {
reference.fixRelativeProjectPath()
add(object: reference)
let newReference = reference.copy()
newReference.fixRelativeProjectPath()
add(object: newReference)

// Add project dependency to root Dependencies group
let dependenciesGroup = try createGroupIfNeeded(groupName: .dependenciesGroup)
dependenciesGroup.children.append(reference)
rootObject?.projects.append([.projectRefKey: reference])
containerPortal = .fileReference(reference)
dependenciesGroup.children.append(newReference)
rootObject?.projects.append([.projectRefKey: newReference])

containerPortal = .fileReference(newReference)
}
proxyType = .reference
} else {
Expand Down Expand Up @@ -87,6 +89,26 @@ private extension PBXFileReference {
// For example, '../../Pods/SnapKit.xcodeproj' should be 'SnapKit.xcodeproj'.
path = path.map(URL.init(fileURLWithPath:))?.lastPathComponent
}

func copy() -> PBXFileReference {
PBXFileReference(
sourceTree: sourceTree,
name: name,
fileEncoding: fileEncoding,
explicitFileType: explicitFileType,
lastKnownFileType: lastKnownFileType,
path: path,
includeInIndex: includeInIndex,
wrapsLines: wrapsLines,
usesTabs: usesTabs,
indentWidth: indentWidth,
tabWidth: tabWidth,
lineEnding: lineEnding,
languageSpecificationIdentifier: languageSpecificationIdentifier,
xcLanguageSpecificationIdentifier: xcLanguageSpecificationIdentifier,
plistStructureDefinitionIdentifier: plistStructureDefinitionIdentifier
)
}
}

extension PBXProj {
Expand Down

0 comments on commit 671852a

Please sign in to comment.