Swift 6 build error: Static property 'schema' is not concurrency-safe
concavegit opened this issue ยท 2 comments
concavegit commented
Environment information
System:
OS: macOS 15.0
CPU: (8) arm64 Apple M2
Memory: 118.66 MB / 24.00 GB
Shell: /bin/zsh
Binaries:
Node: 22.9.0 - /opt/homebrew/bin/node
Yarn: undefined - undefined
npm: 10.8.3 - /opt/homebrew/bin/npm
pnpm: undefined - undefined
NPM Packages:
@aws-amplify/auth-construct: 1.3.1
@aws-amplify/backend: 1.2.2
@aws-amplify/backend-auth: 1.1.5
@aws-amplify/backend-cli: 1.2.7
@aws-amplify/backend-data: 1.1.4
@aws-amplify/backend-deployer: 1.1.3
@aws-amplify/backend-function: 1.4.1
@aws-amplify/backend-output-schemas: 1.2.0
@aws-amplify/backend-output-storage: 1.1.2
@aws-amplify/backend-secret: 1.1.2
@aws-amplify/backend-storage: 1.1.3
@aws-amplify/cli-core: 1.1.3
@aws-amplify/client-config: 1.3.1
@aws-amplify/deployed-backend-client: 1.4.1
@aws-amplify/form-generator: 1.0.2
@aws-amplify/model-generator: 1.0.7
@aws-amplify/platform-core: 1.1.0
@aws-amplify/plugin-types: 1.2.2
@aws-amplify/sandbox: 1.2.2
@aws-amplify/schema-generator: 1.2.3
aws-amplify: 6.6.2
aws-cdk: 2.159.0
aws-cdk-lib: 2.159.0
typescript: 5.6.2
AWS environment variables:
AWS_STS_REGIONAL_ENDPOINTS = regional
AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables
Describe the bug
I updated my iOS app from Swift 5 to Swift 6, and the build fails due to this error in the generated +Schema.swift files:
/Users/concaveusr/Projects/Kanai/Kanai/AmplifyModels/KanaiUserInfo+Schema.swift:23:21 Static property 'schema' is not concurrency-safe because non-'Sendable' type 'ModelSchema' may have shared mutable state
Note that putting @preconcurrency at the top of the generated Schema files suppresses the error, but I'm creating this issue to either add that automatically, or to even better find a way to make schema concurrency-safe.
Reproduction steps
Make any model in Amplify Gen 2 and put it in your Swift 6 Xcode project and try to build it.
ykethan commented
Hey,๐ thanks for raising this! I'm going to transfer this over to our API repository for better assistance ๐
dpilch commented
ModelSchema
actually is defined in the Amplify Swift library, so I think this issue will be solved there.