-
-
Notifications
You must be signed in to change notification settings - Fork 309
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
Update project to Swift 5.10 and start on Sendable
updates
#833
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8852c48
Bump to Swift 5.10 for Swift 6 language mode warnings
waltflanagan ef6d866
Introduce `BuildSetting` enum to enable strongly typed setting serial…
waltflanagan e9e9bc4
Migrate `BuildSettings` to use `BuildSetting` enum.
waltflanagan 51c7f9f
Use `withLock` from `NSLocking` protocol instead of custom implementa…
waltflanagan 49514f4
Add `NSRecursiveLock` to `PBXObjectReference` to provide thread safety.
waltflanagan bf6a64a
Fix Tests
waltflanagan 976ab8f
Add missing `Linux` implementation of `withLock`
waltflanagan 0cc904d
Update `PlistValue` to write `BuildSetting` correctly
waltflanagan 74dde97
Fix tests
waltflanagan d8c4202
Fix equality on `XCBuildConfiguration`
waltflanagan bec42a6
Make underscore (_) properties completely private
waltflanagan e2b09d3
Unify `object` access in `PBXObjectReference`
waltflanagan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// swift-tools-version:5.8 | ||
// swift-tools-version:5.10 | ||
|
||
import PackageDescription | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Foundation | ||
|
||
// reimplemention of `withLock` from `NSLocking` extension that is exclusive to the macOS version of `Foundation` | ||
extension NSLocking { | ||
func withLock<T>(_ body: () throws -> T) rethrows -> T { | ||
lock() | ||
defer { unlock() } | ||
return try body() | ||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
51 changes: 50 additions & 1 deletion
51
Sources/XcodeProj/Objects/Configuration/BuildSettings.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,53 @@ | ||
import Foundation | ||
|
||
/// Build settings. | ||
public typealias BuildSettings = [String: Any] | ||
public typealias BuildSettings = [String: BuildSetting] | ||
|
||
public enum BuildSetting: Sendable, Equatable { | ||
case string(String) | ||
case array([String]) | ||
|
||
var valueForWriting: String { | ||
switch self { | ||
case .string(let string): | ||
return string | ||
case .array(let array): | ||
return array.joined(separator: " ") | ||
} | ||
} | ||
} | ||
|
||
extension BuildSetting: Codable { | ||
public init(from decoder: Decoder) throws { | ||
let container = try decoder.singleValueContainer() | ||
do { | ||
let string = try container.decode(String.self) | ||
self = .string(string) | ||
} catch { | ||
let array = try container.decode([String].self) | ||
self = .array(array) | ||
} | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.singleValueContainer() | ||
switch self { | ||
case .string(let string): | ||
try container.encode(string) | ||
case .array(let array): | ||
try container.encode(array) | ||
} | ||
} | ||
} | ||
|
||
extension BuildSetting: ExpressibleByArrayLiteral { | ||
public init(arrayLiteral elements: String...) { | ||
self = .array(elements) | ||
} | ||
} | ||
|
||
extension BuildSetting: ExpressibleByStringLiteral { | ||
public init(stringLiteral value: StringLiteralType) { | ||
self = .string(value) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I think having three APIs for the same is unnecessary. I believe (it's been a long time) that the motivation for having
getThrowingObject
was to instruct developers at runtime about bad usages of the library. For example adding a reference to an object that's not strongly referenced by the project. However, looking at thegetThrowingObject
implementation, and don't know if the error that we are throwing is more helpful than trying to do a force unwrap of the referenced object.I'm between making
getThrowingObject
errors more useful, which would require adding more context toPBXObjectReference
to ensure it's in sync, which is a bit of a tricky challenge, or removinggetObject
andgetThrowingObject
and having a single accessor. I'd say that we do the latter.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up going with
object() -> T?
since that preserved the most current callsites. Also addedobject(as: T.Type)
to avoid a double cast when used incompactMap