2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Swift】Resourcesのjsonが読み込めなくなった時はこうしろ

Last updated at Posted at 2023-03-30

SwiftUIのチュートリアルをやっていたらなぜかResourcesフォルダーにある
jsonファイルが読み込めなくなった時のレポ
Untitled.png
こんな感じでPreviewが表示されずに困った

解決策❶: ファイル追加時にResourcesに自動登録する

D&Dでファイルをプロジェクトに追加するときに
Untitled.png
Add to targets: にチェックを入れることでResourcesが自動で追加される
これを忘れると手動でやる羽目になる

解決策❷: 後から自力でResourcesを追加する

project をクリック
Untitled.png
Build Phases をクリック
Untitled.png
Copy Bundle Resources (Any items) をクリックUntitled.png
+ を押して読み込ませたResourcesをAddする
Untitled.png
表示できるようになる
Untitled.png

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?