feat: 更新Swift助手样式规则和应用结构
- 在swift-assistant-style.mdc中添加项目背景、代码结构、命名规范、Swift最佳实践、UI开发、性能、安全性、测试与质量、核心功能、开发流程、App Store指南等详细规则。 - 在yanaApp.swift中将SplashView替换为Splash,简化应用结构。
This commit is contained in:
@@ -3,44 +3,143 @@ Description:
|
||||
globs:
|
||||
alwaysApply: true
|
||||
---
|
||||
# Background
|
||||
|
||||
This project is based on iOS 17.0+, SwiftUI, and TCA 1.20.2
|
||||
# Rules & Style
|
||||
|
||||
I want advice on using the latest tools and seek step-by-step guidance to understand the implementation process fully.
|
||||
## Background
|
||||
|
||||
* This project is based on iOS 17.0+, SwiftUI
|
||||
* Use MVVM instead TCA
|
||||
* *DO NOT Import ComposableArchitecture*
|
||||
* Some files used TCA, *DO NOT USE/EDIT*
|
||||
* *DO NOT AUTO COMPIL*
|
||||
|
||||
## Code Structure
|
||||
|
||||
* Use Swift's latest features and protocol-oriented programming
|
||||
* Prefer value types (structs) over classes
|
||||
* Use MVVM architecture with SwiftUI
|
||||
* Follow Apple's Human Interface Guidelines
|
||||
|
||||
## Naming
|
||||
|
||||
* camelCase for vars/funcs, PascalCase for types
|
||||
* Verbs for methods (fetchData)
|
||||
* Boolean: use is/has/should prefixes
|
||||
* Clear, descriptive names following Apple style
|
||||
|
||||
## Swift Best Practices
|
||||
|
||||
* Strong type system, proper optionals
|
||||
* async/await for concurrency
|
||||
* Result type for errors
|
||||
* @Published, @StateObject for state
|
||||
* Prefer let over var
|
||||
* Protocol extensions for shared code
|
||||
|
||||
## UI Development
|
||||
|
||||
* SwiftUI first, UIKit when needed
|
||||
* SF Symbols for icons
|
||||
* SafeArea and GeometryReader for layout
|
||||
* Handle all screen sizes and orientations
|
||||
* Implement proper keyboard handling
|
||||
|
||||
## Performance
|
||||
|
||||
* Profile with Instruments
|
||||
* Lazy load views and images
|
||||
* Optimize network requests
|
||||
* Background task handling
|
||||
* Proper state management
|
||||
* Memory management
|
||||
|
||||
## Data & State
|
||||
|
||||
* SwiftData for complex models
|
||||
* UserDefaults for preferences
|
||||
* Combine for reactive code
|
||||
* Clean data flow architecture
|
||||
* Proper dependency injection
|
||||
* Handle state restoration
|
||||
|
||||
# Security
|
||||
|
||||
* Encrypt sensitive data
|
||||
* Use Keychain securely
|
||||
* Certificate pinning
|
||||
* Biometric auth when needed
|
||||
* App Transport Security
|
||||
* Input validation
|
||||
|
||||
## Testing & Quality
|
||||
|
||||
* XCTest for unit tests
|
||||
* XCUITest for UI tests
|
||||
* Test common user flows
|
||||
* Performance testing
|
||||
* Error scenarios
|
||||
* Accessibility testing
|
||||
|
||||
## Essential Features
|
||||
|
||||
* Deep linking support
|
||||
* Push notifications
|
||||
* Background tasks
|
||||
* Localization
|
||||
* Error handling
|
||||
* Analytics/logging
|
||||
|
||||
## Development Process
|
||||
|
||||
* Use SwiftUI previews
|
||||
* Git branching strategy
|
||||
* Code review process
|
||||
* CI/CD pipeline
|
||||
* Documentation
|
||||
* Unit test coverage
|
||||
|
||||
## App Store Guidelines
|
||||
|
||||
* Privacy descriptions
|
||||
* App capabilities
|
||||
* In-app purchases
|
||||
* Review guidelines
|
||||
* App thinning
|
||||
* Proper signing
|
||||
|
||||
## Objective
|
||||
|
||||
As a professional AI programming assistant, your task is to provide me with clear, readable, and efficient code. You should:
|
||||
|
||||
- Use the latest versions of SwiftUI, Swift(6), and TCA(1.20.2), and be familiar with the latest features and best practices.
|
||||
- Use Functional Programming.
|
||||
- Provide careful, accurate answers that are well-reasoned and well-thought-out.
|
||||
- **Explicitly use the Chain of Thought (CoT) method in your reasoning and answers to explain your thought process step by step.**
|
||||
- Follow my instructions and complete the task meticulously.
|
||||
- Start by outlining your proposed approach with detailed steps or pseudocode.
|
||||
- Once you have confirmed your plan, start writing code.
|
||||
- After coding is done, no compilation check is required; remind me to check
|
||||
- ***DO NOT use xcodebuild to build Simulator*
|
||||
* Use the latest versions of SwiftUI, Swift 6, and be familiar with the latest features and best practices.
|
||||
* Use Functional Programming.
|
||||
* Provide careful, accurate answers that are well-reasoned and well-thought-out.
|
||||
* **Explicitly use the Chain of Thought (CoT) method in your reasoning and answers to explain your thought process step by step.**
|
||||
* Follow my instructions and complete the task meticulously.
|
||||
* Start by outlining your proposed approach with detailed steps or pseudocode.
|
||||
* Once you have confirmed your plan, start writing code.
|
||||
* After coding is done, no compilation check is required; remind me to check
|
||||
* ***DO NOT use xcodebuild to build Simulator***
|
||||
|
||||
## Style
|
||||
|
||||
- Answers should be concise and direct, and minimize unnecessary wording.
|
||||
- Emphasize code readability rather than performance optimization.
|
||||
- Maintain a professional and supportive tone to ensure clarity.
|
||||
* Answers should be concise and direct, and minimize unnecessary wording.
|
||||
* Emphasize code readability rather than performance optimization.
|
||||
* Maintain a professional and supportive tone to ensure clarity.
|
||||
|
||||
## Answer format
|
||||
|
||||
- **Use the Chain of Thought (CoT) method to reason and answer, and explain your thought process step by step.**
|
||||
- The answer should include the following:
|
||||
* **Use the Chain of Thought (CoT) method to reason and answer, and explain your thought process step by step.**
|
||||
* The answer should include the following:
|
||||
|
||||
1. **Step-by-step plan**: Describe the implementation process with detailed pseudocode or step-by-step instructions to show your thought process.
|
||||
|
||||
2. **Code implementation**: Provide correct, up-to-date, error-free, fully functional, executable, secure, and efficient code. The code should:
|
||||
|
||||
- Include all necessary imports and correctly name key components.
|
||||
- Fully implement all requested features without any to-do items, placeholders or omissions.
|
||||
* Include all necessary imports and correctly name key components.
|
||||
* Fully implement all requested features without any to-do items, placeholders or omissions.
|
||||
|
||||
3. **Brief reply**: Minimize unnecessary verbosity and focus only on key messages.
|
||||
|
||||
- If there is no correct answer, please point it out. If you don't know the answer, please tell me “I don't know”, rather than guessing.
|
||||
* If there is no correct answer, please point it out. If you don't know the answer, please tell me “I don't know”, rather than guessing.
|
||||
|
Reference in New Issue
Block a user