Skip to content

feat(native): SwiftUI views as the Astryx product in apple/, with core components and clone-only templates - #7981

Merged
cixzhang merged 20 commits into
mainfrom
native/swift-ios-1
Oct 24, 2026
Merged

cixzhang merged 20 commits into
mainfrom
native/swift-ios-1

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Layout (2026-10-24): the SwiftUI views live in packages/native/apple/ as the Astryx product (Sources/Astryx/<Name>/, tests in Tests/AstryxTests/), beside AstryxNative; clone-only templates are in apple/Templates/, a separate package with no products that npm leaves out.

Starts the SwiftUI arm of AST-082 (Native-first surfaces) inside @astryxdesign/native. Adapted from ejc3/astryx-swift (MIT); EJ is co-author.

User need

A team building an iOS app with Astryx has nothing to start from: the web components do not run on iOS, and the native package has generated props types but no views. People trying Astryx in SwiftUI also need one agreed place for components and templates, so work from different people lands in the same shape instead of in separate forks.

Problem and solution fit

  • A versioned home. packages/native/apple/ is a Swift package. The 1 is a generation, not an iOS version, so a rethink can start swift-ios-2 beside it and both can be scored before one is retired.
  • core/ for components. One folder per component, named as in packages/core/src/<Name>/: Text and Heading, Button, TextInput, Card, Banner. Parameters use core's prop names and values (variant: .primary, size: .lg, isLoading).
  • templates/ for templates. One folder per astryx template id, built only from core/ and SwiftUI layout. It starts with login, which matches the web template's content, validation message, and loading state.
  • Tokens from core, not hand-copied. core/Theme/Generated/DefaultTheme.swift is core's default theme run through core's own resolver, light and dark (pnpm -F @astryxdesign/native generate:swift-ios). A test fails when it drifts. Components read every color, size, and font from the theme, and text grows with Dynamic Type.
  • README. apple/README.md covers the layout, how to use it, the token rules, how to add a component or template, and what is not done yet.

Current specification

