Skip to content

Conversation

@waahm7
Copy link
Contributor

@waahm7 waahm7 commented Jan 7, 2025

Fixes #185
Description of changes:
This PR fixes a bunch of Swift 6 errors (warnings for pre-Swift 6).

  • Marks a lot of our classes as unchecked Sendable; Swift cannot verify the Send-ability of these classes due to C pointers.
  • Refactors our tests to address some concurrency issues.
  • Marks the global allocator as unsafe, since Swift complains that global mutable things are not safe.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@waahm7 waahm7 changed the title WIP | Swift 6 Support Fix Concurrency Warnings in Swift 6 Jan 7, 2025
@waahm7 waahm7 marked this pull request as ready for review January 7, 2025 19:46
@waahm7 waahm7 requested a review from xiazhvera January 7, 2025 19:54
//extension Dictionary where Key == String, Value == EndpointProperty {
// /// Converts EndpointProperty to a dictionary of `String`: `AnyHashable`
// /// - Returns: Dictionary of `String`: `AnyHashable`
// func toStringHashableDictionary() -> [String: AnyHashable] {
Copy link
Contributor

Choose a reason for hiding this comment

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

The function seems not used. Is it safe to remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, removed.

])
])]
XCTAssertEqual(expectedProperties, properties)
// let expectedProperties = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Need clean up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, removed.

Comment on lines 95 to 96
sed -i '' 's/swift-tools-version:5\.7/swift-tools-version:6\.0/' Package.swift
cat Package.swift | head -3
Copy link
Contributor

Choose a reason for hiding this comment

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

if Package.swift doesn't have the exact string swift-tools-version:5.7, this step will just fail silently, which will make it hard to debug and probably leave the CI doesn't do the expected thing for us.

GenAI suggested something like:

Solution 1: Combined sed command with conditional exit
Bash
 Copy code
sed -i '' '/swift-tools-version:5\.7/{s/swift-tools-version:5\.7/swift-tools-version:6\.0/;b};q1' Package.swift
This will:
Search for the pattern
If found, make the substitution and branch to end of script (with b)
If not found, exit with code 1 (with q1)

Also, using the exact version seems less future proven. I am not sure if we will ever change the version in the package.swift, but in general, maybe just match all version instead.

Copy link
Contributor Author

@waahm7 waahm7 Apr 28, 2025

Choose a reason for hiding this comment

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

Thanks, I have made it more generic so that it works with any 5.xx version and also fails if it can't replace it.

@waahm7 waahm7 merged commit 35688e3 into main Apr 28, 2025
28 of 32 checks passed
@waahm7 waahm7 deleted the swift6-support branch April 28, 2025 20:58
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.

Use of GCD in asynchronous context

3 participants