ams-capacitor-pro
暂无简介
- License 许可
- MIT
- 最近更新
- 2026-11-07
- Stars
- ★ 0
- Forks
- 1
03 SKILL.md 正文
Capacitor Pro
A practical guide to Capacitor: turning a web app into native iOS and Android apps with full access to native APIs via plugins — setup, the plugin bridge, platform projects, live updates, and store deployment.
Overview
Capacitor wraps your built web app in a native shell with a WebView, plus a plugin bridge to native APIs (camera, filesystem, push notifications, geolocation...). Unlike older "write once" web containers, Capacitor embraces the native projects: ios/ and android/ are real, editable Xcode/Gradle projects checked into your repo. You own the native side.
The flow: web code → npx cap sync → native projects → build in Xcode/Android Studio → stores.
When to use
- An existing web app (React, Vue, Angular, plain JS) needs iOS/Android apps.
- You want native features (push, camera, biometrics) without going fully native.
- Teams that are web-first but need store presence.
- OTA content updates without full store review (within store policy limits).
Core concepts
- The bridge.
Plugins.Camera.getPhoto(...)in JS calls native code. Official plugins cover the essentials; community plugins fill gaps; you can write custom native plugins (Swift/Kotlin) when needed. npx cap sync. Copies your web build output into the native projects and updates plugin native code. Run after every web build and every plugin install.- Native projects are source.
ios/andandroid/are checked in and editable — add native dependencies, entitlements, deep links directly. Capacitor regenerates only what it owns. - Config (
capacitor.config.ts). App ID, app name, web directory (dist), server settings for live reload during development. - Live reload. Point the native app at your dev server (
server.url) for instant iteration on a device — then clear it for production builds. - Push notifications. Via the Push Notifications plugin + FCM (Android) / APNs (iOS). Certificates, entitlements, and token handling are the fiddly parts — budget time.
- Live updates. Services exist to push web-bundle updates over the air. Allowed for web content; native changes still need store review. Stay within Apple/Google policy (no changing app purpose or sneaking features past review).
Practical workflow
1. Add to a web app.
npm i @capacitor/core @capacitor/cli
npx cap init "MyApp" com.example.myapp --web-dir=dist
npm i @capacitor/camera @capacitor/push-notifications # plugins you need
npx cap add ios
npx cap add android
2. Use a plugin.
import { Camera, CameraResultType } from '@capacitor/camera';
const photo = await Camera.getPhoto({
resultType: CameraResultType.Uri,
quality: 90,
});
// photo.webPath -> display; photo.path -> native file access
Always wrap in try/catch — users deny permissions, and simulators lack cameras.
3. Dev loop.
npm run build && npx cap sync
# then run from Xcode / Android Studio on a device
For speed: set server.url to your LAN dev server + cleartext: true for live reload during development.
4. Platform specifics. iOS: set bundle ID, signing team, capabilities (push, associated domains) in Xcode. Android: applicationId, signing config, permissions in AndroidManifest.xml.
5. Build for stores. iOS: Archive in Xcode → App Store Connect. Android: signed AAB (./gradlew bundleRelease). Automate signing in CI with secrets — never commit keystores or provisioning profiles.
6. Maintain. After Capacitor major upgrades, re-run npx cap sync, check plugin compatibility, and re-verify permissions — upgrades are the #1 source of "it worked last release" bugs.
Common pitfalls
- Forgetting
cap sync. Web changes not appearing on device? You built but didn't sync. Make it part of the build script. - Permissions as an afterthought. Camera/location/notifications need
Info.plistentries (iOS, with usage descriptions) and manifest entries + runtime requests (Android). Missing usage descriptions = instant App Store rejection. - Simulator-only testing. Push notifications, cameras, and performance behave differently on real devices. Test on hardware before submission.
- WebView quirks. iOS WKWebView and Android WebView differ: scrolling behavior, input focus, file access. Test both; use
viewport-fit=coverand safe-area insets for notched devices. - Storing secrets in the web bundle. The JS bundle is readable. API keys in web code are public — use a backend or native secure storage (Keychain/Keystore via plugins).
- OTA overreach. Pushing native-code-equivalent changes or altering app purpose via live update violates store policy. Web content and bug fixes only.
- Plugin rot. Community plugins lag behind Capacitor majors. Prefer official plugins; vet community ones for maintenance activity before depending on them.
- Ignoring app lifecycle.
appStateChange/pause/resumeevents — persist state, refresh stale data on resume, handle deep links (appUrlOpen) for auth callbacks.
04 同仓库更多 Skills
web-scrape
Turn web pages into LLM-ready markdown via the Firecrawl API (renders JS, anti-bot handling). Use when browser_open/fetch fails on JS-heavy pages, or when you need clean markdown/structured extraction from a site. Requires FIRECRAWL_API_KEY.
design-taste-frontend
tasteskill v2, the anti-slop frontend skill. Art direction for websites, distilled from a study of 247 curated gallery sites (One Page Love, Awwwards Sites of the Day). Deals researched directions (idea, composition, type, palette, photographs, section blueprints) from a library, enforces a strict no-slop house style with a real-browser inspector, and runs a look-and-fix loop on screenshots. Use this whenever you build, design, redesign, restyle, polish or review a landing page, marketing site, portfolio, product page, one-pager, hero or any public-facing web page, in any stack (HTML/CSS, React, Next.js, Vue, Svelte, Astro, Tailwind) — also when the user says a page looks generic, templated, "AI-made", sloppy, or asks to make it look designed, premium, award-level or less like every other site. Not for dashboards or app screens.
test-driven-development
Use when implementing any feature or bugfix, before writing implementation code
systematic-debugging
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
requesting-code-review
Use when completing tasks, implementing major features, or before merging to verify work meets requirements
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).