Skip to content

iCloud Drive のフォルダにアプリのアイコンを出す - #141

Merged
temoki merged 4 commits into
mainfrom
feature/icloud-documents
Oct 6, 2026
Merged

temoki merged 4 commits into
mainfrom
feature/icloud-documents

Conversation

@temoki

@temoki temoki commented Oct 6, 2026

Copy link
Copy Markdown
Owner

iCloud Drive の「Tortoise Blocks」フォルダに、アプリのアイコンが出るようにします(#140)。iPhone / iPad / Vision Pro が対象で、Mac は対象外です。

  • アプリ専用の iCloud コンテナを使う:iCloud.space.hiraku.tortoiseblocks を CloudDocuments で使い、NSUbiquitousContainers で Documents/ を公開します。これまでのフォルダは書類ブラウザが作ったただのフォルダで、ただのフォルダにはアイコンを付けられません。
  • Mac は entitlements を変えない:CODE_SIGN_ENTITLEMENTS[sdk=macosx*] で今のファイルを使い続けます。iCloud には provisioning profile が要るので、チームなしの ad-hoc 署名で回している Mac の Debug ビルドが起動しなくなるためです。指定のないときは iCloud ありなので、後から増えるプラットフォームは iCloud を引き継ぎます。
  • 起動時にコンテナを作る(UbiquityContainer.prepare()):DocumentGroup は新規書類をブラウザがいま開いているフォルダに作るだけで、コンテナには触らないためです。
  • 隠しファイル .keep を置く:空の Documents/ は iCloud Drive に表示されません。iPhone の実機で、.keep を置くとアイコン付きで表示されることを確かめました。
  • CLAUDE.md に、iCloud の構成、Mac を外した理由、シミュレータ版の entitlements の確かめ方を書きました。

確かめたこと

  • macOS / iPad / iPhone / visionOS の 4 つのビルド
  • 出来上がった製品の entitlements(Mac は iCloud なし、iOS と visionOS は iCloud あり)
  • Mac の Debug ビルドが ad-hoc 署名のまま起動すること
  • iPhone の実機で、iCloud Drive にアイコン付きのフォルダが出ること

既定の保存先をコンテナにする公式の API はありません。このため、リリースノートで新しいフォルダの開き方を案内します(下書きは #140 のコメント)。TestFlight ビルドでの確認などの手作業が #140 に残っているので、この PR では Issue を閉じません。

Refs #140

temoki added 4 commits October 6, 2026 13:28
The "Tortoise Blocks" folder in iCloud Drive was a plain folder the
document browser made, and a plain folder cannot carry an icon; only the
app's own ubiquity container, published through NSUbiquitousContainers,
can. Claim iCloud.space.hiraku.tortoiseblocks with CloudDocuments and
publish its document scope.

macOS keeps its old entitlements: iCloud needs a provisioning profile,
and the Mac's Debug loop is ad-hoc signed without a team. The bare
CODE_SIGN_ENTITLEMENTS carries iCloud and [sdk=macosx*] opts out, so a
platform added later inherits it rather than silently losing it.

Refs #140
The document browser makes a new document wherever it is looking, not in
the app's container, so nothing ever asked for the container and iCloud
Drive had no folder to show. Ask for it at launch, off the main actor,
and create its Documents folder.

From an app delegate rather than a view's task: no single view is there
on every launch.

Refs #140
An empty Documents folder stayed out of iCloud Drive on an iPhone — in
the Files app and in the app's own browser, minutes later — and appeared,
with its icon, once an empty .keep was inside it. Hidden, so a child has
nothing to find or delete, and a marker already there, or its .icloud
placeholder from another device, is left alone. Written through a file
coordinator, as writes into a ubiquity container have to be.

Refs #140
@temoki
temoki merged commit a49d204 into main Oct 6, 2026
7 checks passed
@temoki
temoki deleted the feature/icloud-documents branch October 6, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant