Λογότυπο Swiftui Best Practices

Swiftui Best Practices

Οργανισμός
coinbase
swiftui-best-practices

ΧΡΗΣΙΜΟΠΟΙΗΣΤΕ ΤΗ όταν μεταφέρετε ένα component του CDS React Native σε εγγενές iOS ή όταν γράφετε ή ελέγχετε SwiftUI στα packages/cds-ios ή apps/ios-gallery. Καλύπτει μοτίβα επανεγγραφής (Style έναντι SwiftUI API έναντι CDS view), προδιαγραφές εμφάνισης RN (όχι απομιμήσεις του HIG), επιβολή στοιχείων ελέγχου με εμφάνιση HIG, tokens, gallery και δοκιμές.

Add to TypingMind

Επισκόπηση

Εκδότηςcoinbase
Αποθετήριοcds
Όνομα δεξιότηταςswiftui-best-practices
Αστέρια
506
Διακλαδώσεις
114
Συνοδευτικά αρχεία
Μόνο οδηγίες
Σύνδεσμοι
  • Οδηγίες σε Markdown

    Ένα αρχείο SKILL.md που το μοντέλο φορτώνει όταν χρειάζεται, ώστε να καταναλώνει token μόνο όταν ένα αίτημα είναι πράγματι σχετικό.

  • Λειτουργεί με οποιοδήποτε LLM

    Οι δεξιότητες AI είναι απλό Markdown, όχι κώδικας για συγκεκριμένο πάροχο, επομένως αυτή η δεξιότητα λειτουργεί με GPT, Claude, Gemini, Grok ή ένα τοπικό μοντέλο.

  • Αυτοτελής

    Όλα όσα χρειάζεται το μοντέλο περιλαμβάνονται στις οδηγίες — χωρίς επιπλέον αρχεία για συγχρονισμό.

  • Ανοιχτού κώδικα

    Δημοσιεύτηκε στο GitHub από τον λογαριασμό coinbase. Ελέγξτε τα αρχεία της δεξιότητας στο αποθετήριο πριν την εγκαταστήσετε.

Εγκατάσταση

Εγκαταστήστε τη δεξιότητα AI Swiftui Best Practices στο TypingMind για να τη χρησιμοποιείτε με οποιοδήποτε LLM ή προσθέστε τη σε άλλον πράκτορα AI που διαβάζει αρχεία SKILL.md.

1

Εγκατάσταση στο TypingMind

Το TypingMind εγκαθιστά μια δεξιότητα απευθείας από τον φάκελό της στο GitHub — διαβάζει το SKILL.md, συγκεντρώνει τα συνοδευτικά αρχεία σε πακέτο και αποθηκεύει το αποτέλεσμα τοπικά.

  1. Ανοίξτε την εφαρμογή και μεταβείτε στα Πρόσθετα → Δεξιότητες.
  2. Επιλέξτε «Εγκατάσταση από GitHub».
  3. Επικολλήστε το παρακάτω URL του φακέλου της δεξιότητας και επιβεβαιώστε.
    https://github.com/coinbase/cds/tree/master/.claude/skills/swiftui-best-practices
  4. Ενεργοποιήστε τη δεξιότητα σε κάθε συνομιλία όπου θέλετε να είναι διαθέσιμη.
Πρόσθετα → Δεξιότητες → Προσθήκη δεξιότητας → Από URL του GitHub, έπειτα επικολλήστε το URL του φακέλου και πατήστε «Συνέχεια».
2

Εγκατάσταση σε άλλον πράκτορα AI

Κάθε πράκτορας AI που υποστηρίζει τη μορφή Agent Skills μπορεί να χρησιμοποιήσει αυτή τη δεξιότητα — αντιγράψτε τον φάκελο στον κατάλογο δεξιοτήτων του.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/coinbase/cds.git /tmp/cds
mkdir -p .claude/skills
cp -r /tmp/cds/.claude/skills/swiftui-best-practices .claude/skills/swiftui-best-practices
Επανεκκινήστε το Claude Code μετά την αντιγραφή, ώστε να εντοπίσει τη νέα δεξιότητα.

