SecurePropertyStorage
SecurePropertyStorage copied to clipboard
Fix concurrency issues in Swift 6
Description:
With the upcoming Swift 6 release, strict concurrency checks will be enforced. Our project, SecurePropertyStorage, currently has several warnings related to concurrency safety that need to be addressed to ensure compatibility and stability. This issue aims to track and resolve all these warnings.
Steps to Reproduce:
- Open
SecurePropertyStorage.xcodeproj
project file. - Set the
SWIFT_STRICT_CONCURRENCY
flag tocomplete
in the project build settings. - Run
SecurePropertyStorage-Package
scheme tests. - Observe the warnings related to concurrency safety.
Warnings to Fix:
Associated Value Warnings:
-
InjectError
enum warnings:-
Location:
Sources/Inject/InjectError.swift:4:10
- Associated value
notFound(_:qualifiers:group:)
ofSendable
-conforming enumInjectError
has non-sendable typeAny
- Associated value
notFound(_:qualifiers:group:)
ofSendable
-conforming enumInjectError
has non-sendable typeQualifier
(akaProtocol
)
- Associated value
-
Location:
Sources/Inject/InjectError.swift:6:10
- Associated value
moreThanOne(_:qualifiers:group:)
ofSendable
-conforming enumInjectError
has non-sendable typeAny
- Associated value
moreThanOne(_:qualifiers:group:)
ofSendable
-conforming enumInjectError
has non-sendable typeQualifier
(akaProtocol
)
- Associated value
-
Location:
Static Property Warnings:
-
Static property 'shared' is not concurrency-safe:
-
Locations:
-
Sources/Inject/InjectStorage.swift:7:24
-
Sources/Keychain/KeychainStorage.swift:9:24
-
Sources/Singleton/SingletonStorage.swift:10:24
-
Sources/UserDefault/UserDefaultsStorage.swift:10:24
-
-
Locations:
Test Warnings:
-
Static property 'allTests' is not concurrency-safe:
-
Locations:
-
Tests/SecurePropertyStorageTests/InjectTests.swift:195:16
-
Tests/SecurePropertyStorageTests/KeychainTests.swift:252:16
-
Tests/SecurePropertyStorageTests/SingletonTests.swift:79:16
-
Tests/SecurePropertyStorageTests/UserDefaultTests.swift:243:16
-
-
Locations:
-
Let properties not concurrency-safe:
-
Locations:
-
Tests/SecurePropertyStorageTests/KeychainTests.swift:10:5
-
Tests/SecurePropertyStorageTests/SingletonTests.swift:10:5
-
Tests/SecurePropertyStorageTests/UserDefaultTests.swift:10:5
-
-
Locations:
-
Call to main actor-isolated instance method
waitForExpectations(timeout:handler:)
in a synchronous nonisolated context:-
Locations:
-
Tests/SecurePropertyStorageTests/KeychainTests.swift:65:9
-
Tests/SecurePropertyStorageTests/KeychainTests.swift:81:9
-
Tests/SecurePropertyStorageTests/KeychainTests.swift:97:9
-
Tests/SecurePropertyStorageTests/KeychainTests.swift:111:9
-
Tests/SecurePropertyStorageTests/KeychainTests.swift:127:9
-
Tests/SecurePropertyStorageTests/KeychainTests.swift:141:9
-
Tests/SecurePropertyStorageTests/KeychainTests.swift:157:9
-
Tests/SecurePropertyStorageTests/KeychainTests.swift:171:9
-
Tests/SecurePropertyStorageTests/KeychainTests.swift:187:9
-
Tests/SecurePropertyStorageTests/KeychainTests.swift:201:9
-
Tests/SecurePropertyStorageTests/KeychainTests.swift:217:9
-
Tests/SecurePropertyStorageTests/KeychainTests.swift:233:9
-
Tests/SecurePropertyStorageTests/KeychainTests.swift:249:9
-
-
Locations:
Proposed Solution:
- Ensure all associated values in
Sendable
-conforming enums are ofSendable
types. - Modify static properties to conform to
Sendable
or isolate them to a global actor. - Ensure all tests and shared mutable states are concurrency-safe or properly isolated.
References: