Easy Prompt提示词导航站
代码能力代码高难

SwiftUI 代码审查助手

全面审查 SwiftUI 代码,检查现代 API 使用、可维护性、性能、可访问性和设计规范,提供具体修复建议。

提示词正文

复制后可直接粘贴到模型或内部评测工具。

Review Swift and SwiftUI code for correctness, modern API usage, and adherence to project conventions. Report only genuine problems - do not nitpick or invent issues.

Review process:

  1. Check for deprecated API.
  2. Check that views, modifiers, and animations have been written optimally.
  3. Validate that data flow is configured correctly.
  4. Ensure navigation is updated and performant.
  5. Ensure the code uses designs that are accessible and compliant with Apple's Human Interface Guidelines.
  6. Validate accessibility compliance including Dynamic Type, VoiceOver, and Reduce Motion.
  7. Ensure the code is able to run efficiently.
  8. Quick validation of Swift code.
  9. Final code hygiene check.

If doing a partial review, load only the relevant sections below.

Core Instructions

  • iOS 26 exists, and is the default deployment target for new apps.
  • Target Swift 6.2 or later, using modern Swift concurrency.
  • As a SwiftUI developer, the user will want to avoid UIKit unless requested.
  • Do not introduce third-party frameworks without asking first.
  • Break different types up into different Swift files rather than placing multiple structs, classes, or enums into a single file.
  • Use a consistent project structure, with folder layout determined by app features.

Output Format

Organize findings by file. For each issue:

  1. State the file and relevant line(s).
  2. Name the rule being violated (e.g., "Use foregroundStyle() instead of foregroundColor()").
  3. Show a brief before/after code fix.

Skip files with no issues. End with a prioritized summary of the most impactful changes to make first.

Example output:

ContentView.swift

Line 12: Use foregroundStyle() instead of foregroundColor().

// Before
Text("Hello").foregroundColor(.red)

// After
Text("Hello").foregroundStyle(.red)

Line 24: Icon-only button is bad for VoiceOver - add a text label.

// Before
Button(action: addUser) {
    Image(systemName: "plus")
}

// After
Button("Add User", systemImage: "plus", action: addUser)

Line 31: Avoid Binding(get:set:) in view body - use @State with onChange() instead.

// Before
TextField("Username", text: Binding(
    get: { model.username },
    set: { model.username = $0; model.save() }
))

// After
TextField("Username", text: $model.username)
    .onChange(of: model.username) {
        model.save()
    }

Summary

  1. Accessibility (high): The add button on line 24 is invisible to VoiceOver.
  2. Deprecated API (medium): foregroundColor() on line 12 should be foregroundStyle().
  3. Data flow (medium): The manual binding on line 31 is fragile and harder to maintain.

End of example.

使用场景

审查 SwiftUI 项目代码质量识别并修复已弃用的 API 调用提升应用的可访问性合规性优化数据流和状态管理确保导航和动画符合最佳实践统一项目代码风格和结构设计

参考输出

### ContentView.swift **Line 12: Use `foregroundStyle()` instead of `foregroundColor()`.** ```swift // Before Text("Hello").foregroundColor(.red) // After Text("Hello").foregroundStyle(.red) ``` **Line 24: Icon-only button is bad for VoiceOver - add a text label.** ```swift // Before Button(action: addUser) { Image(systemName: "plus") } // After Button("Add User", systemImage: "plus", action: addUser) ``` ### Summary 1. **Accessibility (high):** The add button on line 24 is invisible to VoiceOver. 2. **Deprecated API (medium):** `foregroundColor()` on line 12 should be `foregroundStyle()`.

评分维度

评分标准: - **完整性(30%)**:是否覆盖所有审查维度(API、可访问性、性能、设计等) - **准确性(30%)**:问题识别是否准确,建议是否符合 SwiftUI 最佳实践 - **实用性(20%)**:修复建议是否具体、可操作,是否提供 before/after 示例 - **优先级(20%)**:总结是否合理排序问题影响程度(高/中/低)

用户评分

0 个评分
-

你的评分

登录后评分

评论

0

登录后评论

相关提示词

图片写作生成

产品营销 - 黑白先锋时尚人像

一个用于拍摄锐利人像的高级时尚黑白编辑提示词,包含戏剧性光影和未来感配饰,模仿奢侈品牌广告大片风格。

Nano Banana Pro图片提示词产品营销
Nano Banana Pro 图像生成
图片写作生成

社交媒体帖子 - 梦幻夜花园时尚人像

一个复杂且高质量的提示词,用于创作充满奇幻色彩的时尚大片,营造出闪烁的灯光与浪漫的氛围。

Nano Banana Pro图片提示词社交媒体帖子
Nano Banana Pro 图像生成
图片写作生成

社交媒体帖子 - 野花丛中梦幻般的女子

这是一个电影级、照片写实风格的提示词,用于创作一幅女子在雏菊丛中的宁静肖像,强调柔和的自然光和前景细节的清晰对焦。

Nano Banana Pro图片提示词社交媒体帖子
Nano Banana Pro 图像生成
图片写作生成

社交媒体帖子 - 地中海里维埃拉男装风格

一份全面的专业摄影提示词,旨在呈现以阳光普照的石质建筑为背景、对比鲜明且锐利的男装时尚大片。

Nano Banana Pro图片提示词社交媒体帖子
Nano Banana Pro 图像生成