Χρησιμοποιήστε τη στο TypingMind

Ενεργοποιήστε τη δεξιότητα Swiftui Best Practices σε οποιαδήποτε συνομιλία στο TypingMind και το μοντέλο αναλαμβάνει τα υπόλοιπα. Το όνομα και η περιγραφή της περιλαμβάνονται στην προτροπή συστήματος και, μόλις προκύψει ένα σχετικό αίτημα, το μοντέλο φορτώνει μόνο του τις πλήρεις οδηγίες — δεν χρειάζεται ποτέ να την καλείτε χειροκίνητα και δεν καταναλώνει token μέχρι να χρησιμοποιηθεί πραγματικά.

Το μοντέλο φορτώνει αυτόματα τη δεξιότητα Swiftui Best Practices μόλις λάβει ένα σχετικό αίτημα.

Λειτουργεί με οποιοδήποτε μοντέλο AI

Οι δεξιότητες AI είναι οδηγίες σε απλό κείμενο Markdown και όχι κώδικας για συγκεκριμένο πάροχο, οπότε η δεξιότητα Swiftui Best Practices δεν περιορίζεται στο μοντέλο για το οποίο γράφτηκε. Εγκαταστήστε τη μία φορά στο TypingMind και χρησιμοποιήστε τη με GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ή ένα τοπικό μοντέλο που εκτελείτε εσείς — πάντα με τα δικά σας κλειδιά API.

  • Φόρτωση μόνο όταν χρειάζεται

    Η προτροπή συστήματος περιλαμβάνει μόνο το όνομα και την περιγραφή. Οι οδηγίες ανακτώνται με το πρώτο σχετικό αίτημα, οπότε μια δεξιότητα που δεν χρησιμοποιείται δεν έχει κόστος.

  • Αλλάξτε μοντέλο κατά τη διάρκεια της συνομιλίας

    Επειδή η δεξιότητα αποτελείται από οδηγίες και όχι από κώδικα, η αλλαγή μοντέλου δεν επηρεάζει τη λειτουργία της — το επόμενο μοντέλο διαβάζει το ίδιο αρχείο SKILL.md.

Οδηγίες δεξιότητας

Αυτό είναι το περιεχόμενο του αρχείου SKILL.md που φορτώνει το μοντέλο. Διαβάστε το πριν από την εγκατάσταση — μια δεξιότητα αποτελείται από οδηγίες που θα ακολουθήσει το μοντέλο σας.

CDS iOS — migrate RN → SwiftUI

Read packages/cds-ios/AGENTS.md before writing any Swift. That file is the API-boundary source of truth (public theme only; components stay internal until they stabilize). This skill is the migration workflow: take one RN component and produce the iOS equivalent without wrapping HIG controls in a CDS view.

CDS SwiftUI Best Practices is the working reference (parallel to CDS Compose Best Practices). Read it before porting a component, and add new port learnings there, not here. It includes the full RN component → iOS map. If Linear is unavailable, rely on this file.

Also read:

Do not copy RN JSX into SwiftUI. Do not share widget code with Android. Do not make components public to make the gallery compile. Do not leak Lottie / third-party types into the CDS public (or even internal-customer-facing) API.

Visual spec is RN, not HIG. Match the React Native component’s layout, states, and chrome as closely as iOS allows (tokens, Figma, RN source). HIG wins only for OS chrome that is not a CDS component (nav bar, keyboard, status bar) or where iOS physically cannot match (Dynamic Type reflow, safe area, no hover). Do not ship SwiftUI .alert / DisclosureGroup / .popover as the CDS Alert / Accordion / Tooltip just because Apple has a look-alike.

Classify before writing code

Pick one rewrite pattern. If the Linear issue already has ios_work, honor it unless it still says “use SwiftUI API” for a component whose chrome does not match RN — then reclassify to CDS view.

PatternWhenCall siteCDS ships
style SwiftUI controlApple has the widget and a Style protocol, and makeBody can match RN chrome (Button, Toggle, ProgressView, TextField)Keep Apple's type + attach .cdsinternal Style + .cds(…) factory
modifier on SwiftUI viewApple has the widget but no Style protocol (Text, Divider insets)Keep Apple's type + .cdsText / .cdsDividerinternal ViewModifier
CDS viewRN chrome is not the platform default (Alert modal, Accordion, Tooltip / Nudge, Coachmark, Avatar, Lottie host, SlideButton)Alert(…), Accordion(…), SlideButton(…)internal View
use SwiftUI APIThe RN component already looks like the system API (HStack / Spacer / padding, existing CDSThemeProvider)Use the system APIGallery + docs only
skipNot iOS (AndroidNavigationBar, MediaQueryProvider / useBreakpoints)n/aDo not port

Text is modifier, not Style: SwiftUI has no TextStyle protocol. CDSTextStyle is a typography role enum, not a View. Never name a new type CDSTextStyle for a modifier.

When two patterns could apply, prefer: Style → modifier → CDS view (if RN chrome differs) → SwiftUI API (only if it already looks like RN) → skip.

Need Design = the native version cannot match RN and would look or behave dramatically different (research question 7). A missing Figma link alone is not a reason, and neither is “should this look like HIG instead.”

Do not wrap styled HIG controls — wrap the app

Do not invent CDSButton, CDSToggle, CDSText, CDSProgressCircle, CDSTextField, or CDSDivider views that hide the system widget. Overlay components whose RN chrome is not system chrome (Alert, Accordion, Tooltip) are CDS views — that is visual parity, not a Button wrapper.

The goal is the entire app looks like CDS, not “developers remembered to import CDSButton”. Those are opposite mechanisms:

ApproachForgotten Button("Save") {}Entire app?
Wrap in CDSButtonCompiles, looks like HIGNo — CDS is opt-in per control
Default Style on CDSThemeProviderCompiles, looks like CDSYes — CDS is opt-out per chrome

SwiftUI cannot replace SwiftUI.Button at import time the way RN replaces Pressable with @coinbase/cds-mobile Button. The analog of MaterialTheme / RN ThemeProvider is environment inheritance. Wrap CDSThemeProvider around the app. Do not wrap the control.

A CDSButton type also swallows SwiftUI API (ButtonRole, toolbar placement, keyboardShortcut, Menu, label as View) and recreates the RN facade this rewrite exists to delete.

How the whole app becomes CDS

CDSThemeProvider already injects \.cdsTheme and colorScheme. It should also install the SwiftUI style environment so unstyled HIG controls pick up CDS without a per-instance modifier:

  1. Always-safe defaults (do these on the provider):
    • .tint from the theme primary
    • .font from typography.body so Text is CDS body unless a role is set
    • .foregroundStyle from colors.fg
    • .toggleStyle(.cds(.primary))
    • .progressViewStyle(.cds(.m))
    • future .textFieldStyle(.cds) (not picker styles: apps can't implement PickerStyle / DatePickerStyle)
  2. Button is inherited too, but the default variant is not filled primary. A root .buttonStyle(.cds(.primary)) paints every toolbar item, list-row button, and many nav actions as a primary pill — that is not “the app is CDS”, that is “the app is covered in CTAs”. Default a CDS style that applies type, color, radius, and press without the filled primary chrome (a .cds / .cds(.plain) default). Explicit CTAs still write .buttonStyle(.cds(.primary)). Toolbar / list chrome that must stay HIG opts out with .buttonStyle(.plain) (or a later .cds(.toolbar)).
  3. OS .alert / .confirmationDialog are not CDS Alert. They ignore app ButtonStyle and will never match RN’s custom modal. Ship a CDS Alert view for the RN component. Leave SwiftUI .alert for true system dialogs (not a CDS export).
  4. Typography roles still use .cdsText(.title3) (and so on). Environment .font can only supply one default (body). Wrapping CDSText("Hello") is still wrong — it blocks Text concatenation, AttributedString, and Label.
  5. Gallery is the spec. Show both the inherited default and the explicit variant override.
  6. Do not add a second sugar (.cdsButton(.primary) that only forwards to .buttonStyle) unless Style discovery is proven painful.

If a product app wants RetailPrimaryButton, that wrapper lives in the app, not in CDS.

Shipped call sites (copy these)

swift
Button("Primary") { }
    .buttonStyle(.cds(.primary))

Button(action: next) {
    CDSButtonLabel("Continue", trailing: Image(systemName: "chevron.right"))
}
.buttonStyle(.cds(.primary, size: .l))

Toggle("Notifications", isOn: $on)
    .toggleStyle(.cds(.primary))

Text("Balance")
    .cdsText(.title3)

ProgressView()
    .progressViewStyle(.cds(.m))

// CDS Alert (RN overlay) — custom view, not SwiftUI .alert
// Alert(title: "Delete wallet?", …)

// OS dialog only — not the CDS Alert component
.alert("Delete wallet?", isPresented: $show) {
    Button("Delete", role: .destructive) { }
    Button("Cancel", role: .cancel) { }
}

CDSButtonLabel is a label helper, not a Button wrapper. Skip it when the label is custom.

Read RN for capability, not tree

From packages/mobile/ (and shared bits in packages/common/):

  • Take: variants, sizes, state (disabled, loading, error), a11y labels, animation intent, token names (bgPrimary, space.x2, borderRadius.roundedFull), and the visual design (padding, radius, chrome, pictogram, caret). That is the iOS spec.
  • Leave: Box/HStack RN trees, ThemeProvider wrappers in every story, React memo/useCallback, web className/styles, Pressable-as-root, RN-only props (testID patterns that don't map).

Map tokens through CDSTheme (@Environment(\.cdsTheme)). Never hard-code hex, point sizes, or UIColor that duplicates a token.

Implement

  1. Put code in packages/cds-ios/Sources/Components/<Name>.swift. Metrics-only helpers can live next to the style (see buttonColors / buttonMetrics) or in Sources/Components/internal/ if shared.
  2. Stay internal. No public on the component, Style, modifier, or variant enums until gallery + token tests exist and a human decides to stabilize.
  3. Use @Environment(\.cdsTheme) and @Environment(\.isEnabled). Do not take a theme: parameter on the Style unless a pure function needs it for tests.
  4. Extract pure mapping functions (buttonColors, toggleTrackColor, progressCircleDiameter) so Tests/CDSDesignSystemTests/ComponentStyleTests.swift can lock token wiring without rendering.
  5. Third-party (Lottie): wrap in a CDS type. Call sites never import Lottie for a CDS animation.
  6. Accessibility: keep system traits from the HIG control. Don't replace Button with a onTapGesture View just to draw chrome — that's what ButtonStyle.makeBody is for.
  7. Add a gallery section — a new <Name>GalleryView.swift registered in GalleryDestination and ComponentGalleryView, or a section inside OtherComponentsGalleryView.swift for components without their own destination — using the real call site (HIG control + Style, or the CDS view for overlays).
  8. Tests: yarn nx run cds-ios:test. Then yarn nx run cds-ios:build if the gallery or package graph changed. Do not run unscoped yarn test.

Anti-patterns

  • struct CDSButton: View that takes title / variant and hides SwiftUI.Button
  • Porting RN Box as CDS.Box
  • Shipping SwiftUI .alert / DisclosureGroup / .popover as CDS Alert / Accordion / Tooltip
  • Setting .buttonStyle(.cds(.primary)) on CDSThemeProvider (filled primary on every Button)
  • public components so the gallery compiles (use @testable)
  • Copying Android composable names/APIs because "parity"
  • Importing Lottie (or any library) from gallery or from a public CDS header
  • Using UIViewRepresentable when a SwiftUI Style/modifier/view will do
  • Making CDSTextStyle a View or ViewModifier

Checklist

  • Pattern chosen (Style / modifier / CDS view / SwiftUI API / skip)
  • Visual matches RN (gallery vs RN/Figma); HIG analog used only if it already looks like RN
  • No wrapper around Button / Toggle / Text / ProgressView
  • Tokens via CDSTheme, pure mappers unit-tested
  • Gallery shows the real call site
  • internal visibility
  • yarn nx run cds-ios:test passes

Συχνές ερωτήσεις

Τι κάνει η δεξιότητα AI Swiftui Best Practices;

ΧΡΗΣΙΜΟΠΟΙΗΣΤΕ ΤΗ όταν μεταφέρετε ένα component του CDS React Native σε εγγενές iOS ή όταν γράφετε ή ελέγχετε SwiftUI στα packages/cds-ios ή apps/ios-gallery. Καλύπτει μοτίβα επανεγγραφής (Style έναντι SwiftUI API έναντι CDS view), προδιαγραφές εμφάνισης RN (όχι απομιμήσεις του HIG), επιβολή στοιχείων ελέγχου με εμφάνιση HIG, tokens, gallery και δοκιμές.

Γιατί να χρησιμοποιήσετε τη δεξιότητα Swiftui Best Practices στο TypingMind;

Επειδή την εγκαθιστάτε μία φορά και τη χρησιμοποιείτε με οποιοδήποτε μοντέλο. Η Swiftui Best Practices είναι απλό Markdown και όχι κώδικας ειδικά για κάποιον πάροχο, επομένως η ίδια δεξιότητα λειτουργεί με GPT-5, Claude, Gemini, Grok ή ένα τοπικό μοντέλο — και μπορείτε να αλλάξετε μοντέλο κατά τη διάρκεια της συνομιλίας χωρίς να διακοπεί η λειτουργία της. Το TypingMind λειτουργεί με τα δικά σας κλειδιά API, οπότε πληρώνετε απευθείας τους παρόχους αντί για συνδρομή ανά θέση χρήστη, ενώ οι δεξιότητες και οι συνομιλίες σας παραμένουν στον δικό σας χώρο αποθήκευσης.

Πώς εγκαθιστώ τη δεξιότητα Swiftui Best Practices στο TypingMind;

Στο TypingMind, ανοίξτε Πρόσθετα → Δεξιότητες → Εγκατάσταση από το GitHub και επικολλήστε τη διεύθυνση https://github.com/coinbase/cds/tree/master/.claude/skills/swiftui-best-practices. Το TypingMind διαβάζει το αρχείο SKILL.md και εγκαθιστά τη δεξιότητα, την οποία μπορείτε να ενεργοποιείτε ανά συνομιλία.

Ποια μοντέλα AI μπορούν να χρησιμοποιήσουν τη δεξιότητα Swiftui Best Practices;

Οποιοδήποτε μοντέλο συνδέετε στο TypingMind. Οι δεξιότητες AI είναι απλές οδηγίες Markdown και όχι κώδικας ειδικά για κάποιον πάροχο, επομένως τα GPT, Claude, Gemini, Grok και τα τοπικά μοντέλα μπορούν όλα να φορτώσουν αυτή τη δεξιότητα όταν ένα αίτημα αντιστοιχεί σε αυτή.

Με πόσα μοντέλα AI μπορώ να χρησιμοποιήσω τη δεξιότητα Swiftui Best Practices;

Με όσα θέλετε. Στο TypingMind μπορείτε να χρησιμοποιήσετε τη δεξιότητα Swiftui Best Practices με οποιοδήποτε μοντέλο υποστηρίζει δεξιότητες, όπως τα GPT, Claude, Gemini, Grok, DeepSeek, Mistral και Llama, χρησιμοποιώντας τα δικά σας κλειδιά API.

Είναι δωρεάν η δεξιότητα AI Swiftui Best Practices;

Δημοσιεύεται στο GitHub από τον λογαριασμό coinbase. Ελέγξτε το αποθετήριο για τους όρους αδειοδότησης. Πληρώνετε μόνο τον δικό σας πάροχο AI για τα token που χρησιμοποιείτε.

Τι είναι οι δεξιότητες AI;

Μια δεξιότητα AI είναι ένα επαναχρησιμοποιήσιμο πακέτο οδηγιών που διδάσκει σε ένα μοντέλο AI πώς να εκτελεί μια συγκεκριμένη εργασία. Ακολουθεί την ανοιχτή μορφή Agent Skills: ένα αρχείο SKILL.md με όνομα και περιγραφή, μαζί με τυχόν σενάρια κώδικα, πρότυπα ή αρχεία αναφοράς που μπορεί να χρειαστεί το μοντέλο. Το μοντέλο διαβάζει τις οδηγίες μόνο όταν το αίτημά σας αντιστοιχεί στη δεξιότητα, οπότε μια εγκατεστημένη δεξιότητα δεν κοστίζει τίποτα μέχρι να χρησιμοποιηθεί.

Σε τι διαφέρουν οι δεξιότητες AI από τα πρόσθετα ή τους συνδέσμους MCP;

Ένα πρόσθετο ή ένας σύνδεσμος MCP παρέχει στο μοντέλο νέα εργαλεία που μπορεί να καλέσει — κώδικα που εκτελείται κάπου και επιστρέφει ένα αποτέλεσμα. Μια δεξιότητα AI παρέχει αντί γι’ αυτό γνώσεις και διαδικασίες στο μοντέλο: πώς να προσεγγίσει μια εργασία, ποια βήματα να ακολουθήσει και ποια χαρακτηριστικά έχει ένα καλό αποτέλεσμα. Οι δεξιότητες είναι απλό Markdown, επομένως δεν χρειάζονται διακομιστή, κλειδί API ή περιβάλλον εκτέλεσης και λειτουργούν με οποιοδήποτε μοντέλο.

Προβολή όλων
Λογότυπο mattpocock

Improve Codebase Architecture

mattpocock
ΚοινότηταΔημοφιλής

Σαρώστε μια βάση κώδικα για ευκαιρίες περαιτέρω διερεύνησης, παρουσιάστε τις σε μια οπτική αναφορά HTML και, στη συνέχεια, εξετάστε διεξοδικά όποια επιλέξετε.

22.3K
264.4K
Αρχεία: 2
Προβολή
Λογότυπο mattpocock

Grilling

mattpocock
ΚοινότηταΔημοφιλής

Κάντε επίμονες και εξονυχιστικές ερωτήσεις στον χρήστη για ένα σχέδιο, μια απόφαση ή μια ιδέα. Χρησιμοποιήστε το όταν ο χρήστης θέλει να δοκιμάσει σε βάθος τη σκέψη του ή χρησιμοποιεί κάποια φράση ενεργοποίησης με τη λέξη «grill».

22.3K
264.4K
Αρχεία: 1
Προβολή
Λογότυπο mattpocock

Teach

mattpocock
ΚοινότηταΔημοφιλής

Διδάξτε στον χρήστη μια νέα δεξιότητα ή έννοια μέσα σε αυτόν τον χώρο εργασίας.

22.3K
264.4K
Αρχεία: 5
Προβολή
Λογότυπο affaan-m

Api Design

affaan-m
ΚοινότηταΔημοφιλής

Μοτίβα σχεδιασμού REST API, όπως ονοματοδοσία πόρων, κωδικοί κατάστασης, σελιδοποίηση, φιλτράρισμα, αποκρίσεις σφαλμάτων, διαχείριση εκδόσεων και περιορισμός ρυθμού αιτημάτων για API παραγωγής.

39.1K
261.1K
Οδηγίες
Προβολή

Δημιουργήστε τώρα τον δικό σας χώρο εργασίας AI

Εγγραφείτε στο ενημερωτικό μας δελτίο για να ενημερώνεστε για νέες λειτουργίες και μελλοντικές κληρώσεις δώρων 👇