android-to-ios
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAndroid to iOS: Feature Parity Implementation
Android 转 iOS:功能一致性实现
Use Android code as the reference to implement the equivalent iOS feature. Not a literal translation - understand what the Android code does, then implement it idiomatically for iOS.
Use this when:
- Porting a feature from Android to iOS
- Android is the "source of truth" for a feature
- Ensuring feature parity between platforms
以Android代码为参考,在iOS中实现等效功能。并非字面翻译——先理解Android代码的作用,再以符合iOS开发习惯的方式实现。
适用场景:
- 将功能从Android移植到iOS
- Android是某功能的基准实现
- 确保跨平台功能一致性
Key Principle
核心原则
Android Code → Understand Feature → Match iOS Codebase Patterns → Implement
(what) (how it's done here)Preserved: Feature behavior, data structure shapes, business logic, user flows
Adapted: Language idioms, frameworks, patterns to match the iOS codebase
Android Code → Understand Feature → Match iOS Codebase Patterns → Implement
(what) (how it's done here)需保留: 功能行为、数据结构形态、业务逻辑、用户流程
需适配: 语言习惯、框架、模式,以匹配iOS代码库
Workflow
工作流程
Step 0: Gather Context
步骤0:收集上下文
Ask the user for both pieces of information:
To port a feature from Android to iOS, I need:
1. PATH TO ANDROID CODEBASE (source of truth)
Where is the Android project located?
Example: /path/to/android-app or ../android-app
2. FEATURE TO IMPLEMENT
What feature or component should I port?
Example: "UserProfile screen" or "the authentication flow" or "app/src/main/java/features/checkout"Assumptions:
- Current working directory = iOS codebase (target)
- User provides path to Android codebase (source)
If the user already provided this info, proceed. Otherwise, ask.
向用户询问以下两项信息:
To port a feature from Android to iOS, I need:
1. PATH TO ANDROID CODEBASE (source of truth)
Where is the Android project located?
Example: /path/to/android-app or ../android-app
2. FEATURE TO IMPLEMENT
What feature or component should I port?
Example: "UserProfile screen" or "the authentication flow" or "app/src/main/java/features/checkout"假设条件:
- 当前工作目录为iOS代码库(目标端)
- 用户提供Android代码库的路径(源端)
若用户已提供上述信息,直接继续;否则,先询问获取。
Step 1: Locate the Android Feature
步骤1:定位Android端功能
Navigate to the Android codebase path and find the relevant files:
- Go to the Android path provided
- Find files related to the feature
- Read and understand the implementation
导航至Android代码库路径,找到相关文件:
- 进入用户提供的Android路径
- 找到与目标功能相关的文件
- 阅读并理解其实现逻辑
Step 2: Analyze the Android Code
步骤2:分析Android代码
Thoroughly understand:
| Aspect | What to Extract |
|---|---|
| Feature Behavior | What does this feature do? User-facing functionality |
| Data Structures | Models, types, sealed classes - their shapes and relationships |
| Business Logic | Core logic, validations, transformations |
| State Management | What state exists, how it flows |
| API Contracts | Network calls, request/response shapes |
| UI Flow | Screens, navigation, user interactions |
| Edge Cases | Error handling, loading states, empty states |
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ANDROID FEATURE ANALYSIS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━需全面理解以下内容:
| 维度 | 需提取的信息 |
|---|---|
| 功能行为 | 该功能的用户侧实际表现 |
| 数据结构 | 模型、类型、密封类的形态及关系 |
| 业务逻辑 | 核心逻辑、校验规则、数据转换逻辑 |
| 状态管理 | 存在哪些状态,以及状态流转方式 |
| API协议 | 网络请求、请求/响应的结构 |
| UI流程 | 页面、导航、用户交互逻辑 |
| 边缘场景 | 错误处理、加载状态、空状态 |
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ANDROID FEATURE ANALYSIS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━Feature: [Name]
Feature: [Name]
What It Does
What It Does
[User-facing description]
[User-facing description]
Data Structures
Data Structures
[Key models and their relationships]
[Key models and their relationships]
Business Logic
Business Logic
[Core logic summary]
[Core logic summary]
State
State
[What state is managed, how it changes]
[What state is managed, how it changes]
API Calls
API Calls
[Endpoints, request/response shapes]
[Endpoints, request/response shapes]
UI Flow
UI Flow
[Screens, navigation]
[Screens, navigation]
Edge Cases Handled
Edge Cases Handled
- [Case 1]
- [Case 2]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
undefined- [Case 1]
- [Case 2]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
undefinedStep 3: Analyze iOS Codebase Patterns
步骤3:分析iOS代码库模式
Before implementing, understand how THIS iOS codebase does things:
- Check if exists - If yes, use it and skip manual analysis
.claude/codebase-style.md - Find similar features in the codebase
- Note the patterns used:
- Architecture pattern
- UI framework and patterns
- State management approach
- Networking approach
- Dependency injection
- File/folder organization
- Naming conventions
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
iOS CODEBASE PATTERNS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Style Guide: [Found / Not found]
Patterns observed from existing code:
- Architecture: [what pattern is used]
- UI: [how UI is built]
- State: [how state is managed]
- Networking: [how API calls are made]
- DI: [how dependencies are injected]
- Navigation: [how navigation works]
Similar features to reference:
- [Feature 1]: [path]
- [Feature 2]: [path]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━在实现前,需了解当前iOS代码库的开发规范:
- 检查是否存在 - 若存在,直接参考该文件,跳过手动分析
.claude/codebase-style.md - 在代码库中找到类似功能
- 记录所使用的模式:
- 架构模式
- UI框架及模式
- 状态管理方案
- 网络请求方案
- 依赖注入方式
- 文件/文件夹组织方式
- 命名规范
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
iOS CODEBASE PATTERNS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Style Guide: [Found / Not found]
Patterns observed from existing code:
- Architecture: [what pattern is used]
- UI: [how UI is built]
- State: [how state is managed]
- Networking: [how API calls are made]
- DI: [how dependencies are injected]
- Navigation: [how navigation works]
Similar features to reference:
- [Feature 1]: [path]
- [Feature 2]: [path]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━Step 4: Create Implementation Plan
步骤4:制定实现计划
Map the Android feature to iOS equivalents using the patterns from Step 3:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
IMPLEMENTATION PLAN
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━结合步骤3总结的模式,将Android功能映射为iOS等效实现:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
IMPLEMENTATION PLAN
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━Files to Create
Files to Create
| # | File | Purpose | Android Equivalent |
|---|---|---|---|
| 1 | [path matching codebase conventions] | [purpose] | [Android file] |
| 2 | ... | ... | ... |
| # | File | Purpose | Android Equivalent |
|---|---|---|---|
| 1 | [path matching codebase conventions] | [purpose] | [Android file] |
| 2 | ... | ... | ... |
Key Mappings
Key Mappings
| Android Concept | iOS Equivalent (matching codebase patterns) |
|---|---|
| [Android thing] | [iOS equivalent as done in this codebase] |
| ... | ... |
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
undefined| Android Concept | iOS Equivalent (matching codebase patterns) |
|---|---|
| [Android thing] | [iOS equivalent as done in this codebase] |
| ... | ... |
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
undefinedStep 5: Implement
步骤5:实现功能
Create the iOS implementation:
- Match the codebase's existing patterns exactly
- Use the same architecture, UI patterns, state management as other features
- Follow the same naming conventions
- Keep data structure shapes equivalent for API compatibility
⚠️ IMPORTANT: After creating each file, register it with Xcode:
.swiftbash
ruby ${CLAUDE_PLUGIN_ROOT}/skills/add-to-xcode/scripts/add_to_xcode.rb <filepath>Without this step, files won't appear in Xcode or compile. See the skill.
add-to-xcode编写iOS端实现代码:
- 严格匹配代码库现有模式
- 使用与其他功能一致的架构、UI模式、状态管理方案
- 遵循相同的命名规范
- 保持数据结构形态一致,以确保API兼容性
⚠️ 重要提示:创建每个 文件后,需在Xcode中注册:
.swiftbash
ruby ${CLAUDE_PLUGIN_ROOT}/skills/add-to-xcode/scripts/add_to_xcode.rb <filepath>若跳过此步骤,文件将不会在Xcode中显示或参与编译。详情请参考 技能文档。
add-to-xcodeStep 6: Copy Assets (if needed)
步骤6:复制资源(如需要)
If the feature uses assets, offer to copy them:
Assets that may need to be copied:
- Images, icons, colors, fonts, Lottie animations, sounds, etc.
If assets are needed and the user wants them copied, use file operations to transfer them from the Android codebase to the appropriate iOS locations.
若功能涉及资源,可主动提出复制:
可能需要复制的资源包括:
- 图片、图标、颜色、字体、Lottie动画、音效等
若用户需要复制资源,通过文件操作将其从Android代码库转移至iOS代码库的对应位置。
Step 7: Report Results
步骤7:结果汇报
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ANDROID → iOS COMPLETE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ANDROID → iOS COMPLETE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━Feature: [Name]
Feature: [Name]
Files Created
Files Created
| File | Purpose |
|---|---|
| [path] | [description] |
| File | Purpose |
|---|---|
| [path] | [description] |
Feature Parity Checklist
Feature Parity Checklist
- Core functionality matches Android
- Data structures equivalent
- Error handling preserved
- Loading states preserved
- Edge cases handled
- Matches iOS codebase patterns
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
---- Core functionality matches Android
- Data structures equivalent
- Error handling preserved
- Loading states preserved
- Edge cases handled
- Matches iOS codebase patterns
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
---Triggers
触发关键词
"android to ios"
"convert from android"
"port this kotlin to swift"
"implement this android feature for ios"
"ios version of this android code""android to ios"
"convert from android"
"port this kotlin to swift"
"implement this android feature for ios"
"ios version of this android code"Integration with style-guide
与style-guide技能的集成
Recommended: Run the skill on the iOS codebase first.
style-guidestyle guide ← Run this first on iOS codebase
android to ios ← Then run thisThis generates which this skill will automatically reference.
.claude/codebase-style.mdIf style guide exists:
- Skip manual pattern analysis (Step 3)
- Reference the documented patterns directly
- Ensure perfect consistency with existing code
If no style guide:
- This skill will analyze patterns manually (Step 3)
- Consider running first for better results
style-guide
推荐流程: 先在iOS代码库上运行 技能
style-guidestyle guide ← 先在iOS代码库上运行此命令
android to ios ← 再运行此命令该命令会生成 文件,本技能将自动参考该文件。
.claude/codebase-style.md若已存在style guide:
- 跳过手动模式分析(步骤3)
- 直接参考文档中记录的模式
- 确保与现有代码完全一致
若不存在style guide:
- 本技能将手动分析代码模式(步骤3)
- 建议先运行 技能以获得更优结果
style-guide
Tips
注意事项
- Don't translate literally - Understand the feature, then implement idiomatically
- Match the codebase - Use the same patterns as existing iOS code
- Keep data shapes equivalent - API compatibility matters
- Handle platform differences - Some things work differently (lifecycle, permissions)
- Verify feature parity - Same behavior, not same code
- 不要字面翻译 - 先理解功能本质,再以符合iOS习惯的方式实现
- 匹配代码库规范 - 使用与现有iOS代码一致的模式
- 保持数据形态一致 - API兼容性至关重要
- 处理平台差异 - 部分功能的实现方式不同(如生命周期、权限)
- 验证功能一致性 - 确保行为一致,而非代码一致