Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Inconsistent behaviour with Xcode 16 when PBXProject.TargetAttributes is empty #865

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@
"code"
]
},
{
"login": "georgenavarro",
"name": "George Navarro",
"avatar_url": "https://avatars.githubusercontent.com/u/2748028?v=4",
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/xcodeproj.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Select Xcode 16
run: sudo xcode-select -switch /Applications/Xcode_16.app/Contents/Developer
- uses: jdx/mise-action@v2
- name: Build
run: mise run build
Expand All @@ -31,15 +29,14 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: jdx/mise-action@v2
- uses: swift-actions/setup-swift@v2
- name: Build
run: mise run build-linux
run: swift build --configuration release
test:
name: Test (macOS / Xcode)
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Select Xcode 16
run: sudo xcode-select -switch /Applications/Xcode_16.app/Contents/Developer
- uses: jdx/mise-action@v2
- name: Run tests
run: mise run test
Expand All @@ -50,15 +47,18 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: jdx/mise-action@v2
- uses: swift-actions/setup-swift@v2
- run: |
git config --global user.email 'xcodeproj@tuist.dev'
git config --global user.name 'xcodeproj'
git config --global init.defaultBranch main
- name: Test
run: mise run test-linux
run: swift test

lint:
name: Lint
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Select Xcode 16
run: sudo xcode-select -switch /Applications/Xcode_16.app/Contents/Developer
- uses: jdx/mise-action@v2
- run: mise run lint
2 changes: 1 addition & 1 deletion .mise/tasks/test-linux
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# mise description="Run tests on Linux"

CONTAINER_RUNTIME=$(command -v podman || command -v docker)
CONTAINER_RUNTIME=docker

if [ -z "$CONTAINER_RUNTIME" ]; then
echo "Neither podman nor docker is available. Please install one to proceed."
Expand Down
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.7.1
5.10
18 changes: 0 additions & 18 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,6 @@
"revision" : "26cc5e9ae0947092c7139ef7ba612e34646086c7",
"version" : "0.10.1"
}
},
{
"identity" : "swift-docc-plugin",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-docc-plugin",
"state" : {
"revision" : "85e4bb4e1cd62cec64a4b8e769dcefdf0c5b9d64",
"version" : "1.4.3"
}
},
{
"identity" : "swift-docc-symbolkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-docc-symbolkit",
"state" : {
"revision" : "b45d1f2ed151d057b54504d653e0da5552844e34",
"version" : "1.0.0"
}
}
],
"version" : 2
Expand Down
3 changes: 1 addition & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.8
// swift-tools-version:5.10.0

import PackageDescription

