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

Support Swift 6 #91

Merged
merged 9 commits into from
Jul 7, 2024
Merged

Support Swift 6 #91

merged 9 commits into from
Jul 7, 2024

Conversation

dfed
Copy link
Owner

@dfed dfed commented Jun 28, 2024

Gets us running well in Swift 6 language mode.

We'll add CI when Xcode 16 is in CI. For now I'm testing locally.

@dfed dfed self-assigned this Jun 28, 2024
Copy link

codecov bot commented Jun 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.66%. Comparing base (13c4533) to head (0733e61).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #91      +/-   ##
==========================================
- Coverage   99.66%   99.66%   -0.01%     
==========================================
  Files          47       47              
  Lines       11520    11519       -1     
==========================================
- Hits        11481    11480       -1     
  Misses         39       39              
Files Coverage Δ
Sources/SafeDICore/Generators/ScopeGenerator.swift 99.66% <ø> (ø)
Sources/SafeDICore/Models/Dependency.swift 100.00% <ø> (ø)
Sources/SafeDICore/Models/ImportStatement.swift 95.00% <ø> (ø)
Sources/SafeDICore/Models/Initializer.swift 98.95% <ø> (ø)
Sources/SafeDICore/Models/Instantiable.swift 100.00% <ø> (ø)
Sources/SafeDITool/SafeDITool.swift 100.00% <ø> (ø)
...eDIToolTests/Helpers/SafeDIToolTestExecution.swift 100.00% <ø> (ø)
...ToolTests/SafeDIToolCodeGenerationErrorTests.swift 99.88% <100.00%> (+<0.01%) ⬆️
...afeDIToolTests/SafeDIToolCodeGenerationTests.swift 100.00% <ø> (ø)
...SafeDIToolTests/SafeDIToolDOTGenerationTests.swift 100.00% <ø> (ø)

@dfed dfed marked this pull request as ready for review June 28, 2024 04:29
@@ -11,45 +11,85 @@ struct SafeDIGenerateDependencyTree: BuildToolPlugin {
return []
}

let outputSwiftFile = context.pluginWorkDirectory.appending(subpath: "SafeDI.swift")
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes to this file are best viewed with whitespace changes turned off. Apple deprecated a ton of the path-based APIs in Swift 6 / Xcode 16.

@@ -101,9 +158,7 @@ extension Target {
func createBuildCommands(
context: XcodeProjectPlugin.XcodePluginContext,
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

somewhat annoyingly, XcodeProjectPlugin.XcodePluginContext has not been updated at all, and all of its APIs are deprecated. Hopefully an oversight that'll be fixed before Xcode 16.0 goes live.

@@ -417,7 +417,7 @@ actor ScopeGenerator: CustomStringConvertible {

private enum GenerationError: Error, CustomStringConvertible {
case erasedInstantiatorGenericDoesNotMatch(property: Property, instantiable: Instantiable)
case dependencyCycleDetected(any Collection<Property>, scope: ScopeGenerator)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any Collection is not Sendable, but Array is

@@ -299,4 +300,4 @@ protocol FileFinder {

extension FileManager: FileFinder {}

var fileFinder: FileFinder = FileManager.default
@MainActor var fileFinder: FileFinder = FileManager.default
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is still a gross hack... one day we'll fix it.

@@ -38,7 +38,6 @@ final class SafeDIToolCodeGenerationErrorTests: XCTestCase {
for fileToDelete in filesToDelete {
try FileManager.default.removeItem(at: fileToDelete)
}
fileFinder = FileManager.default
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since fileFinder is bound to the main actor we can't set it in this method.

@dfed
Copy link
Owner Author

dfed commented Jul 7, 2024

Happy to take feedback post-merge. We'll also be iterating here as we get closer to Swift 6's actual release + when Xcode 16 is available in CI.

@dfed dfed merged commit a5c6b15 into main Jul 7, 2024
13 checks passed
@dfed dfed deleted the dfed--swift-6 branch July 7, 2024 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant