Is it possible to use SwiftData?
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 28/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- swift
- 领域
- build-system, tooling
调研方向
Start by reading the reported example in Sources/tracker/Data.swift and running xtool dev to reproduce the missing SwiftDataMacros plugin error. Investigate whether xtool can support SwiftData macro expansion; the issue gives no implementation path or tests. Done means the example builds successfully, or the project documents that SwiftData is unsupported.
由索引模型根据 Issue 内容生成。
描述
I'm really new to swift and i don't really know if it's a bug, so filing without the bug label. Thanks in advance for helping :)
if i do something like this:
import SwiftData
@Model
final class Person {
var firstName: String
var lastName: String
var relatives: [Person] = []
}
compilation will fail with a massive wall of repeating errors like this:
root@48e2171c8734:/ios/tracker# xtool dev
Planning...
[1/1] Planning build
Building for debugging...
error: emit-module command failed with exit code 1 (use -v to see invocation)
/ios/tracker/Sources/tracker/Data.swift:4:13: error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; plugin for module 'SwiftDataMacros' not found
2 |
3 | @Model
4 | final class Person {
| `- error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; plugin for module 'SwiftDataMacros' not found
5 | var firstName: String
6 | var lastName: String
SwiftData.Model:3:320: note: 'Model()' declared here
1 | @available(swift 5.9)
2 | @available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
3 | @attached(member, names: named(_$backingData), named(persistentBackingData), named(schemaMetadata), named(init), named(_$observationRegistrar), named(_SwiftDataNoType), named(access), named(withMutation)) @attached(memberAttribute) @attached(extension, conformances: Observable, PersistentModel, Sendable) public macro Model() = #externalMacro(module: "SwiftDataMacros", type: "PersistentModelMacro")
| `- note: 'Model()' declared here
/ios/tracker/Sources/tracker/Data.swift:5:9: error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; plugin for module 'SwiftDataMacros' not found
3 | @Model
4 | final class Person {
5 | var firstName: String
| `- error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; plugin for module 'SwiftDataMacros' not found
6 | var lastName: String
7 | var relatives: [Person] = []
SwiftData.Model:3:320: note: 'Model()' declared here
1 | @available(swift 5.9)
2 | @available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
3 | @attached(member, names: named(_$backingData), named(persistentBackingData), named(schemaMetadata), named(init), named(_$observationRegistrar), named(_SwiftDataNoType), named(access), named(withMutation)) @attached(memberAttribute) @attached(extension, conformances: Observable, PersistentModel, Sendable) public macro Model() = #externalMacro(module: "SwiftDataMacros", type: "PersistentModelMacro")
| `- note: 'Model()' declared here
/ios/tracker/Sources/tracker/Data.swift:6:9: error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; plugin for module 'SwiftDataMacros' not found
4 | final class Person {
5 | var firstName: String
6 | var lastName: String
| `- error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; plugin for module 'SwiftDataMacros' not found
7 | var relatives: [Person] = []
8 | }
SwiftData.Model:3:320: note: 'Model()' declared here
1 | @available(swift 5.9)
2 | @available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
3 | @attached(member, names: named(_$backingData), named(persistentBackingData), named(schemaMetadata), named(init), named(_$observationRegistrar), named(_SwiftDataNoType), named(access), named(withMutation)) @attached(memberAttribute) @attached(extension, conformances: Observable, PersistentModel, Sendable) public macro Model() = #externalMacro(module: "SwiftDataMacros", type: "PersistentModelMacro")
| `- note: 'Model()' declared here
/ios/tracker/Sources/tracker/Data.swift:7:6: error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; plugin for module 'SwiftDataMacros' not found
5 | var firstName: String
6 | var lastName: String
7 | var relatives: [Person] = []
| `- error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; plugin for module 'SwiftDataMacros' not found
8 | }
SwiftData.Model:3:320: note: 'Model()' declared here
1 | @available(swift 5.9)
2 | @available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
3 | @attached(member, names: named(_$backingData), named(persistentBackingData), named(schemaMetadata), named(init), named(_$observationRegistrar), named(_SwiftDataNoType), named(access), named(withMutation)) @attached(memberAttribute) @attached(extension, conformances: Observable, PersistentModel, Sendable) public macro Model() = #externalMacro(module: "SwiftDataMacros", type: "PersistentModelMacro")
| `- note: 'Model()' declared here
/ios/tracker/Sources/tracker/Data.swift:4:13: error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; plugin for module 'SwiftDataMacros' not found
2 |
3 | @Model
4 | final class Person {
| `- error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; plugin for module 'SwiftDataMacros' not found
5 | var firstName: String
6 | var lastName: String
SwiftData.Model:3:320: note: 'Model()' declared here
1 | @available(swift 5.9)
2 | @available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
3 | @attached(member, names: named(_$backingData), named(persistentBackingData), named(schemaMetadata), named(init), named(_$observationRegistrar), named(_SwiftDataNoType), named(access), named(withMutation)) @attached(memberAttribute) @attached(extension, conformances: Observable, PersistentModel, Sendable) public macro Model() = #externalMacro(module: "SwiftDataMacros", type: "PersistentModelMacro")
| `- note: 'Model()' declared here
/ios/tracker/Sources/tracker/Data.swift:4:13: error: class 'Person' has no initializers
2 |
3 | @Model
4 | final class Person {
| `- error: class 'Person' has no initializers
5 | var firstName: String
| `- note: stored property 'firstName' without initial value prevents synthesized initializers
6 | var lastName: String
| `- note: stored property 'lastName' without initial value prevents synthesized initializers
7 | var relatives: [Person] = []
8 | }
/ios/tracker/Sources/tracker/Data.swift:4:13: error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; plugin for module 'SwiftDataMacros' not found
2 |
3 | @Model
4 | final class Person {
| `- error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; plugin for module 'SwiftDataMacros' not found
5 | var firstName: String
6 | var lastName: String
SwiftData.Model:3:320: note: 'Model()' declared here
1 | @available(swift 5.9)
2 | @available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
3 | @attached(member, names: named(_$backingData), named(persistentBackingData), named(schemaMetadata), named(init), named(_$observationRegistrar), named(_SwiftDataNoType), named(access), named(withMutation)) @attached(memberAttribute) @attached(extension, conformances: Observable, PersistentModel, Sendable) public macro Model() = #externalMacro(module: "SwiftDataMacros", type: "PersistentModelMacro")
| `- note: 'Model()' declared here
/ios/tracker/Sources/tracker/Data.swift:5:9: error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; plugin for module 'SwiftDataMacros' not found
3 | @Model
4 | final class Person {
5 | var firstName: String
| `- error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; plugin for module 'SwiftDataMacros' not found
6 | var lastName: String
7 | var relatives: [Person] = []
SwiftData.Model:3:320: note: 'Model()' declared here
1 | @available(swift 5.9)
2 | @available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
3 | @attached(member, names: named(_$backingData), named(persistentBackingData), named(schemaMetadata), named(init), named(_$observationRegistrar), named(_SwiftDataNoType), named(access), named(withMutation)) @attached(memberAttribute) @attached(extension, conformances: Observable, PersistentModel, Sendable) public macro Model() = #externalMacro(module: "SwiftDataMacros", type: "PersistentModelMacro")
| `- note: 'Model()' declared here
/ios/tracker/Sources/tracker/Data.swift:6:9: error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; plugin for module 'SwiftDataMacros' not found
4 | final class Person {
5 | var firstName: String
6 | var lastName: String
| `- error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; plugin for module 'SwiftDataMacros' not found
7 | var relatives: [Person] = []
8 | }
SwiftData.Model:3:320: note: 'Model()' declared here
1 | @available(swift 5.9)
2 | @available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
3 | @attached(member, names: named(_$backingData), named(persistentBackingData), named(schemaMetadata), named(init), named(_$observationRegistrar), named(_SwiftDataNoType), named(access), named(withMutation)) @attached(memberAttribute) @attached(extension, conformances: Observable, PersistentModel, Sendable) public macro Model() = #externalMacro(module: "SwiftDataMacros", type: "PersistentModelMacro")
| `- note: 'Model()' declared here
/ios/tracker/Sources/tracker/Data.swift:7:6: error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; plugin for module 'SwiftDataMacros' not found
5 | var firstName: String
6 | var lastName: String
7 | var relatives: [Person] = []
| `- error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; plugin for module 'SwiftDataMacros' not found
8 | }
SwiftData.Model:3:320: note: 'Model()' declared here
1 | @available(swift 5.9)
2 | @available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
3 | @attached(member, names: named(_$backingData), named(persistentBackingData), named(schemaMetadata), named(init), named(_$observationRegistrar), named(_SwiftDataNoType), named(access), named(withMutation)) @attached(memberAttribute) @attached(extension, conformances: Observable, PersistentModel, Sendable) public macro Model() = #externalMacro(module: "SwiftDataMacros", type: "PersistentModelMacro")
| `- note: 'Model()' declared here
/ios/tracker/Sources/tracker/Data.swift:4:13: error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; plugin for module 'SwiftDataMacros' not found
2 |
3 | @Model
4 | final class Person {
| `- error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; plugin for module 'SwiftDataMacros' not found
5 | var firstName: String
6 | var lastName: String
SwiftData.Model:3:320: note: 'Model()' declared here
1 | @available(swift 5.9)
2 | @available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
3 | @attached(member, names: named(_$backingData), named(persistentBackingData), named(schemaMetadata), named(init), named(_$observationRegistrar), named(_SwiftDataNoType), named(access), named(withMutation)) @attached(memberAttribute) @attached(extension, conformances: Observable, PersistentModel, Sendable) public macro Model() = #externalMacro(module: "SwiftDataMacros", type: "PersistentModelMacro")
| `- note: 'Model()' declared here
/ios/tracker/Sources/tracker/Data.swift:4:13: error: class 'Person' has no initializers
2 |
3 | @Model
4 | final class Person {
| `- error: class 'Person' has no initializers
5 | var firstName: String
| `- note: stored property 'firstName' without initial value prevents synthesized initializers
6 | var lastName: String
| `- note: stored property 'lastName' without initial value prevents synthesized initializers
7 | var relatives: [Person] = []
8 | }
[3/6] Compiling tracker Data.swift
Error: exit(1)
is it generally possible to use swiftData, and if no, could you recommend some alternative please?
P.S. probably shouldn't affect anything, but i'm building from a docker container because i couldn't set xtool up on my Nixos host
- 主要语言
- Swift
- 星标
- 5.5k
- 派生
- 163
- 平均合并
- 19 小时 16 分钟
- 30 天内合并 PR
- 26
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
xtool-org/xtool 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 63/100
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 46/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 1 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 45/100
维护者通常 1 天内回复
-
[Feature Request] Add `xtool update` command for automatic CLI updates可能已有人在做 @Madhav008 于 4 天前认领。 未关闭enhancement
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
相似的 Issue
-
simulator-session.yml の simtunnel の固定先が古く、agentd が無いため simtunnel up --wait / status が準備完了を検知できない未关闭
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 1/5 1-3 小时 新手友好度 85/100
apache/arrow-swift#203 ·
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
RealtimeV2 fails to compile on Xcode 27.1 / Swift 6.4: ambiguous implicit access level for import of 'HTTPTypes'可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭Realtime swift
难度 2/5 1-3 小时 新手友好度 68/100
supabase/supabase-swift#1647 ·
维护者通常 1 天内回复
-
[Pri] Low [Status] Ready for Dev [Type] Bug /Me
难度 2/5 1-3 小时 新手友好度 78/100
wordpress-mobile/WordPress-iOS#26279 · 1 条评论 ·
维护者通常 1 天内回复