aws-amplify / amplify-category-api

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development. This plugin provides functionality for the API category, allowing for the creation and management of GraphQL and REST based backends for your amplify project.
https://docs.amplify.aws/
Apache License 2.0
88 stars 76 forks source link

Swift 6 build error: Static property 'schema' is not concurrency-safe #2889

Open concavegit opened 23 hours ago

concavegit commented 23 hours ago

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 22 hours ago

Hey,👋 thanks for raising this! I'm going to transfer this over to our API repository for better assistance 🙂