AST-082 (current): DEC-7 (native implementations live in @astryxdesign/native), FR11 (native-first on each platform), FR12 arm A (platform views painted with Astryx's tokens).

Public delta and caller burden

  • No change to any published stable package. Core, lab, and themes are untouched.
  • @astryxdesign/native (private, canary-only) adds apple/ (the Astryx product) to its files, minus apple/Templates, and a generate:swift-ios script.
  • New experimental Swift product Astryx (components). Page templates are clone-only: templates/ is its own Swift package with no products, depending on the components by path, and it is left out of the npm package (npm pack --dry-run lists no template file). An app copies a template's folder:
import Astryx
import SwiftUI

WindowGroup { LoginTemplate().astryxTheme() } // LoginTemplate copied from Templates/Login/

Design and alternatives

  • Rejected: porting the whole spike. ejc3/astryx-swift draws snapshots computed by a TypeScript core in Hermes (arm C). That runtime and its wire format are separate work; this PR takes the SwiftUI drawing approach and the token handling, with plain Swift parameters.
  • Rejected: a version named after iOS. Which iOS versions are supported is still open (AST-082 OQ4). The package targets iOS 17 today; it also declares macOS 14 only so it builds and tests on a Mac without a simulator.
  • Next: views move onto the generated contract types in apple/ (ButtonProps and so on) once those contracts exist, so a core prop change reaches Swift.

Evidence

  • pnpm vitest run --project node packages/native: 33 tests pass, including color keywords, the theme drift check, and color-tint-hover.
  • pnpm -F @astryxdesign/native typecheck passes; the commit hook's repo checks pass.
  • Swift 6, macOS SDK: core/ and templates/ compile as modules; both test targets typecheck against them.
  • The test assertions also ran in Swift immediate mode against the real sources: all 24 checks pass (default tokens in both modes, token lookups and fallbacks, hex parsing, Dynamic Type scale, login validation and loading).
  • Rendered with SwiftUI's ImageRenderer on macOS in light and dark: buttons in every variant and size, error and success banners, a card, and the login column in its rest and error states. Text fields draw as blank boxes in an image render, which is a renderer limit.
  • CI: test-native-swift in ci.yml (joined by test, merged in ci(native): build and test the native Swift packages on macOS #7984) runs on macOS for every Package.swift under packages/native when Swift changes: swift test for a package that supports macOS and has test targets, then an iOS Simulator build. This package is in that tree, so this PR's own run builds and tests it; no separate lane is added here.
  • Review fixes: supporting text defaults to the secondary color and the extra-small size is .xsm (token font-size-xs), as core's Text; the button's tap area is at least 44 × 44 pt; the theme generator reads black/white (so color-tint-hover is present) and fails on any unreadable kept token; generate:swift-ios builds core first. New Swift TextTests and node assertions cover them.
  • Review fixes (latest): a loading button stays enabled and undimmed, holds its width, ignores presses and says Loading, as core's Button; fonts come from the theme's font-family-* stacks (first installed family, system font for system families) and headings read the heading family; Banner icons use core's shared icon names (info, warning, error, success) as SF Symbols a theme can replace, sized to grow with Dynamic Type; without astryxTheme(_:) components follow Dark Mode and Dynamic Type.
  • New Swift tests: Button (loading, disabled, 44 pt tap area, largest text), Heading (levels, VoiceOver heading level), TextInput (44 pt at every text size, secondary label color), Banner (shared icons, theme replacement, status ground), fonts, the default environment (Dark Mode, Dynamic Type), plus the two-theme tests. All 26 core test functions also ran in Swift immediate mode against the real sources: 0 failures.
  • Simulator or device captures (AST-093 FR5): not measured here. Captures of every component state and of the login template's rest, error, and loading states, in light, dark, and the largest text size, come from the CI screenshot target in the separate screenshot PR.
  • Supporting evidence only: SwiftUI ImageRenderer renders on macOS of the components in light, dark (without the theme modifier), and the largest accessibility text size. They are not simulator captures, and ImageRenderer draws the text field and spinner as placeholders.
  • Localized speech: the loading value and announcement read @astryx.button.loading from Localizable.strings generated per locale from core's catalogs (a vitest drift test; a Swift test checks en and de-DE).
  • Accessibility checks in the Swift tests: loading value, disabled dimming, 44 pt tap area, Heading level and largest size, Banner label (title, then description) and largest size, TextInput label, Dynamic Type and Dark Mode without the theme modifier.
  • Accessibility-tree assertions (AST-093 FR5): not measured until an app-hosted iOS test target exists (tracked as a native gap). Hostless SwiftPM tests on the iOS Simulator expose no SwiftUI accessibility tree (0 elements, verified in CI), and macOS builds none without an assistive client, so a test cannot yet fail when .accessibilityAddTraits(.isHeader), the field's .accessibilityLabel, or the button's Loading .accessibilityValue is removed. The checks above test the values and traits each view applies, not the rendered tree.
  • Not measured: an iOS Simulator test run (CI here runs swift test on macOS and an iOS Simulator build; simulator test runs arrive with the CI change that adds them) and on-device pixels.

Scope

  • One capability is added.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • Public text and artifacts contain no internal Meta context.

Testing

pnpm vitest run --project node packages/native
pnpm -F @astryxdesign/native typecheck
cd packages/native/apple && swift test && (cd templates && swift test)   # on a Mac with Xcode

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 23, 2026
@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 24, 2026 2:33pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Oct 24, 2026, 2:52 PM UTC

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

46 of 498 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 753,933
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,072
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
RichTextEditor Markdown parity: side by side probe dark 94,866
RichTextEditor Markdown parity: side by side probe light 89,762
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
Markdown Default neutral dark 7,573
Markdown Default neutral light 7,566

and 26 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval is waiting on a maintainer. AST-082 FR5 and FR16 say Swift bindings and native platform contracts are generated from core's contracts and read core only through a portable entry, so a maintainer needs to update AST-082, or identify the record that allows swift-ios-1's hand-written SwiftUI parameters and its build-time import of @astryxdesign/core/theme. A maintainer also needs to provide or identify the governing spec for native templates shipped as the AstryxTemplates product, since AST-082 lists product templates as a non-goal. Whatever that decision, these still need changes:

  • AstryxText should default supporting text to the secondary colour and spell core's xsm size .xsm, as core's Text does.
  • pnpm -F @astryxdesign/native generate:swift-ios fails on a fresh checkout until core is built, so the script should build core first.
  • The theme generator silently drops --color-tint-hover, and AstryxButton guarantees a 44 pt tap height but not width.
  • Please add a swift build and swift test run and an iOS build of the package, or the planned macOS CI lane, before approval.

[Automated review]

Comment thread packages/native/package.json Outdated
"prepack": "pnpm build",
"build": "node ../../scripts/clean-dist.mjs && tsc --project tsconfig.build.json && node scripts/generate.mjs --types",
"generate:apple": "pnpm build && node scripts/generate.mjs --apple",
"generate:swift-ios": "node scripts/swift-ios-theme.mjs",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a fresh checkout this fails with ERR_MODULE_NOT_FOUND for @astryxdesign/core/dist/theme/index.js, because plain node resolves core's default export to dist/ and nothing builds it. The drift test's message sends contributors here. Building first, as generate:apple does, fixes it:

"generate:swift-ios": "pnpm -F @astryxdesign/core build && node scripts/swift-ios-theme.mjs"

/// Core's `Text` sizes this package draws so far, used to override the size
/// a semantic type sets.
public enum AstryxTextSize: String, CaseIterable, Sendable {
case xs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core's Text size has no xs. The value is 'xsm', which maps to --font-size-xs (packages/core/src/Text/text.stylex.ts), so size="xsm" has no Swift spelling. Rename the case to xsm and keep the token font-size-xs, so the README's "core's prop names and values" holds (AST-082 FR3).

public init(
_ content: String,
type: AstryxTextType = .body,
color: AstryxTextColor = .primary,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core defaults Text color by type: supporting gets secondary, every other type primary (defaultColorByType in Text.tsx). With .primary here, AstryxText("…", type: .supporting) paints primary text. Making color optional and resolving it from type keeps the default the same on both platforms (AST-082 FR3).

: parseFloat(m[4]);
return `#${hex2(+m[1])}${hex2(+m[2])}${hex2(+m[3])}${hex2(alpha * 255)}`;
}
if (v === 'transparent') return '#00000000';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any other CSS keyword returns null, and resolveMode then skips the token without a message. Core's --color-tint-hover resolves to black / white, so it is missing from both generated tables, and the drift test cannot notice. Accept CSS named colours, or throw on an unreadable value in a kept group.

.opacity(isEnabled ? (configuration.isPressed ? 0.75 : 1) : 0.5)
// Drawn at the token height; laid out at least 44 high so the whole
// platform-minimum tap area counts.
.frame(minHeight: 44)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This guarantees the 44 pt minimum vertically only. A one-character label is about 33 pt wide (label plus 2 × 12 pt padding), below the minimum the doc comment promises (AST-082 FR11). .frame(minWidth: 44, minHeight: 44) covers both.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval is waiting on an engineering owner's decision: AST-093 FR5 asks native components to take parameters named and typed as their generated contracts (ButtonProps, TextProps, HeadingProps, TextInputProps and CardProps already exist), and AST-082 FR16 lets native read core only through a portable entry, but swift-ios-1 hand-writes its initializers and its theme generator imports @astryxdesign/core/theme. An engineering owner can accept that interim shape by commenting /approve-spec <full head SHA> on this pull request (the author may, as an engineering owner) or by amending AST-093 or AST-082; otherwise the components move onto the generated contracts, Banner gets one, and the generator waits for the portable entry. Whatever that decision, these need changes:

  • AstryxButton treats isLoading as disabled (dimmed to 0.5 and .disabled), where core's Button stays undimmed, focusable and announces Loading.
  • AST-093 FR5's evidence is missing: accessibility and largest-Dynamic-Type checks, tests for Heading, TextInput and Banner, a test run on iOS, and simulator or device captures.
  • The type family and Banner icons are fixed in code (.system fonts, --font-family-* dropped by the generator), so a theme's font and icons never reach iOS (AST-093 FR4).
  • Outside .astryxTheme() the components ignore Dark Mode and Dynamic Type (AST-082 FR11).

[Automated review]

)
// A loading button keeps its label for VoiceOver, and the progress
// indicator announces itself; taps are ignored until it finishes.
.disabled(isDisabled || isLoading)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isLoading makes the button disabled, so the style dims it to 0.5 (line 132) and assistive technology gets a disabled control. Core's Button keeps a loading button undimmed and focusable and announces Loading through a live region, and family:buttons FR4 keeps disabled and pending styling distinct. Disable only for isDisabled, ignore taps in the action while loading, and overlay the spinner so the width holds.


/// A system font at a token size and a token weight.
public func font(size token: String, _ fallback: CGFloat, weight: String) -> Font {
.system(size: fontSize(token, fallback), weight: fontWeight(size(weight, 400)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every component's font is .system, and the generator drops --font-family-*, so a theme's type family never reaches iOS. AST-093 FR4 lists type family among the values that come from the theme; carry the family tokens and use Font.custom when the first family is installed, keeping the system font for a system stack.

}

private struct AstryxStyleKey: EnvironmentKey {
static let defaultValue = AstryxStyle(tokens: .defaultLight)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without .astryxTheme() this default keeps light colours in Dark Mode and a text scale of 1, so text ignores Dynamic Type (AST-082 FR11). Keeping the theme in the environment and resolving mode and scale where components read it would let the default follow both settings.

Comment on lines +79 to +80
const {defineTheme} = await import('@astryxdesign/core/theme');
const {resolveThemeTokens} = await import('@astryxdesign/core/theme/tokens');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads core's web theme entry, which exports Theme and the CSS generators, where AST-082 FR16 lets native read core only through a portable entry. check-package-boundaries.js does not see it because it scans only packages/native/src. This is part of the open owner decision on the interim shape.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec d2ada10

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec b5e5eef

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 846a9ea

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes are needed before this can be approved. An engineering owner's /approve-spec on this head settles the interim direction, but AST-093 FR5 and AST-082 FR3/FR16 still say the opposite, and AST-093 FR5's evidence is incomplete.

  • Attach iOS Simulator or device captures of every component state and of the login template's rest, error and loading states, in light, dark and at the largest text size (AST-093 FR5).
  • Record the accepted interim shape on main (AST-093 FR5 for the hand-written parameters and Banner's missing contract, AST-082 FR16 for the build-time @astryxdesign/core/theme import), or move Button, Text, Heading, TextInput and Card onto their generated contracts.
  • Run the Swift tests on an iOS Simulator and add the missing checks: Heading at the largest text size and under a second theme, Banner's accessibility label and largest size, and TextInput's accessibility label.

[Automated review]

isLoading: Bool = false,
isDisabled: Bool = false,
fillsWidth: Bool = false,
action: @escaping () -> Void

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core's Button contract calls this onClick (ButtonProps.onClick in apple/Sources/AstryxNative/Generated/Button.swift), and AST-093 FR5 asks native components for parameters named and typed as their generated contract. Taking ButtonProps, or recording the accepted interim exemption in AST-093 FR5, resolves it.

}

/// What assistive technology reads after the label while loading.
var loadingValue: String? { isLoading ? "Loading" : nil }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This value and the announcement on line 99 are English literals, while core's Button speaks t('@astryx.button.loading'), so a VoiceOver user on a non-English device hears English. A localized string table seeded from core's catalog would keep the word per locale.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 710e997

Drops the AstryxTemplates library product. The target and its tests stay so
templates still compile and are tested; the READMEs describe templates as
source to copy into an app, as catalog templates are.
Core's FieldLabel draws the label at the label size and medium weight in
color-text-secondary; AstryxTextInput drew it in the primary color.
- templates/ becomes a separate Swift package with no products that depends
  on the components by path, so the components' Package.swift no longer
  names template paths.
- package.json leaves swift-ios-1/templates out of the npm package; npm pack
  lists no template file.
- Template tests move to templates/Tests.
…ronment, tests

- AstryxButton: a loading button stays enabled and undimmed, keeps its
  width with the spinner drawn over the label, ignores presses, and says
  Loading to assistive technology, as core's Button does.
- Fonts come from the theme's font-family stacks (the generator now keeps
  them): the first installed family wins, system families use the system
  font. Headings read font-family-heading.
- Banner icons use core's shared icon names, drawn as SF Symbols that a
  theme can replace; they grow with Dynamic Type.
- Without astryxTheme(_:), components follow Dark Mode and Dynamic Type.
- Tests for Button (loading, disabled, tap area, largest text), Heading,
  TextInput, Banner, fonts, and the default environment.
…ibility tests

- generate:swift-ios also writes Localizable.strings per locale from core's
  locale catalogs; AstryxButton's loading value and announcement read
  @astryx.button.loading from them. A test fails when they drift.
- Banner reads its title then its description as one label; TextInput
  names the field by its label.
- Tests: Heading at the largest text size and under a second theme, Banner
  label and largest size, TextInput label, localized Loading.
Localizations are named by language alone unless a language has several
catalogs (pt-BR, pt-PT), with zh-Hans, zh-Hant and nb as Apple spells them.
The strings test finds a localization case-insensitively, since SwiftPM may
change a folder's case.
…l and trait tests

- The README names the three parameters that differ from core's names
  (action, a Binding for value, an optional level) as the interim shape.
- Button exposes its accessible name and button trait, Heading its header
  trait, and tests assert them.
Content is wrapped in a VStack (leading, no added spacing), as children flow
inside core's Card. A two-child test checks both children share one card,
top to bottom; the test pixel reader now reads rows top first.
New iOS-only tests host each component in a UIHostingController and read
the accessibility elements SwiftUI exposes to UIKit: Heading's header trait,
the text field's name, and Button's label, button trait, and Loading value.
Removing any of those modifiers fails them.
Hosting a SwiftUI view in a UIHostingController stops the hostless SwiftPM
test process on the iOS Simulator, failing every main-actor test after it.
Reading the accessibility tree needs an app-hosted test target.
…oduct

swift-ios-1/ is retired. apple/Package.swift now has two products: Astryx
(views, theme, localized messages; Sources/Astryx/<Name>/, tests in
Tests/AstryxTests/) and AstryxNative (generated contracts and the logic
host). Page templates move to apple/Templates/, still a separate package
with no products, and npm files leave apple/Templates out. The theme and
strings generators write into Sources/Astryx/.
@cixzhang cixzhang changed the title feat(native): start swift-ios-1, a SwiftUI package with core components and templates feat(native): SwiftUI views as the Astryx product in apple/, with core components and clone-only templates Oct 24, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec c246588

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes are needed before this can be approved: the SwiftUI views now live in apple/Sources/Astryx/, but AST-093 on main still places Swift components in swift-ios-<n>/core/ and ties the interim parameter exemption to swift-ios-1, and the evidence AST-093 FR5 asks for is still incomplete.

  • Record the apple/ layout in AST-093 FR1 and its Current-state impact on main and update the packages/native/specs/ guidance, or keep the views in swift-ios-1/core/.
  • Attach iOS Simulator or device captures of each view's states and of the login template's rest, error and loading states, in light, dark and at the largest text size.
  • Make the accessibility assertions observe the rendered views, for example from an app-hosted test target, so that removing .accessibilityHeading, the field's .accessibilityLabel or the button's Loading .accessibilityValue fails a test.
  • Resolve AstryxButton's icon through the theme's shared icon names, as AstryxBanner does, and list all six parameter differences in the README.

[Automated review]

└── Tests/
```

- **`Sources/Astryx/<Name>/`** holds one folder per component, named as in

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AST-093 FR1 on main still puts a Swift component's folder and spec at packages/native/swift-ios-<n>/core/<Name>/<Name>.spec.md, and its Current-state impact ties the FR5 parameter exemption to views in swift-ios-1; packages/native/specs/README.md, TEMPLATE.md and the two specs/swift/ READMEs say the same. Recording this Sources/Astryx/<Name>/ layout there keeps the next component spec beside its views.

Comment thread packages/native/apple/README.md Outdated
- **`Sources/Astryx/<Name>/`** holds one folder per component, named as in
`packages/core/src/<Name>/`. A component's parameters use core's prop names
and values (`variant: .primary`, `size: .lg`, `isLoading`), so code reads
the same across web and native, with three exceptions, the interim shape

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides these three, AstryxButton adds fillsWidth and takes icon as an SF Symbol name (neither is in the generated ButtonProps), and AstryxCard(padding: Int) cannot spell CardPadding's 0.5 and 1.5 steps. Listing them keeps this sentence true for anyone porting web code.

// spinner draws over it.
HStack(spacing: astryx.space(2)) {
if let icon {
Image(systemName: icon)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image(systemName: icon) takes a raw SF Symbol name, so a shared icon name such as "success" draws nothing and a theme's icons never reach a button (AST-093 FR4; AST-082 FR4 and FR17). Resolving it through astryx.icon(_:), as AstryxBanner does, keeps the shared names and theme replacement.

…all six parameter differences

- AstryxButton resolves icon through the theme's shared icon names, as
  AstryxBanner does. The default map covers every built-in name, and a
  vitest check keeps it equal to NATIVE_ICON_DEFAULTS.
- The README names all six differences from core's parameters.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec bf745f3

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes are needed before this can be approved: the SwiftUI views now live in apple/Sources/Astryx/, but AST-093 on main still places Swift component folders in swift-ios-<n>/core/ and ties the interim parameter exemption to swift-ios-1, and the evidence AST-093 FR5 asks for is still incomplete.

  • Land the AST-093 amendment for the apple/ layout (#8245) on main, point the packages/native/specs/ guidance at apple/Sources/Astryx/<Name>/, and give AstryxHeading its own Heading/ folder.
  • Attach iOS Simulator or device captures of each view's states and of the login template's rest, error and loading states, in light, dark and at the largest text size.
  • Make the accessibility assertions observe the rendered views, for example from an app-hosted test target, so that removing a label, trait or value modifier fails a test.

[Automated review]

`packages/core/src/<Name>/`. A component's parameters use core's prop names
and values (`variant: .primary`, `size: .lg`, `isLoading`), so code reads
the same across web and native, with six exceptions, the interim shape
AST-093 FR5 exempts until the components move onto the generated contracts:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AST-093's exemption on main covers "The first Swift views in swift-ios-1", and FR1 still puts Swift component folders in packages/native/swift-ios-<n>/core/<Name>/. Until the amendment in #8245 lands, this citation does not cover views in apple/Sources/Astryx/, and packages/native/specs/README.md, specs/TEMPLATE.md, specs/swift/README.md and specs/swift/library/README.md still send component specs to swift-ios-1/core/.

Comment thread packages/native/apple/README.md Outdated
│ │ │ └── Generated/ # core's default theme, generated; do not edit
│ │ ├── Resources/ # core's messages per locale, generated; do not edit
│ │ ├── Localization/
│ │ ├── Text/ # AstryxText, AstryxHeading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AstryxHeading lives in Text/, but core keeps Heading in its own packages/core/src/Heading/, and AST-093 FR1 gives each native component its own folder named as the core component, so a Heading spec would have no views beside it. Moving it to Sources/Astryx/Heading/ fixes that.


@MainActor
@Test func aHeadingIsAHeader() {
#expect(AstryxHeading.accessibilityTraits.contains(.isHeader))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads the static AstryxHeading.accessibilityTraits declared at AstryxText.swift:113, so it stays green if .accessibilityAddTraits and .accessibilityHeading at AstryxText.swift:108-109 are deleted. AST-093 FR5's trait assertion needs to observe the hosted view, for example from an app-hosted test target.

@MainActor
@Test func aTextFieldIsNamedByItsLabel() {
let field = AstryxTextInput(label: "Email", value: .constant(""))
#expect(field.accessibilityText == "Email")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accessibilityText is label (AstryxTextInput.swift:61), so this passes without .accessibilityLabel at AstryxTextInput.swift:55, which is the field's only name because the visible label is hidden from VoiceOver at :43.

let loading = AstryxButton(label: "Save", isLoading: true) { presses += 1 }
loading.activate()
#expect(presses == 0)
#expect(loading.loadingValue == "Loading")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loadingValue is computed beside the view; VoiceOver hears it only through .accessibilityValue at AstryxButton.swift:99, which this assertion never reaches.

As in core, Heading lives in apple/Sources/Astryx/Heading/. Its tests move
to HeadingTests.swift, and the text field's to TextInputTests.swift.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec f4faca3

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval is waiting on an engineering owner: the SwiftUI views now live in packages/native/apple/Sources/Astryx/, but AST-093 on main still places Swift component folders in swift-ios-<n>/core/ (FR1) and grants the interim parameter exemption to views in swift-ios-1 (Current-state impact). An engineering owner needs to update those AST-093 claims on main for the apple/ layout (the open amendment, #8245) and record the decision by commenting /approve-spec <full head SHA> on this pull request; the author may do both as an engineering owner. Whatever that decision, these still need changes:

  • Attach iOS Simulator or device captures of each view's states and of the login template's rest, error and loading states, in light, dark and at the largest text size (AST-093 FR5).
  • Make the accessibility assertions observe the rendered views, for example from an app-hosted test target, so that removing a label, trait or value modifier fails a test.
  • If the apple/ layout stays, point the packages/native/specs/ guidance at apple/Sources/Astryx/<Name>/.

[Automated review]


@MainActor
@Test func aHeadingIsAHeader() {
#expect(AstryxHeading.accessibilityTraits.contains(.isHeader))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads the static AstryxHeading.accessibilityTraits, not what the rendered heading exposes, so deleting .accessibilityAddTraits and .accessibilityHeading in AstryxHeading.swift (lines 29-30) leaves it green. AST-093 FR5 asks for accessibility assertions, and they need to fail when the trait is removed; a test that reads the heading's accessibility element from an app-hosted target would.

Comment on lines +57 to +59
#expect(AstryxButton(label: "Save") {}.accessibilityText == "Save")
#expect(AstryxButton(label: "Save", isLoading: true) {}.accessibilityText == "Save")
#expect(AstryxButton.accessibilityTraits.contains(.isButton))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These compare accessibilityText and the static accessibilityTraits with the values they are declared as; VoiceOver hears them only through the modifiers at AstryxButton.swift:97-99, which no test reads. The same applies to loadingValue at line 16.

Comment on lines +49 to +50
the same across web and native, with six exceptions, the interim shape
AST-093 FR5 exempts until the components move onto the generated contracts:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On main, AST-093's Current-state impact grants this exemption to the views “in swift-ios-1”; it covers Sources/Astryx/ once the AST-093 amendment for the apple/ layout lands.

@cixzhang
cixzhang merged commit d42a692 into main Oct 24, 2026
70 checks passed
@github-actions
github-actions Bot deleted the native/swift-ios-1 branch October 25, 2026 06:20

This branch was successfully deployed

1 active deployment
Preview — f4faca38 Deployed Oct 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant