Skip to content

Local Linking ​

Family layout convention ​

lh-ui/                        # Family parent directory (not a repo)
├── lh-ui-core/               # Token source of truth + codegen
├── lh-ui-android/            # Sibling repo
├── lh-ui-ios/                # This repo
├── lh-ui-harmony/
└── lh-ui-windows/

When every repo shares the same parent directory, tokens are linked locally; when a sibling repo is absent (a single-repo CI clone), it falls back to the npm package automatically. This is structurally the same as the web bloodline's vite alias guard mechanism (master plan D18).

Three-level guard ​

scripts/link-tokens.mjs looks for the token artifacts in priority order:

PrioritySourceNotes
1../lh-ui-core/dist/iosLocal linking: token changes take effect immediately
2node_modules/@lh-ui/core/dist/iosnpm fallback: @lh-ui/core's files:["dist"] ships all four platform artifacts
3—Errors out — without tokens there is nothing to build

Daily workflow ​

bash
# 1. Change tokens (in the core repo)
cd ../lh-ui-core
vim tokens/color.json           # or spacing / typography / ...

# 2. Regenerate + verify
pnpm codegen                    # Generates the dist/ artifacts for all four platforms
pnpm verify                     # schema + references + WCAG contrast + spec consistency

# 3. Sync back to this repo
cd ../lh-ui-ios
pnpm link:tokens                # Overwrites Sources/LhUITokens/

# 4. Regression
swift test

CI gate ​

bash
pnpm link:tokens:check          # Checks whether tokens are in sync (file-count comparison; exit code 1 if not)

Forbidden ​

  • ❌ Hand-editing Sources/LhUITokens/ (generated output, gitignored)
  • ❌ Committing generated token files to the repo
  • ❌ Writing color or spacing literals inside components (e.g. Color(red: 0.169, ...), CGFloat(40), a font size of 14)
  • ❌ Copying artifacts over manually instead of running link:tokens

Troubleshooting ​

SymptomCauseFix
Compile error cannot find 'LhTokens' in scopeTokens not syncedpnpm link:tokens
Token values do not match expectationsThe core repo was not re-run through codegenRun pnpm codegen in the core repo, then link again
link:tokens reports "token artifacts not found"Sibling repo absent and the npm package not installedCheck the family layout or run pnpm i -D @lh-ui/core
Dark colors look wrongThe light primary was changed but the dark pre-computation was not updatedUpdate color-dark.json and re-run (R-n6)
default-related compile errorsA generated member name colliding with a keyword was not escapedUpgrade core (fixed: member names are wrapped in backticks, `default`)

lh-ui native bloodline · iOS (Swift + SwiftUI)