复制安装命令
用 Codex 或 Claude 安装复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它先审查 Skill 页面再帮你安装。
复制前请先查看来源、License 和安全提示。
86 agent skills optimized for iOS 26+ development with Swift 6.
用 Codex 或 Claude 安装复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它先审查 Skill 页面再帮你安装。
复制前请先查看来源、License 和安全提示。
来源文件:README.md
86 agent skills optimized for iOS 26+ development with Swift 6.3 and modern Apple frameworks. All code examples, patterns, and guidance target the latest APIs -- Liquid Glass, approachable concurrency, Foundation Models, StoreKit 2, SwiftData, async/await URLSession, and more. No deprecated patterns.
Compatible with Claude Code, OpenAI Codex, Cursor, GitHub Copilot, and 40+ other agents. Follows the open Agent Skills standard.
Every skill is self-contained. No skill depends on another. Install only what you need.
Release history: CHANGELOG.md.
The skills CLI is the recommended install method.
Interactive install (recommended):
npx skills add dpearson2699/swift-ios-skills
Running the default command opens the skills CLI UI so you can choose which skills to install and which agent(s) to install them for.
Install everything for any coding agent:
npx skills add dpearson2699/swift-ios-skills --all
Use --all when you want the full set of 86 skills installed automatically for any coding agent.
Install specific skills directly:
npx skills add dpearson2699/swift-ios-skills --skill <skill-name> --skill <skill-name>
Check for updates to installed skills:
npx skills check
Update installed skills to the latest versions:
npx skills update
Use these after installing through the skills CLI.
Add the marketplace (one-time):
/plugin marketplace add dpearson2699/swift-ios-skills
Install everything:
/plugin install all-ios-skills@swift-ios-skills
Or install a themed bundle (bundles limit how many skills load into the context window — if you want everything, use all-ios-skills above instead of installing multiple bundles):
/plugin install swiftui-skills@swift-ios-skills
/plugin install swift-core-skills@swift-ios-skills
/plugin install ios-app-framework-skills@swift-ios-skills
/plugin install ios-data-framework-skills@swift-ios-skills
/plugin install ios-ai-ml-skills@swift-ios-skills
/plugin install ios-engineering-skills@swift-ios-skills
/plugin install ios-hardware-skills@swift-ios-skills
/plugin install ios-platform-skills@swift-ios-skills
/plugin install ios-gaming-skills@swift-ios-skills
/plugin install apple-kit-skills@swift-ios-skills
$skill-installer install https://github.com/dpearson2699/swift-ios-skills/tree/main/skills/<skill-name>
| Plugin | Skills included |
|---|---|
| all-ios-skills | All 86 skills |
| apple-kit-skills | 39 skills spanning Apple Kit frameworks plus CarPlay |
| swiftui-skills | focus-engine, swiftui-animation, swiftui-gestures, swiftui-layout-components, swiftui-liquid-glass, swiftui-navigation, swiftui-patterns, swiftui-performance, swiftui-uikit-interop, swiftui-webkit |
| swift-core-skills | core-data, swift-api-design-guidelines, swift-architecture, swift-codable, swift-charts, swift-concurrency, swift-formatstyle, swift-language, swift-testing, swiftdata |
| ios-app-framework-skills | activitykit, adattributionkit, alarmkit, app-clips, app-intents, avkit, carplay, mapkit, paperkit, pdfkit, photokit, push-notifications, storekit, tipkit, widgetkit |
| ios-data-framework-skills | cloudkit, contacts-framework, eventkit, financekit, healthkit, musickit, passkit, weatherkit |
| ios-ai-ml-skills | apple-on-device-ai, coreml, natural-language, speech-recognition, vision-framework |
| ios-engineering-skills | app-store-optimization, app-store-review, authentication, background-processing, cryptokit, debugging-instruments, device-integrity, ios-accessibility, ios-ettrace-performance, ios-localization, ios-memgraph-analysis, ios-networking, swift-security, swiftlint, ios-simulator, metrickit |
| ios-hardware-skills | accessorysetupkit, core-bluetooth, core-motion, core-nfc, dockkit, pencilkit, realitykit, sensorkit |
| ios-platform-skills | appmigrationkit, audioaccessorykit, browserenginekit, callkit, cryptotokenkit, energykit, homekit, permissionkit, relevancekit, shareplay-activities |
| ios-gaming-skills | gamekit, scenekit, spritekit, tabletopkit |
| Skill | What it covers |
|---|---|
| focus-engine | @FocusState, defaultFocus, focusSection, focused scene values, focus restoration, UIFocusGuide |
| swiftui-animation | Spring animations, PhaseAnimator, KeyframeAnimator, matchedGeometryEffect, SF Symbols |
| swiftui-gestures | Tap, drag, magnify, rotate, long press, simultaneous and sequential gestures |
| swiftui-layout-components | Grid, LazyVGrid, Layout protocol, ViewThatFits, custom layouts |
| swiftui-liquid-glass | iOS 26 Liquid Glass, glassEffect, GlassEffectContainer, morphing transitions |
| swiftui-navigation | NavigationStack, NavigationSplitView, programmatic navigation, deep linking |
| swiftui-patterns | @Observable, state ownership, environment wiring, view composition, async loading, MV-pattern architecture |
| swiftui-performance | Rendering performance, view update optimization, layout thrash, Instruments profiling |
| swiftui-uikit-interop | UIViewRepresentable, UIHostingController, Coordinator, incremental UIKit-to-SwiftUI migration |
| swiftui-webkit | WebView, WebPage, navigation policies, JavaScript calls, local content, custom URL schemes |
| Skill | What it covers |
|---|---|
| swift-api-design-guidelines | Swift API Design Guidelines -- argument labels, mutating/nonmutating pairs, documentation comments, naming conventions |
| swift-architecture | Architecture patterns: MV (@Observable), MVVM, MVI, TCA, Clean Architecture, Coordinator, decision framework |
| swift-codable | Swift Codable, JSONDecoder, JSONEncoder, CodingKeys, custom decoding, nested JSON |
| swift-charts | Bar, line, area, pie, donut, and 3D charts, scrolling, selection, annotations |
| swift-concurrency | Swift 6.2 concurrency, Sendable, actors, structured concurrency, data-race safety |
| swift-formatstyle | FormatStyle protocol, number/currency/date/duration/measurement formatting, custom styles |
| swift-language | Swift 6.3 language idioms, result builders, property wrappers, typed throws |
| swift-testing | Swift Testing framework, @Test, @Suite, #expect, parameterized tests, mocking |
| core-data | Core Data persistence, NSPersistentContainer, NSFetchedResultsController, batch operations, staged migration |
| swiftdata | @Model, @Query, #Predicate, ModelContainer, migrations, CloudKit sync, @ModelActor |
| Skill | What it covers |
|---|---|
| activitykit | ActivityKit, Dynamic Island, Lock Screen Live Activities, push-to-update |
| adattributionkit | Privacy-preserving ad attribution, postbacks, conversion values, re-engagement |
| alarmkit | AlarmKit system alarms and countdown timers, Lock Screen, Dynamic Island, Live Activities |
| app-clips | App Clips, invocation URLs, NFC, QR, App Clip Codes, App Group handoff |
| app-intents | App Intents for Siri, Shortcuts, Spotlight, widgets, and Apple Intelligence |
| avkit | AVPlayerViewController, VideoPlayer, Picture-in-Picture, AirPlay, subtitles |
| carplay | CarPlay templates, navigation, audio, communication, EV charging apps |
| mapkit | MapKit, CoreLocation, annotations, geocoding, directions, geofencing |
| paperkit | PaperMarkupViewController, markup editing, drawing, shapes (iOS 26) |
| pdfkit | PDFView, PDFDocument, annotations, text search, form filling, thumbnails |
| photokit | PhotosPicker, AVCaptureSession, photo library, video recording, media permissions |
| push-notifications | UNUserNotificationCenter, APNs, rich notifications, silent push, service extensions |
| storekit | StoreKit 2 purchases, subscriptions, SubscriptionStoreView, transaction verification |
| tipkit | Feature discovery tooltips, contextual tips, tip rules, tip events |
| widgetkit | Home Screen, Lock Screen, and StandBy widgets, Control Center controls, timeline providers |
| Skill | What it covers |
|---|---|
| cloudkit | CKContainer, CKRecord, subscriptions, sharing, CKSyncEngine, SwiftData sync |
| contacts-framework | CNContactStore, fetch requests, key descriptors, CNContactPickerViewController, save requests |
| eventkit | EKEventStore, EKEvent, EKReminder, recurrence rules, EventKitUI editors and choosers |
| financekit | Apple Card, Apple Cash, Wallet orders, transaction queries, account balances |
| healthkit | HKHealthStore, queries, statistics, workout sessions, background delivery |
| musickit | MusicKit authorization, catalog search, ApplicationMusicPlayer, MPRemoteCommandCenter |
| passkit | Apple Pay, PKPaymentRequest, PKPaymentAuthorizationController, Wallet passes |
| weatherkit | WeatherService, current/hourly/daily forecasts, alerts, attribution requirements |
| Skill | What it covers |
|---|---|
| apple-on-device-ai | Foundation Models framework, Core ML, MLX Swift, on-device LLM inference |
| coreml | Core ML model loading, prediction, MLTensor, compute unit configuration, VNCoreMLRequest, MLComputePlan |
| natural-language | NLTokenizer, NLTagger, sentiment analysis, language identification, embeddings, Translation |
| speech-recognition | SpeechAnalyzer, SpeechTranscriber, SFSpeechRecognizer, on-device recognition, audio buffer processing |
| vision-framework | Vision text recognition, face/barcode detection, image segmentation, VisionKit DataScannerViewController |
| Skill | What it covers |
|---|---|
| app-store-optimization | ASO keyword strategy, description writing, screenshot optimization, Custom Product Pages, A/B testing |
| app-store-review | App Review guidelines, rejection prevention, privacy manifests, ATT, HIG compliance |
| authentication | Sign in with Apple, ASAuthorizationController, passkeys, biometric auth (LAContext), credential management |
| background-processing | BGTaskScheduler, background refresh, URLSession background transfers |
| cryptokit | SHA-2/SHA-3, HMAC, AES-GCM, ChaChaPoly, HPKE, ML-KEM/ML-DSA, P256/Curve25519 signing, ECDH, Secure Enclave |
| debugging-instruments | Xcode debugger, Instruments, os_signpost, MetricKit, crash symbolication |
| device-integrity | DeviceCheck (DCDevice per-device bits), App Attest (DCAppAttestService attestation and assertion flows) |
| ios-accessibility | VoiceOver, Dynamic Type, custom rotors, accessibility focus, assistive-technology support |
| ios-ettrace-performance | ETTrace launch/runtime capture, exact-build dSYM matching, processed flamegraph JSON, comparable verification |
| ios-localization | String Catalogs, pluralization, FormatStyle, right-to-left layout |
| ios-memgraph-analysis | Simulator memgraph capture, leak ownership paths, reachable heap growth, raw evidence preservation |
| ios-networking | URLSession async/await, REST APIs, downloads/uploads, WebSockets, pagination, retry, caching |
| swift-security | Keychain Services, CryptoKit symmetric/asymmetric, biometric authentication, Secure Enclave, certificate trust, credential storage, OWASP compliance · Based on ivan-magda/swift-security-skill |
| ios-simulator | xcrun simctl commands, device lifecycle, push/location/privacy simulation, log streaming, simulator limitations |
| metrickit | MetricManager async reports, hang/crash diagnostics, production performance telemetry |
| swiftlint | SwiftLint setup, .swiftlint.yml, build tool plugin, rule selection, baselines, suppressions, CI integration |
| Skill | What it covers |
|---|---|
| accessorysetupkit | Privacy-preserving BLE/Wi-Fi accessory discovery, ASAccessorySession, picker UI |
| core-bluetooth | CBCentralManager, CBPeripheral, BLE scanning/connecting, services, characteristics, background modes |
| core-motion | CMMotionManager, CMPedometer, accelerometer, gyroscope, activity recognition, altitude |
| core-nfc | NFCNDEFReaderSession, NFCTagReaderSession, NDEF reading/writing, background tag reading |
| dockkit | DockAccessoryManager, camera subject tracking, motor control, framing |
| pencilkit | PKCanvasView, PKDrawing, PKToolPicker, Apple Pencil drawing and annotation |
| realitykit | RealityView, entities, anchors, ARKit world tracking, raycasting, scene understanding |
| sensorkit | Research-grade sensor data, ambient light, keyboard metrics, device usage (approved studies) |
| Skill | What it covers |
|---|---|
| appmigrationkit | Cross-platform data transfer, AppMigrationExtension export/import (iOS 26) |
| audioaccessorykit | Audio accessory features, automatic switching, device placement (iOS 26.4) |
| browserenginekit | Alternative browser engines (EU), process management, web content extensions |
| callkit | CXProvider, CXCallController, PushKit VoIP registration, call directory extensions |
| cryptotokenkit | TKTokenDriver, TKSmartCard, iOS 26 NFC smart cards, certificate-based auth |
| energykit | ElectricityGuidance, EnergyVenue, grid forecasts, load event submission, electricity insights |
| homekit | HMHomeManager, accessories, rooms, actions, triggers, MatterSupport commissioning |
| permissionkit | AskCenter, PermissionQuestion, child communication safety, CommunicationLimits |
| relevancekit | Widget relevance signals, time/location-based relevance providers (watchOS 26) |
| shareplay-activities | GroupActivity, GroupSession, GroupSessionMessenger, coordinated media playback |
| Skill | What it covers |
|---|---|
| gamekit | Game Center, GKLocalPlayer, leaderboards, achievements, real-time and turn-based multiplayer |
| scenekit | SCNView, SCNScene, 3D geometry, materials, lighting, physics, SceneView |
| spritekit | SKScene, SKSpriteNode, SKAction, physics simulation, particle effects, SpriteView |
| tabletopkit | Multiplayer spatial board games, pieces, cards, dice, Group Activities (visionOS) |
Each skill follows the open Agent Skills standard:
skills/
skill-name/
SKILL.md # Required — instructions and metadata
references/ # Optional — detailed reference material
some-topic.md
SKILL.md contains YAML frontmatter (name, description) and markdown instructions. The references/ folder holds longer examples, advanced patterns, and lookup tables that the main file points to.
This repository contains original instructional content and examples for Apple platform development. Where Apple frameworks, APIs, documentation, WWDC sessions, or trademarks are referenced, those materials remain the property of Apple Inc. The license for this repository applies to this project's original content only and does not claim ownership of or relicense Apple's documentation, trademarks, sample code, or other third-party materials.
These skills work with any agent that supports the Agent Skills standard, including:
v3.0 is a major release. If you previously installed v2.x skills, note the following changes:
Skill count: 57 skills in v2.2.0, 76 skills in v3.0.0.
Skill renames: 12 existing skills renamed to use Apple Kit framework names. Old skill paths no longer resolve. Uninstall all skills and reinstall to upgrade.
| v2.x name | v3.0 name |
|---|---|
live-activities | activitykit |
mapkit-location | mapkit |
photos-camera-media | photokit |
homekit-matter | homekit |
callkit-voip | callkit |
metrickit-diagnostics | metrickit |
pencilkit-drawing | pencilkit |
passkit-wallet | passkit |
musickit-audio | musickit |
cloudkit-sync | cloudkit |
eventkit-calendar | eventkit |
realitykit-ar | realitykit |
19 new Kit framework skills: avkit, gamekit, cryptokit, pdfkit, paperkit, spritekit, scenekit, financekit, accessorysetupkit, adattributionkit, carplay, appmigrationkit, browserenginekit, dockkit, sensorkit, tabletopkit, relevancekit, audioaccessorykit, cryptotokenkit.
New bundles: apple-kit-skills (all 39 Apple Kit framework skills) and ios-gaming-skills (GameKit, SpriteKit, SceneKit, TabletopKit).
PaperKit standalone: PaperKit content removed from pencilkit and is now its own paperkit skill.
Beta frameworks: permissionkit, energykit, paperkit, relevancekit, appmigrationkit, and audioaccessorykit require iOS/watchOS 26 beta and are subject to API changes before GM.
All skills remain self-contained: No skill references or depends on another.
To upgrade via the skills CLI:
npx skills add dpearson2699/swift-ios-skills
To upgrade Claude Code bundles, reinstall the bundles you use (old skill paths will no longer resolve).
If these skills save you time or improve your workflow, you can support ongoing maintenance through GitHub Sponsors.
Support helps keep the collection current with new Apple releases, evolving framework APIs, updated examples, and compatibility work across Claude Code, Codex, Cursor, Copilot, and other agents.
Thanks to the following people for supporting this project:
PolyForm Perimeter 1.0.0 -- see LICENSE
What this means in practice:
This project is not affiliated with, endorsed by, or sponsored by Apple Inc.
name: swift-charts
description: "Implement, review, or improve data visualizations using Swift Charts. Use when building bar, line, area, point, pie, donut, or iOS 26 3D charts; when adding chart selection, scrolling, annotations, axes, scales, legends, or foregroundStyle grouping; when plotting functions with BarPlot, LinePlot, AreaPlot, PointPlot, Chart3D, or SurfacePlot; or when creating heat maps, Gantt charts, grouped bars, sparklines, threshold lines, or spatial visualizations."Build data visualizations with Swift Charts targeting iOS 26+. Compose marks
inside Chart or Chart3D, configure axes and scales with view modifiers, and
use vectorized plots or 3D plots when the data calls for them.
See references/charts-patterns.md for extended patterns, 3D charts, accessibility, and theming guidance.
Identifiable struct or use id: key path.BarMark, LineMark, PointMark, AreaMark,
RuleMark, RectangleMark, SectorMark, or SurfacePlot.Chart; use Chart3D only for real spatial or surface data..foregroundStyle(by:), .symbol(by:), .lineStyle(by:)..chartXAxis / .chartYAxis..chartXScale(domain:) / .chartYScale(domain:).BarPlot, LinePlot, etc.).Identify the data semantics before judging mark choice. Then trace every value through mark, scale, axis, style, selection, and accessibility output; run the same validation matrix used for new charts.
Chart(sales) { item in
BarMark(x: .value("Month", item.month), y: .value("Revenue", item.revenue))
}
Use the data-driven initializer for a single collection. Use the content closure for mixed marks or multiple series, and pass id: when elements are not Identifiable. Load references/charts-patterns.md for complete mixed-series, theming, accessibility, and 3D recipes.
// Vertical bar
BarMark(x: .value("Month", item.month), y: .value("Sales", item.sales))
// Stacked by category (automatic when same x maps to multiple bars)
BarMark(x: .value("Month", item.month), y: .value("Sales", item.sales))
.foregroundStyle(by: .value("Product", item.product))
// Horizontal bar
BarMark(x: .value("Sales", item.sales), y: .value("Month", item.month))
// Interval bar (Gantt chart)
BarMark(
xStart: .value("Start", item.start),
xEnd: .value("End", item.end),
y: .value("Task", item.task)
)
// Single line
LineMark(x: .value("Date", item.date), y: .value("Price", item.price))
// Multi-series via foregroundStyle encoding
LineMark(x: .value("Date", item.date), y: .value("Temp", item.temp))
.foregroundStyle(by: .value("City", item.city))
.interpolationMethod(.catmullRom)
// Multi-series with explicit series parameter
LineMark(
x: .value("Date", item.date),
y: .value("Price", item.price),
series: .value("Ticker", item.ticker)
)
PointMark(x: .value("Height", item.height), y: .value("Weight", item.weight))
.foregroundStyle(by: .value("Species", item.species))
.symbol(by: .value("Species", item.species))
.symbolSize(100)
// Stacked area
AreaMark(x: .value("Date", item.date), y: .value("Sales", item.sales))
.foregroundStyle(by: .value("Category", item.category))
// Range band
AreaMark(
x: .value("Date", item.date),
yStart: .value("Min", item.min),
yEnd: .value("Max", item.max)
)
.opacity(0.3)
RuleMark(y: .value("Target", 9000))
.foregroundStyle(.red)
.lineStyle(StrokeStyle(dash: [5, 3]))
.annotation(position: .top, alignment: .leading) {
Text("Target").font(.caption).foregroundStyle(.red)
}
RectangleMark(x: .value("Hour", item.hour), y: .value("Day", item.day))
.foregroundStyle(by: .value("Intensity", item.intensity))
Use SectorMark for strictly positive values; filter, aggregate, or explain zero/negative values outside the pie or donut.
// Pie chart
Chart(data, id: \.name) { item in
SectorMark(angle: .value("Sales", item.sales))
.foregroundStyle(by: .value("Category", item.name))
}
// Donut chart
Chart(data, id: \.name) { item in
SectorMark(
angle: .value("Sales", item.sales),
innerRadius: .ratio(0.618),
outerRadius: .inset(10),
angularInset: 1
)
.cornerRadius(4)
.foregroundStyle(by: .value("Category", item.name))
}
// Hide axes
.chartXAxis(.hidden)
.chartYAxis(.hidden)
// Custom axis content
.chartXAxis {
AxisMarks(values: .stride(by: .month)) { value in
AxisGridLine()
AxisTick()
AxisValueLabel(format: .dateTime.month(.abbreviated))
}
}
// Multiple AxisMarks compositions (different intervals for grid vs. labels)
.chartXAxis {
AxisMarks(values: .stride(by: .day)) { _ in AxisGridLine() }
AxisMarks(values: .stride(by: .week)) { _ in
AxisTick()
AxisValueLabel(format: .dateTime.week())
}
}
// Axis labels (titles)
.chartXAxisLabel("Time", position: .bottom, alignment: .center)
.chartYAxisLabel("Revenue ($)", position: .leading, alignment: .center)
.chartYScale(domain: 0...100) // Explicit numeric domain
.chartYScale(domain: .automatic(includesZero: true)) // Include zero
.chartYScale(domain: 1...10000, type: .log) // Logarithmic scale
.chartXScale(domain: ["Mon", "Tue", "Wed", "Thu"]) // Categorical ordering
BarMark(...).foregroundStyle(.blue) // Static color
BarMark(...).foregroundStyle(by: .value("Category", item.category)) // Data encoding
AreaMark(...).foregroundStyle( // Gradient
.linearGradient(colors: [.blue, .cyan], startPoint: .bottom, endPoint: .top)
)
@State private var selectedDate: Date?
@State private var selectedRange: ClosedRange<Date>?
@State private var selectedAngle: Double?
// Point selection
Chart(data) { item in
LineMark(x: .value("Date", item.date), y: .value("Value", item.value))
}
.chartXSelection(value: $selectedDate)
// Range selection
.chartXSelection(range: $selectedRange)
// Angular selection binds the plottable angle value; derive the category from ranges.
.chartAngleSelection(value: $selectedAngle)
Chart(dailyData) { item in
BarMark(x: .value("Date", item.date, unit: .day), y: .value("Steps", item.steps))
}
.chartScrollableAxes(.horizontal)
.chartXVisibleDomain(length: 3600 * 24 * 7) // 7 days visible
.chartScrollPosition(initialX: latestDate)
.chartScrollTargetBehavior(
.valueAligned(matching: DateComponents(hour: 0), majorAlignment: .page)
)
BarMark(x: .value("Month", item.month), y: .value("Sales", item.sales))
.annotation(position: .top, alignment: .center, spacing: 4) {
Text("\(item.sales, format: .number)").font(.caption2)
}
// Overflow resolution
.annotation(
position: .top,
overflowResolution: .init(x: .fit(to: .chart), y: .padScale)
) { Text("Label") }
.chartLegend(.hidden) // Hide
.chartLegend(position: .bottom, alignment: .center, spacing: 10) // Position
.chartLegend(position: .bottom) { // Custom
HStack {
ForEach(categories, id: \.self) { cat in
Label(cat, systemImage: "circle.fill").font(.caption)
}
}
}
Use for large datasets (1000+ points). Accept entire collections or functions.
// Data-driven
Chart {
BarPlot(sales, x: .value("Month", \.month), y: .value("Revenue", \.revenue))
.foregroundStyle(\.barColor)
}
// Function plotting: y = f(x)
Chart {
LinePlot(x: "x", y: "y", domain: -5...5) { x in sin(x) }
}
// Parametric: (x, y) = f(t)
Chart {
LinePlot(x: "x", y: "y", t: "t", domain: 0...(2 * .pi)) { t in
(x: cos(t), y: sin(t))
}
}
Apply KeyPath-based modifiers before simple-value modifiers:
BarPlot(data, x: .value("X", \.x), y: .value("Y", \.y))
.foregroundStyle(\.color) // KeyPath first
.opacity(0.8) // Value modifier second
Use Chart3D for spatial data or bivariate surfaces, not as a decorative
replacement for ordinary 2D categorical or time-series charts. Chart3D
accepts SurfacePlot plus 3D initializers of PointMark, RuleMark, and
RectangleMark.
@State private var pose: Chart3DPose = .default
Chart3D {
SurfacePlot(x: "x", y: "y", z: "z") { x, z in
sin(2 * x) * cos(2 * z)
}
.foregroundStyle(.heightBased)
}
.chartXScale(domain: -2...2)
.chartYScale(domain: -1...1)
.chartZScale(domain: -2...2)
.chart3DPose($pose)
// WRONG -- all points connect into one line
Chart {
ForEach(allCities) { item in
LineMark(x: .value("Date", item.date), y: .value("Temp", item.temp))
}
}
// CORRECT -- separate lines per city
Chart {
ForEach(allCities) { item in
LineMark(x: .value("Date", item.date), y: .value("Temp", item.temp))
.foregroundStyle(by: .value("City", item.city))
}
}
// WRONG -- 20 tiny sectors are unreadable
Chart(twentyCategories, id: \.name) { item in
SectorMark(angle: .value("Value", item.value))
}
// CORRECT -- group into top 5 + "Other"
Chart(groupedData, id: \.name) { item in
SectorMark(angle: .value("Value", item.value))
.foregroundStyle(by: .value("Category", item.name))
}
// WRONG -- axis starts at ~95; small changes look dramatic
Chart(data) {
LineMark(x: .value("Day", $0.day), y: .value("Score", $0.score))
}
// CORRECT -- explicit domain for honest representation
Chart(data) {
LineMark(x: .value("Day", $0.day), y: .value("Score", $0.score))
}
.chartYScale(domain: 0...100)
// WRONG -- static color overrides by-value encoding
BarMark(x: .value("X", item.x), y: .value("Y", item.y))
.foregroundStyle(by: .value("Category", item.category))
.foregroundStyle(.blue)
// CORRECT -- use only the data encoding
BarMark(x: .value("X", item.x), y: .value("Y", item.y))
.foregroundStyle(by: .value("Category", item.category))
// WRONG -- creates 10,000 mark views; slow
Chart(largeDataset) { item in
PointMark(x: .value("X", item.x), y: .value("Y", item.y))
}
// CORRECT -- vectorized plot (iOS 18+)
Chart {
PointPlot(largeDataset, x: .value("X", \.x), y: .value("Y", \.y))
}
// WRONG -- clips axis labels at large text sizes
Chart(data) { ... }
.frame(height: 200)
// CORRECT -- adaptive sizing
Chart(data) { ... }
.frame(minHeight: 200, maxHeight: 400)
// WRONG -- compiler error
BarPlot(data, x: .value("X", \.x), y: .value("Y", \.y))
.opacity(0.8)
.foregroundStyle(\.color)
// CORRECT -- KeyPath modifiers first
BarPlot(data, x: .value("X", \.x), y: .value("Y", \.y))
.foregroundStyle(\.color)
.opacity(0.8)
// WRONG -- VoiceOver users get no context
Chart(data) {
BarMark(x: .value("Month", $0.month), y: .value("Sales", $0.sales))
}
// CORRECT -- add per-mark accessibility
Chart(data) { item in
BarMark(x: .value("Month", item.month), y: .value("Sales", item.sales))
.accessibilityLabel("\(item.month)")
.accessibilityValue("\(item.sales) units sold")
}
chartAngleSelection(value:) binds the selected plottable angle value. For
pie and donut charts, map that numeric value through cumulative sector ranges
before comparing it to a category label.
Identifiable or chart uses id: key pathseries: parameter or .foregroundStyle(by:)Date? for date axis).chartXVisibleDomain(length:) for viewportChart3D used only for real 3D data or surfaces, with z scale and pose reviewed
评论 (0)
暂无评论,成为第一个评论者吧!