diff --git a/GRDB/Documentation.docc/SwiftConcurrency.md b/GRDB/Documentation.docc/SwiftConcurrency.md index 684d66af5..9664c2da9 100644 --- a/GRDB/Documentation.docc/SwiftConcurrency.md +++ b/GRDB/Documentation.docc/SwiftConcurrency.md @@ -6,9 +6,9 @@ How to best integrate GRDB and Swift Concurrency GRDB leverages the strengths of both SQLite and Swift 6 when it comes to concurrency. -For instance, when an application connects to the database using a ``DatabasePool``, it can read from the database and display values on the screen, even while a background task is writing the results of a network request to disk. This is possible because SQLite supports [Write-Ahead Logging]. +For instance, when an application connects to the database using a ``DatabasePool``, it can read from the database and display values on the screen, even while a background task is writing the results of a network request to disk. -On the other hand, application previews and tests may prefer to connect to an in-memory ``DatabaseQueue``, which does not support concurrent access, but avoids writing to disk. +On the other hand, application previews and tests can connect to an in-memory ``DatabaseQueue``, which does not support concurrent access, but avoids writing to disk. To choose the appropriate connection for different situations, applications can use the shared ``DatabaseWriter`` protocol, which ensures the concurrency guarantees described in . For examples of this integration, see the [demo apps]. @@ -39,10 +39,52 @@ for try await players in observation.values(in: writer) { Database accesses are handled through closures (as shown with the db argument above). GRDB schedules them optimally, in the best interest of the application. -The Swift 6 compiler ensures that no data races occur during these database accesses. +Depending of the language mode and level of concurrency checkings used by your application (see [Migrating to Swift 6]), you may see warnings or errors. We will address them, and provide general advice below. -### Section header +### Usability of global-actor-isolated types + +The database access closures can be written explicitly, or with the shorthand notation: + +```swift +// Explicit closure +let count = try await writer.read { db in + try Player.fetchCount(db) +} + +// Shorthand notation +let count = try await writer.read(Player.fetchCount) +``` + +The shorthand notation can trigger a warning with the Swift 6 compiler: + +> Compiler warning: Converting non-sendable function value to '@Sendable (Database) throws -> Int' may introduce data races. + +You can remove this warning by enabling "Usability of global-actor-isolated types", described in [SE-0434], as below: + +**Using Xcode** + +Set `SWIFT_UPCOMING_FEATURE_INFER_SENDABLE_FROM_CAPTURES` to `YES` in the build settings of your target. + +**In a SwiftPM package manifest** + +Enable the "GlobalActorIsolatedTypesUsability" upcoming feature: + +```swift +.target( + name: "MyTarget", + swiftSettings: [ + .enableUpcomingFeature("GlobalActorIsolatedTypesUsability") + ] +) +``` -[Write-Ahead Logging]: https://www.sqlite.org/draft/wal.html +- Sendable record types and the Record class +- databaseSelection, databaseDecodingUserInfo, databaseEncodingUserInfo +- InferSendableFromCaptures +- GlobalActorIsolatedTypesUsability? +- Avoid sync db access methods in async contexts + [demo apps]: https://github.com/groue/GRDB.swift/tree/master/Documentation/DemoApps +[Migrating to Swift 6]: https://www.swift.org/migration/documentation/migrationguide/ +[SE-0434]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0434-global-actor-isolated-types-usability.md diff --git a/Tests/Swift6Migration/Swift6Migration.xcodeproj/project.pbxproj b/Tests/Swift6Migration/Swift6Migration.xcodeproj/project.pbxproj new file mode 100644 index 000000000..476f1a544 --- /dev/null +++ b/Tests/Swift6Migration/Swift6Migration.xcodeproj/project.pbxproj @@ -0,0 +1,354 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 77; + objects = { + +/* Begin PBXBuildFile section */ + 56CFC7D22CA03647000B5023 /* GRDB in Frameworks */ = {isa = PBXBuildFile; productRef = 56CFC7D12CA03647000B5023 /* GRDB */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 56CFC7BF2CA035E7000B5023 /* Swift6Migration.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Swift6Migration.app; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFileSystemSynchronizedRootGroup section */ + 56CFC7C12CA035E7000B5023 /* Swift6Migration */ = { + isa = PBXFileSystemSynchronizedRootGroup; + path = Swift6Migration; + sourceTree = ""; + }; +/* End PBXFileSystemSynchronizedRootGroup section */ + +/* Begin PBXFrameworksBuildPhase section */ + 56CFC7BC2CA035E7000B5023 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 56CFC7D22CA03647000B5023 /* GRDB in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 56CFC7B62CA035E7000B5023 = { + isa = PBXGroup; + children = ( + 56CFC7C12CA035E7000B5023 /* Swift6Migration */, + 56CFC7C02CA035E7000B5023 /* Products */, + ); + sourceTree = ""; + }; + 56CFC7C02CA035E7000B5023 /* Products */ = { + isa = PBXGroup; + children = ( + 56CFC7BF2CA035E7000B5023 /* Swift6Migration.app */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 56CFC7BE2CA035E7000B5023 /* Swift6Migration */ = { + isa = PBXNativeTarget; + buildConfigurationList = 56CFC7CD2CA035E8000B5023 /* Build configuration list for PBXNativeTarget "Swift6Migration" */; + buildPhases = ( + 56CFC7BB2CA035E7000B5023 /* Sources */, + 56CFC7BC2CA035E7000B5023 /* Frameworks */, + 56CFC7BD2CA035E7000B5023 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + fileSystemSynchronizedGroups = ( + 56CFC7C12CA035E7000B5023 /* Swift6Migration */, + ); + name = Swift6Migration; + packageProductDependencies = ( + 56CFC7D12CA03647000B5023 /* GRDB */, + ); + productName = Swift6Migration; + productReference = 56CFC7BF2CA035E7000B5023 /* Swift6Migration.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 56CFC7B72CA035E7000B5023 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1600; + LastUpgradeCheck = 1600; + TargetAttributes = { + 56CFC7BE2CA035E7000B5023 = { + CreatedOnToolsVersion = 16.0; + }; + }; + }; + buildConfigurationList = 56CFC7BA2CA035E7000B5023 /* Build configuration list for PBXProject "Swift6Migration" */; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 56CFC7B62CA035E7000B5023; + minimizedProjectReferenceProxies = 1; + packageReferences = ( + 56CFC7D02CA03647000B5023 /* XCLocalSwiftPackageReference "../../../GRDB.swift" */, + ); + preferredProjectObjectVersion = 77; + productRefGroup = 56CFC7C02CA035E7000B5023 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 56CFC7BE2CA035E7000B5023 /* Swift6Migration */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 56CFC7BD2CA035E7000B5023 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 56CFC7BB2CA035E7000B5023 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 56CFC7CB2CA035E8000B5023 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 18.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_STRICT_CONCURRENCY = complete; + SWIFT_UPCOMING_FEATURE_INFER_SENDABLE_FROM_CAPTURES = YES; + }; + name = Debug; + }; + 56CFC7CC2CA035E8000B5023 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 18.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_STRICT_CONCURRENCY = complete; + SWIFT_UPCOMING_FEATURE_INFER_SENDABLE_FROM_CAPTURES = YES; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 56CFC7CE2CA035E8000B5023 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"Swift6Migration/Preview Content\""; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.Swift6Migration; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 56CFC7CF2CA035E8000B5023 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"Swift6Migration/Preview Content\""; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.Swift6Migration; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 56CFC7BA2CA035E7000B5023 /* Build configuration list for PBXProject "Swift6Migration" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 56CFC7CB2CA035E8000B5023 /* Debug */, + 56CFC7CC2CA035E8000B5023 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 56CFC7CD2CA035E8000B5023 /* Build configuration list for PBXNativeTarget "Swift6Migration" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 56CFC7CE2CA035E8000B5023 /* Debug */, + 56CFC7CF2CA035E8000B5023 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + 56CFC7D02CA03647000B5023 /* XCLocalSwiftPackageReference "../../../GRDB.swift" */ = { + isa = XCLocalSwiftPackageReference; + relativePath = ../../../GRDB.swift; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 56CFC7D12CA03647000B5023 /* GRDB */ = { + isa = XCSwiftPackageProductDependency; + productName = GRDB; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 56CFC7B72CA035E7000B5023 /* Project object */; +} diff --git a/Tests/Swift6Migration/Swift6Migration.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Tests/Swift6Migration/Swift6Migration.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..919434a62 --- /dev/null +++ b/Tests/Swift6Migration/Swift6Migration.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Tests/Swift6Migration/Swift6Migration/Assets.xcassets/AccentColor.colorset/Contents.json b/Tests/Swift6Migration/Swift6Migration/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 000000000..eb8789700 --- /dev/null +++ b/Tests/Swift6Migration/Swift6Migration/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Tests/Swift6Migration/Swift6Migration/Assets.xcassets/AppIcon.appiconset/Contents.json b/Tests/Swift6Migration/Swift6Migration/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..230588010 --- /dev/null +++ b/Tests/Swift6Migration/Swift6Migration/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,35 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "tinted" + } + ], + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Tests/Swift6Migration/Swift6Migration/Assets.xcassets/Contents.json b/Tests/Swift6Migration/Swift6Migration/Assets.xcassets/Contents.json new file mode 100644 index 000000000..73c00596a --- /dev/null +++ b/Tests/Swift6Migration/Swift6Migration/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Tests/Swift6Migration/Swift6Migration/ContentView.swift b/Tests/Swift6Migration/Swift6Migration/ContentView.swift new file mode 100644 index 000000000..a7b0b6368 --- /dev/null +++ b/Tests/Swift6Migration/Swift6Migration/ContentView.swift @@ -0,0 +1,24 @@ +// +// ContentView.swift +// Swift6Migration +// +// Created by Gwendal Roué on 22/09/2024. +// + +import SwiftUI + +struct ContentView: View { + var body: some View { + VStack { + Image(systemName: "globe") + .imageScale(.large) + .foregroundStyle(.tint) + Text("Hello, world!") + } + .padding() + } +} + +#Preview { + ContentView() +} diff --git a/Tests/Swift6Migration/Swift6Migration/InferSendableFromCaptures.swift b/Tests/Swift6Migration/Swift6Migration/InferSendableFromCaptures.swift new file mode 100644 index 000000000..0e510ba66 --- /dev/null +++ b/Tests/Swift6Migration/Swift6Migration/InferSendableFromCaptures.swift @@ -0,0 +1,9 @@ +import GRDB + +private struct Player: TableRecord { } + +private func fetchCount(_ writer: any DatabaseWriter) async throws -> Int { + // Converting non-sendable function value to + // '@Sendable (Database) throws -> Int' may introduce data races. + try await writer.read(Player.fetchCount) +} diff --git a/Tests/Swift6Migration/Swift6Migration/Preview Content/Preview Assets.xcassets/Contents.json b/Tests/Swift6Migration/Swift6Migration/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 000000000..73c00596a --- /dev/null +++ b/Tests/Swift6Migration/Swift6Migration/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Tests/Swift6Migration/Swift6Migration/Swift6MigrationApp.swift b/Tests/Swift6Migration/Swift6Migration/Swift6MigrationApp.swift new file mode 100644 index 000000000..9ef8b0b0c --- /dev/null +++ b/Tests/Swift6Migration/Swift6Migration/Swift6MigrationApp.swift @@ -0,0 +1,17 @@ +// +// Swift6MigrationApp.swift +// Swift6Migration +// +// Created by Gwendal Roué on 22/09/2024. +// + +import SwiftUI + +@main +struct Swift6MigrationApp: App { + var body: some Scene { + WindowGroup { + ContentView() + } + } +}