Skip to content

Commit

Permalink
Merge pull request #268 from xcode-project-manager/project-references
Browse files Browse the repository at this point in the history
Rename some PBXProject attributes
  • Loading branch information
Pedro Piñera Buendía authored Jun 15, 2018
2 parents 1ad8b07 + a3b21ef commit 70e4557
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Remove `ObjectReference` https://github.com/xcbuddy/xcodeproj/pull/5 by @pepibumur.
- Update `PBXNativeTarget` reference attributes to be of type `PBXObjectReference` https://github.com/xcbuddy/xcodeproj/pull/8 by @pepibumur.
- Add convenient methods to materialize objects references https://github.com/xcode-project-manager/xcodeproj/pull/12 by @pepibumur.
- Rename some PBXProject attributes for consistency https://github.com/xcode-project-manager/xcodeproj/pull/268 by @pepibumur.

### Added
- Add `addDependency` method to `PBXNativeTarget` https://github.com/xcbuddy/xcodeproj/pull/8 by @pepibumur.
Expand Down
4 changes: 2 additions & 2 deletions Sources/xcodeproj/Equality.generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ extension PBXProject {
if developmentRegion != rhs.developmentRegion { return false }
if hasScannedForEncodings != rhs.hasScannedForEncodings { return false }
if knownRegions != rhs.knownRegions { return false }
if mainGroup != rhs.mainGroup { return false }
if productRefGroup != rhs.productRefGroup { return false }
if mainGroupReference != rhs.mainGroupReference { return false }
if productsGroupReference != rhs.productsGroupReference { return false }
if projectDirPath != rhs.projectDirPath { return false }
if projectReferences != rhs.projectReferences { return false }
if projectRoots != rhs.projectRoots { return false }
Expand Down
2 changes: 1 addition & 1 deletion Sources/xcodeproj/PBXProj.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public extension PBXProj {
/// Returns root project's root group.
public func rootGroup() throws -> PBXGroup? {
let project = try rootProject()
return try project?.mainGroup.object()
return try project?.mainGroupReference.object()
}
}

Expand Down
32 changes: 16 additions & 16 deletions Sources/xcodeproj/PBXProject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public final class PBXProject: PBXObject {
public var knownRegions: [String]

/// The object is a reference to a PBXGroup element.
public var mainGroup: PBXObjectReference
public var mainGroupReference: PBXObjectReference

/// The object is a reference to a PBXGroup element.
public var productRefGroup: PBXObjectReference?
public var productsGroupReference: PBXObjectReference?

/// The relative path of the project.
public var projectDirPath: String
Expand All @@ -51,11 +51,11 @@ public final class PBXProject: PBXObject {
/// - name: xcodeproj's name.
/// - buildConfigurationListReference: project build configuration list.
/// - compatibilityVersion: project compatibility version.
/// - mainGroup: project main group.
/// - mainGroupReference: project main group.
/// - developmentRegion: project has development region.
/// - hasScannedForEncodings: project has scanned for encodings.
/// - knownRegions: project known regions.
/// - productRefGroup: product reference group.
/// - productsGroupReference: product reference group.
/// - projectDirPath: project dir path.
/// - projectReferences: project references.
/// - projectRoots: project roots.
Expand All @@ -64,11 +64,11 @@ public final class PBXProject: PBXObject {
public init(name: String,
buildConfigurationListReference: PBXObjectReference,
compatibilityVersion: String,
mainGroup: PBXObjectReference,
mainGroupReference: PBXObjectReference,
developmentRegion: String? = nil,
hasScannedForEncodings: Int = 0,
knownRegions: [String] = [],
productRefGroup: PBXObjectReference? = nil,
productsGroupReference: PBXObjectReference? = nil,
projectDirPath: String = "",
projectReferences: [[String: PBXObjectReference]] = [],
projectRoots: [String] = [],
Expand All @@ -77,11 +77,11 @@ public final class PBXProject: PBXObject {
self.name = name
self.buildConfigurationListReference = buildConfigurationListReference
self.compatibilityVersion = compatibilityVersion
self.mainGroup = mainGroup
self.mainGroupReference = mainGroupReference
self.developmentRegion = developmentRegion
self.hasScannedForEncodings = hasScannedForEncodings
self.knownRegions = knownRegions
self.productRefGroup = productRefGroup
self.productsGroupReference = productsGroupReference
self.projectDirPath = projectDirPath
self.projectReferences = projectReferences
self.projectRoots = projectRoots
Expand Down Expand Up @@ -122,11 +122,11 @@ public final class PBXProject: PBXObject {
hasScannedForEncodings = hasScannedForEncodingsString.flatMap({ Int($0) }) ?? 0
knownRegions = (try container.decodeIfPresent(.knownRegions)) ?? []
let mainGroupReference: String = try container.decode(.mainGroup)
mainGroup = referenceRepository.getOrCreate(reference: mainGroupReference, objects: objects)
self.mainGroupReference = referenceRepository.getOrCreate(reference: mainGroupReference, objects: objects)
if let productRefGroupReference: String = try container.decodeIfPresent(.productRefGroup) {
productRefGroup = referenceRepository.getOrCreate(reference: productRefGroupReference, objects: objects)
productsGroupReference = referenceRepository.getOrCreate(reference: productRefGroupReference, objects: objects)
} else {
productRefGroup = nil
productsGroupReference = nil
}
projectDirPath = try container.decodeIfPresent(.projectDirPath) ?? ""
let projectReferences: [[String: String]] = (try container.decodeIfPresent(.projectReferences)) ?? []
Expand Down Expand Up @@ -167,12 +167,12 @@ extension PBXProject: PlistSerializable {
dictionary["knownRegions"] = PlistValue.array(knownRegions
.map { .string(CommentedString("\($0)")) })
}
let mainGroupObject: PBXGroup = try mainGroup.object()
dictionary["mainGroup"] = .string(CommentedString(mainGroup.value, comment: mainGroupObject.name ?? mainGroupObject.path))
if let productRefGroup = productRefGroup {
let productRefGroupObject: PBXGroup = try productRefGroup.object()
let mainGroupObject: PBXGroup = try mainGroupReference.object()
dictionary["mainGroup"] = .string(CommentedString(mainGroupReference.value, comment: mainGroupObject.name ?? mainGroupObject.path))
if let productsGroupReference = productsGroupReference {
let productRefGroupObject: PBXGroup = try productsGroupReference.object()
let productRefGroupComment = productRefGroupObject.name ?? productRefGroupObject.path
dictionary["productRefGroup"] = .string(CommentedString(productRefGroup.value,
dictionary["productRefGroup"] = .string(CommentedString(productsGroupReference.value,
comment: productRefGroupComment))
}
dictionary["projectDirPath"] = .string(CommentedString(projectDirPath))
Expand Down
2 changes: 1 addition & 1 deletion Tests/xcodeprojTests/PBXNativeTargetSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final class PBXNativeTargetSpec: XCTestCase {
let project = PBXProject(name: "Project",
buildConfigurationListReference: configurationList,
compatibilityVersion: "0",
mainGroup: mainGroup)
mainGroupReference: mainGroup)
objects.addObject(project)
let target = PBXNativeTarget(name: "Target")
let dependency = PBXNativeTarget(name: "Dependency")
Expand Down
4 changes: 2 additions & 2 deletions Tests/xcodeprojTests/PBXProjectSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ final class PBXProjectSpec: XCTestCase {
subject = PBXProject(name: "App",
buildConfigurationListReference: PBXObjectReference("config"),
compatibilityVersion: "version",
mainGroup: PBXObjectReference("main"),
mainGroupReference: PBXObjectReference("main"),
developmentRegion: "region",
hasScannedForEncodings: 1,
knownRegions: ["region"],
productRefGroup: PBXObjectReference("group"),
productsGroupReference: PBXObjectReference("group"),
projectDirPath: "path",
projectReferences: [["ref": PBXObjectReference("ref")]],
projectRoots: ["root"],
Expand Down

0 comments on commit 70e4557

Please sign in to comment.