Purpose
Enable Codex to use the Figma MCP (figma-desktop) to fetch design data and generate Swift / SwiftUI code consistent with NewsBreak’s design system.
Rules
- Use
/Figma/get_metadatato inspect layer structure, node names, and frame hierarchy. - Treat Figma layer names as the canonical source of Swift struct names
(e.g.BreakingNewsCard→BreakingNewsCardView).
- Use
/Figma/get_codefor components with Code Connect definitions. - When
clientLanguages=swiftandclientFrameworks=swiftui, Codex should return valid SwiftUI code. - Generated code must follow
NBDesigntoken definitions (colors, fonts, spacings). - If tokens don’t exist, add comments like
// TODO: define in NBDesign.
- Use
/Figma/get_variable_defsto extract design tokens (colors, radius, typography). - Merge updates into
NBDesign.swiftusing consistent naming:
DesignColor.primary,DesignFont.headline, etc.
- Use
/Figma/get_screenshotfor snapshot comparisons between Figma design and rendered SwiftUI preview. - Store generated previews under
/Previews/FigmaComparisons/.
- Add Codex prompt patterns such as:
Generate SwiftUI component from Figma nodeCompare Figma design and local SwiftUI viewSync Figma variables to NBDesign.swift
- Prefer
get_coderesults for high-fidelity UI; fallback toget_metadatafor layout skeletons.
Whenever you ask Codex to run pod install, it should:
- Change directory to
~/Work/nb-iOS/NewsBreak - Run
bundle exec pod install - Return to the original directory
- iOS app source lives under
NewsBreak/(Objective-C) andFeatures/(Swift feature modules).
Each feature module exposes its ownClasses/subtree. - Shared libraries sit under
Libraries/(design system, routing, metrics, etc.).
Respect module boundaries when introducing cross-cutting code. - Third-party pods & tools:
LocalPods/holds vendored frameworks.swiftlint/contains lint configuration.- Keep generated artifacts out of version control.
# Local debug build
xcodebuild -workspace /Users/yxj/Work/nb-iOS/NewsBreak/InNow.xcworkspace -scheme NewsBreak -configuration Debug build -destination 'platform=iOS Simulator,name=iPhone 15'
# Run XCTest suites
xcodebuild test -workspace /Users/yxj/Work/nb-iOS/NewsBreak/InNow.xcworkspace -scheme NewsBreakTests -destination 'platform=iOS Simulator,name=iPhone 15,OS latest'
# Enforce Swift style
swiftlint lint --config swiftlint/.swiftlint.yml
# Refresh CocoaPods
bundle exec pod install- Swift: 4-space indentation,
UpperCamelCasefor types,lowerCamelCasefor variables/functions. - Objective-C: follow existing brace style and use
NBprefixes for shared classes. - Prefer
final classand protocol-oriented design in Swift modules. - Keep Objective-C categories in
Category/folders. - Run
swiftlintand respect any baseline suppressions inswiftlint/swiftlint_baseline.json.
- Unit/UI tests use XCTest.
Place new tests beside their target inNewsBreakTests/or module-specificTests/directories. - Name test methods as
test_<Scenario>_<Expectation>(). - Ensure new features include coverage and avoid disabling failing tests.
- Use the
xcodebuild testcommand for CI parity.
Capture logs with-resultBundlePathwhen debugging failures.
- Write commits in imperative mood (e.g.,
Add drama carousel logging adapter). - Keep commits scoped to one logical change and run lint/tests before pushing.
- Pull requests should include:
- Concise summary
- Linked Jira/Ticket identifiers
- Screenshots for UI updates
- Notes on testing performed
- Request reviews from module owners (see
CODEOWNERS). - Ensure CI is green before merging.
- Never commit secrets (API keys, certificates, etc.).
Use existing build configuration files and keychain profiles. - When modifying networking modules, ensure feature gating (
NBFeatureGating) guards experimental endpoints.
- git: edits are auto-approved
Author Note:
All newly created source files should include the header author name:
jing.yang