Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Is it possible to use SwiftData?

オープン
#149 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
28/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
swift

調査の方向性

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 の本文から書いたものです。

説明

enhancement

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時間 33分
マージ済み PR(30日)
25

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

xtool-org/xtool のほかの issue

xtool-org/xtool の issue をすべて見る

似ている issue

Swift の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。