Skip to content

Fix iOS patterns: prefer SwiftUI, add xcodegen project setup, fix token approach - #67

Open
mattpodwysocki wants to merge 5 commits into
mainfrom
fix-ios-patterns-swiftui
Open

Fix iOS patterns: prefer SwiftUI, add xcodegen project setup, fix token approach#67
mattpodwysocki wants to merge 5 commits into
mainfrom
fix-ios-patterns-swiftui

Conversation

@mattpodwysocki

@mattpodwysocki mattpodwysocki commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes gaps discovered while building a real demo iOS app with the Mapbox Maps SDK v11. The skill was producing incorrect patterns — particularly recommending bare SPM packages (which can't run as iOS apps) and missing most of the SwiftUI-native annotation API.

  • Project setup: Add xcodegen + project.yml pattern. A bare SPM .target builds as a library — it cannot launch as an iOS app. This was the biggest practical gap.
  • Token: Add Config.swift + MapboxOptions.accessToken approach for SPM/xcodegen projects alongside the existing Info.plist approach (which only works in Xcode-managed projects)
  • SwiftUI first: Explicitly discourage UIViewRepresentable wrappers; Map(viewport:) is the correct SwiftUI entry point
  • Annotations: Add CircleAnnotationGroup, PointAnnotationGroup, .onTapGesture per annotation, and MapViewAnnotation for callouts — all missing from the SwiftUI section
  • Camera animation: Add withViewportAnimation(.fly(duration:)) for SwiftUI (the UIKit mapView.camera.fly(to:) was the only documented pattern)
  • User location: Add Puck2D(bearing: .heading) inside Map {} for SwiftUI
  • StyleColor gotcha: Document that StyleColor(red:green:blue:alpha:) returns optional — use StyleColor(UIColor(...)) instead
  • StyleURI: Clarify rawValue: for mapbox:// URIs vs url: for https:// URLs
  • Minimum iOS: Bump recommendation from iOS 12 to iOS 16 with explanation (NavigationSplitView requires 16, foregroundStyle requires 15)
  • Evals: Update token eval (Add mapbox-geospatial-operations skill #1), add 4 new evals covering project setup, SwiftUI annotation groups, camera animation, and StyleColor optional

Eval fixes (cross-skill, added in latest commit)

Ran a full eval suite across all 18 skills and fixed the worst-scoring gaps:

Skill Before After
mapbox-style-quality 67% 93%
mapbox-search-integration 75% 100%
mapbox-style-patterns 80% 100%
mapbox-ios-patterns 83% 95%

Changes:

  • ios-patterns AGENTS.md: add XcodeGen gitignore guidance (project.yml committed, .xcodeproj gitignored); fix stale .iconImage().image(.init(image:name:))
  • search-integration SKILL.md: add Custom UI section surfacing session token requirement for direct API callers (billing impact)
  • style-patterns references/data-viz-base.md: explain why water must be gray not blue for choropleth maps (blue water competes with red/blue election data)
  • style-quality SKILL.md: expand Large Style File Size troubleshooting to spell out ordered cleanup steps (empty layers, boolean expressions) and reviewing percentReduction/changes in the optimization report

Test plan

  • npm run eval mapbox-ios-patterns — 7/7 pass (95%)
  • npm run eval mapbox-search-integration — 3/3 pass (100%)
  • npm run eval mapbox-style-patterns — 3/3 pass (100%)
  • npm run eval mapbox-style-quality — 3/3 pass (93%)
  • xcodegen generate produces a working .xcodeproj from the documented project.yml
  • SwiftUI annotation patterns compile against MapboxMaps 11.x

🤖 Generated with Claude Code

mattpodwysocki and others added 3 commits April 19, 2026 17:53
…p guidance

- Add xcodegen + project.yml pattern for creating runnable Xcode projects
  (bare SPM .target cannot launch as an iOS app)
- Add Config.swift token approach for SPM projects alongside Info.plist
- Make SwiftUI the primary pattern; explicitly discourage UIViewRepresentable
- Add CircleAnnotationGroup, PointAnnotationGroup, onTapGesture per annotation
- Add MapViewAnnotation for SwiftUI callouts
- Add withViewportAnimation(.fly) for SwiftUI camera transitions
- Add Puck2D(bearing: .heading) for SwiftUI user location
- Add StyleColor(UIColor) gotcha — StyleColor(red:green:blue:alpha:) is optional
- Fix StyleURI: rawValue: for mapbox:// URIs, url: for https:// URLs
- Add Viewport.followPuck for SwiftUI camera tracking
- Bump recommended minimum iOS from 12 to 16 with explanation
- Update evals: fix token eval, add 4 new evals for project setup,
  SwiftUI annotations, camera animation, and StyleColor gotcha

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mattpodwysocki
mattpodwysocki requested a review from a team as a code owner April 19, 2026 21:54
mattpodwysocki and others added 2 commits May 12, 2026 14:23
…yle-quality

- ios-patterns AGENTS.md: add XcodeGen gitignore guidance (commit project.yml,
  gitignore .xcodeproj); fix stale .iconImage() → .image(.init(image:name:))
- search-integration: add Custom UI section surfacing session token requirement
  for direct API callers (billing impact)
- style-patterns data-viz-base: explain why water must be gray not blue for
  choropleth maps (blue water competes with red/blue election data)
- style-quality: expand Large Style File Size troubleshooting to spell out
  ordered cleanup steps (empty layers, boolean expressions) and mention
  reviewing percentReduction/changes in the optimization report

Scores after fixes: search-integration 75%→100%, style-patterns 80%→100%,
style-quality 67%→93%, ios-patterns 83%→95%

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Conflicts in ios-patterns files were between this branch's xcodegen/SwiftUI
annotation patterns and PR #66's Markers API decision matrix. Resolution keeps
both: xcodegen project setup, SwiftUI annotation groups + MapViewAnnotation
callout patterns, AND the Markers API table + ForEvery examples from #66.

evals.json now has 8 evals (added #66's Markers-API-for-GeoJSON eval as #5,
shifted camera/StyleColor evals to #7/#8).

Also picks up: mapbox-flutter-patterns skill, cspell additions (xcworkspace,
TLHC, ARGB, etc.) from #66.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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