Expand All @@ -10,7 +10,6 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/tadija/AEXML.git", .upToNextMinor(from: "4.6.1")),
.package(url: "https://github.com/kylef/PathKit.git", .upToNextMinor(from: "1.0.1")),
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.4.3"),
],
targets: [
.target(name: "XcodeProj",
Expand Down
54 changes: 27 additions & 27 deletions Sources/XcodeProj/Errors/Errors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public enum XCodeProjError: Error, CustomStringConvertible, Sendable {
public var description: String {
switch self {
case let .notFound(path):
return "The project cannot be found at \(path.string)"
"The project cannot be found at \(path.string)"
case let .pbxprojNotFound(path):
return "The project doesn't contain a .pbxproj file at path: \(path.string)"
"The project doesn't contain a .pbxproj file at path: \(path.string)"
case let .xcworkspaceNotFound(path):
return "The project doesn't contain a .xcworkspace at path: \(path.string)"
"The project doesn't contain a .xcworkspace at path: \(path.string)"
}
}
}
Expand All @@ -36,7 +36,7 @@ public enum XCSharedDataError: Error, CustomStringConvertible {
public var description: String {
switch self {
case let .notFound(path):
return "xcshareddata not found at path \(path.string)"
"xcshareddata not found at path \(path.string)"
}
}
}
Expand All @@ -52,7 +52,7 @@ public enum XCUserDataError: Error, CustomStringConvertible {
public var description: String {
switch self {
case let .notFound(path):
return "xcuserdata not found at path \(path.string)"
"xcuserdata not found at path \(path.string)"
}
}
}
Expand All @@ -68,7 +68,7 @@ public enum XCWorkspaceError: Error, CustomStringConvertible {
public var description: String {
switch self {
case let .notFound(path):
return "The project cannot be found at \(path.string)"
"The project cannot be found at \(path.string)"
}
}
}
Expand All @@ -84,7 +84,7 @@ public enum XCWorkspaceDataError: Error, CustomStringConvertible {
public var description: String {
switch self {
case let .notFound(path):
return "Workspace not found at \(path.string)"
"Workspace not found at \(path.string)"
}
}
}
Expand All @@ -100,7 +100,7 @@ public enum XcodeprojEditingError: Error, CustomStringConvertible {
public var description: String {
switch self {
case let .unexistingFile(path):
return "The file at path \(path.string) doesn't exist"
"The file at path \(path.string) doesn't exist"
}
}
}
Expand All @@ -116,7 +116,7 @@ public enum XcodeprojWritingError: Error, CustomStringConvertible {
public var description: String {
switch self {
case let .invalidType(classType, expected):
return "Invalid type for object \(classType) that expects a \(expected)"
"Invalid type for object \(classType) that expects a \(expected)"
}
}
}
Expand All @@ -140,15 +140,15 @@ public enum PBXObjectError: Error, CustomStringConvertible {
public var description: String {
switch self {
case .missingIsa:
return "Isa property is missing."
"Isa property is missing."
case let .unknownElement(element):
return "The element \(element) is not supported."
"The element \(element) is not supported."
case .objectsReleased:
return "The PBXObjects instance has been released before saving."
"The PBXObjects instance has been released before saving."
case let .objectNotFound(reference):
return "PBXObject with reference \"\(reference)\" not found."
"PBXObject with reference \"\(reference)\" not found."
case let .orphaned(type, reference):
return "Trying to use object \(type) with reference '\(reference)' before being added to any project"
"Trying to use object \(type) with reference '\(reference)' before being added to any project"
}
}
}
Expand All @@ -164,7 +164,7 @@ enum PBXProjEncoderError: Error, CustomStringConvertible {
var description: String {
switch self {
case .emptyProjectReference:
return "PBXProj should contain a reference to the XcodeProj object that represents the project"
"PBXProj should contain a reference to the XcodeProj object that represents the project"
}
}
}
Expand All @@ -187,23 +187,23 @@ enum PBXProjError: Error, CustomStringConvertible, Equatable {
var description: String {
switch self {
case let .notFound(path):
return ".pbxproj not found at path \(path.string)"
".pbxproj not found at path \(path.string)"
case let .invalidGroupPath(sourceRoot, elementPath):
return "Cannot calculate full path for file element \"\(elementPath ?? "")\" in source root: \"\(sourceRoot)\""
"Cannot calculate full path for file element \"\(elementPath ?? "")\" in source root: \"\(sourceRoot)\""
case let .targetNotFound(targetName):
return "Could not find target with \(targetName)"
"Could not find target with \(targetName)"
case let .frameworksBuildPhaseNotFound(targetName):
return "Could not find frameworks build phase for target \(targetName)"
"Could not find frameworks build phase for target \(targetName)"
case let .sourcesBuildPhaseNotFound(targetName):
return "Could not find sources build phase for target \(targetName)"
"Could not find sources build phase for target \(targetName)"
case let .pathIsAbsolute(path):
return "Path must be relative, but path \(path.string) is absolute"
"Path must be relative, but path \(path.string) is absolute"
case let .multipleLocalPackages(productName: productName):
return "Found multiple top-level packages named \(productName)"
"Found multiple top-level packages named \(productName)"
case let .multipleRemotePackages(productName: productName):
return "Can not resolve dependency \(productName) - conflicting version requirements"
"Can not resolve dependency \(productName) - conflicting version requirements"
case .malformed:
return "The .pbxproj is malformed."
"The .pbxproj is malformed."
}
}
}
Expand All @@ -221,9 +221,9 @@ public enum XCBreakpointListError: Error, CustomStringConvertible {
public var description: String {
switch self {
case let .notFound(path):
return "Breakpoints_v2.xcbkptlist couldn't be found at path \(path.string)"
"Breakpoints_v2.xcbkptlist couldn't be found at path \(path.string)"
case let .missing(property):
return "Property \(property) missing"
"Property \(property) missing"
}
}
}
Expand All @@ -238,7 +238,7 @@ public enum XCConfigError: Error, CustomStringConvertible {
public var description: String {
switch self {
case let .notFound(path):
return ".xcconfig file not found at \(path.string)"
".xcconfig file not found at \(path.string)"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ extension KeyedDecodingContainer {

func decodeIntIfPresent(_ key: KeyedDecodingContainer.Key) throws -> UInt? {
if let string: String = try? decodeIfPresent(key) {
return UInt(string)
UInt(string)
} else if let bool: Bool = try? decodeIfPresent(key) {
return bool ? 0 : 1
bool ? 0 : 1
} else if let int: UInt = try decodeIfPresent(key) {
// don't `try?` here in case key _does_ exist but isn't an expected type
// ie. not a string/bool/int
return int
int
} else {
return nil
nil
}
}

Expand Down
24 changes: 12 additions & 12 deletions Sources/XcodeProj/Objects/Files/PBXContainerItemProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ public final class PBXContainerItemProxy: PBXObject {

var uuid: String {
switch self {
case let .reference(reference): return reference.value
case let .string(string): return string
case let .reference(reference): reference.value
case let .string(string): string
}
}

var id: RemoteGlobalID {
switch self {
case let .reference(reference):
if let object = reference.getObject() {
return .object(object)
.object(object)
} else {
return .string(reference.value)
.string(reference.value)
}
case let .string(string): return .string(string)
case let .string(string): .string(string)
}
}
}
Expand All @@ -44,15 +44,15 @@ public final class PBXContainerItemProxy: PBXObject {

var uuid: String {
switch self {
case let .object(object): return object.uuid
case let .string(string): return string
case let .object(object): object.uuid
case let .string(string): string
}
}

var reference: RemoteGlobalIDReference {
switch self {
case let .object(object): return .reference(object.reference)
case let .string(string): return .string(string)
case let .object(object): .reference(object.reference)
case let .string(string): .string(string)
}
}
}
Expand Down Expand Up @@ -185,11 +185,11 @@ private extension PBXContainerItemProxy.ContainerPortal {
var reference: PBXObjectReference? {
switch self {
case let .project(project):
return project.reference
project.reference
case let .fileReference(fileReference):
return fileReference.reference
fileReference.reference
case .unknownObject:
return nil
nil
}
}

Expand Down
11 changes: 5 additions & 6 deletions Sources/XcodeProj/Objects/Files/PBXGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,17 @@ public extension PBXGroup {
return existingFileReference.value
}

let path: String?
switch sourceTree {
let path: String? = switch sourceTree {
case .group:
path = groupPath.map { filePath.relative(to: $0) }?.string
groupPath.map { filePath.relative(to: $0) }?.string
case .sourceRoot:
path = filePath.relative(to: sourceRoot).string
filePath.relative(to: sourceRoot).string
case .absolute,
.sdkRoot,
.developerDir:
path = filePath.string
filePath.string
default:
path = nil
nil
}
let fileReference = PBXFileReference(
sourceTree: sourceTree,
Expand Down
Loading
Loading