docs(ios): document global file asset loading - #936
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
There was a problem hiding this comment.
🟡 Changes recommended
The new Swift snippets in loading-assets.mdx contain documented-type vs pattern-matching inconsistencies for .unknown(UInt16) and an apparent method-call signature mismatch for removeGlobalFontAsset.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Updates the Apple runtime documentation to explain the modern, worker-based “global asset” replacement flow for the legacy customLoader, centered on creating a File, inspecting File.getAssets() metadata, and registering replacements by asset.uniqueName (including manual CDN loading via cdn metadata).
Changes:
- Expands the Apple “Loading Assets” page with an end-to-end workflow (discover → load bytes → decode → register) plus hosted/CDN asset fetching guidance.
- Updates the Apple legacy migration guide to show the
File.getAssets()replacement pattern and clarifies automatic CDN loading differences. - Refreshes the Apple overview’s Worker section to reference the new asset inspection/registration model.
File summaries
| File | Description |
|---|---|
| runtimes/apple/migrating-from-legacy.mdx | Reframes customLoader migration guidance around File.getAssets() + global asset registration and clarifies CDN behavior. |
| runtimes/apple/loading-assets.mdx | Introduces detailed asset discovery/metadata reference, complete examples, hosted asset loading, and global asset management guidance. |
| runtimes/apple/apple.mdx | Updates Worker overview text to point readers to File.getAssets() and uniqueName-keyed global assets. |
Review details
Suppressed comments (4)
runtimes/apple/loading-assets.mdx:93
- The switch over
asset.typeusescase .unknown:. If.unknowncarries aUInt16as documented above, this needs to becase .unknown(_):to compile.
switch asset.type {
case .image:
let image = try await worker.decodeImage(from: data)
worker.addGlobalImageAsset(image, name: asset.uniqueName)
case .font:
let font = try await worker.decodeFont(from: data)
worker.addGlobalFontAsset(font, name: asset.uniqueName)
case .audio:
let audio = try await worker.decodeAudio(from: data)
worker.addGlobalAudioAsset(audio, name: asset.uniqueName)
case .unknown:
break
}
runtimes/apple/loading-assets.mdx:113
- Same as earlier:
if case .unknown = asset.typewon’t compile if.unknownhas an associatedUInt16as documented. Use.unknown(_)in the pattern.
for asset in try await file.getAssets() {
if case .unknown = asset.type { continue }
guard let url = Bundle.main.url(
runtimes/apple/loading-assets.mdx:134
- Same as earlier:
case .unknown:should becase .unknown(_):if.unknownhas an associated value (as documented in the metadata table).
switch asset.type {
case .image:
let image = try await worker.decodeImage(from: data)
worker.addGlobalImageAsset(image, name: asset.uniqueName)
case .font:
let font = try await worker.decodeFont(from: data)
worker.addGlobalFontAsset(font, name: asset.uniqueName)
case .audio:
let audio = try await worker.decodeAudio(from: data)
worker.addGlobalAudioAsset(audio, name: asset.uniqueName)
case .unknown:
break
}
runtimes/apple/loading-assets.mdx:172
- The font removal call is missing the external parameter label, unlike the image/audio variants shown above. For consistency (and typical Swift API shape), it should likely be
removeGlobalFontAsset(name:).
worker.removeGlobalImageAsset(name: imageAsset.uniqueName)
worker.removeGlobalFontAsset(fontAsset.uniqueName)
worker.removeGlobalAudioAsset(name: audioAsset.uniqueName)
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Document the replacement for the legacy
customLoader: create a file, inspect its assets, and register global images, fonts, or audio using each asset'suniqueName. Matching assets share the replacement across files on the same worker, even after loading.Updates the Apple migration guide, asset-loading walkthrough and examples, and overview. Includes explicit CDN loading using asset metadata.
Validation:
mint broken-linksandgit diff --check.