ios-to-android
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseiOS to Android: Feature Parity Implementation
iOS 转 Android:功能一致性实现
Use iOS code as the reference to implement the equivalent Android feature. Not a literal translation - understand what the iOS code does, then implement it idiomatically for Android.
Use this when:
- Porting a feature from iOS to Android
- iOS is the "source of truth" for a feature
- Ensuring feature parity between platforms
以iOS代码为参考,在Android端实现等效功能。并非字面翻译——先理解iOS代码的实际作用,再以符合Android开发习惯的方式实现。
适用场景:
- 将功能从iOS移植到Android
- iOS是某功能的“基准实现”
- 确保跨平台功能一致性
Key Principle
核心原则
iOS Code → Understand Feature → Match Android 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 Android codebase
iOS Code → 理解功能 → 匹配Android代码库模式 → 实现
(功能是什么) (此处的实现方式)需保留的内容: 功能行为、数据结构形态、业务逻辑、用户流程
需适配的内容: 语言习惯、框架、模式,以匹配Android代码库
Workflow
工作流程
Step 0: Gather Context
步骤0:收集上下文信息
Ask the user for both pieces of information:
To port a feature from iOS to Android, I need:
1. PATH TO iOS CODEBASE (source of truth)
Where is the iOS project located?
Example: /path/to/ios-app or ../ios-app
2. FEATURE TO IMPLEMENT
What feature or component should I port?
Example: "UserProfile screen" or "the authentication flow" or "src/Features/Checkout"Assumptions:
- Current working directory = Android codebase (target)
- User provides path to iOS codebase (source)
If the user already provided this info, proceed. Otherwise, ask.
向用户询问以下两项信息:
要将功能从iOS移植到Android,我需要:
1. iOS代码库路径(基准实现)
iOS项目的存储位置在哪里?
示例:/path/to/ios-app 或 ../ios-app
2. 待实现的功能
需要移植哪个功能或组件?
示例:“用户资料页面” 或 “认证流程” 或 “src/Features/Checkout”预设前提:
- 当前工作目录为Android代码库(目标端)
- 用户会提供iOS代码库路径(源端)
如果用户已提供上述信息,直接进入下一步;否则,先询问用户。
Step 1: Locate the iOS Feature
步骤1:定位iOS端功能
Navigate to the iOS codebase path and find the relevant files:
- Go to the iOS path provided
- Find files related to the feature
- Read and understand the implementation
导航至iOS代码库路径,找到相关文件:
- 进入用户提供的iOS代码路径
- 找到与目标功能相关的文件
- 阅读并理解其实现逻辑
Step 2: Analyze the iOS Code
步骤2:分析iOS代码
Thoroughly understand:
| Aspect | What to Extract |
|---|---|
| Feature Behavior | What does this feature do? User-facing functionality |
| Data Structures | Models, types, enums - 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 |
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
iOS FEATURE ANALYSIS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━深入理解以下内容:
| 维度 | 需提取的信息 |
|---|---|
| 功能行为 | 该功能的具体作用?面向用户的功能点 |
| 数据结构 | 模型、类型、枚举——它们的结构和关联关系 |
| 业务逻辑 | 核心逻辑、校验规则、数据转换 |
| 状态管理 | 存在哪些状态,状态如何流转 |
| API协议 | 网络请求、请求/响应结构 |
| UI流程 | 页面、导航、用户交互 |
| 边界情况 | 错误处理、加载状态、空状态 |
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
iOS 功能分析
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━Feature: [Name]
功能:[名称]
What It Does
功能说明
[User-facing description]
[面向用户的描述]
Data Structures
数据结构
[Key models and their relationships]
[核心模型及其关联关系]
Business Logic
业务逻辑
[Core logic summary]
[核心逻辑概述]
State
状态管理
[What state is managed, how it changes]
[管理的状态内容及变化方式]
API Calls
API调用
[Endpoints, request/response shapes]
[接口地址、请求/响应结构]
UI Flow
UI流程
[Screens, navigation]
[页面、导航方式]
Edge Cases Handled
处理的边界情况
- [Case 1]
- [Case 2]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
undefined- [情况1]
- [情况2]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
undefinedStep 3: Analyze Android Codebase Patterns
步骤3:分析Android代码库模式
Before implementing, understand how THIS Android 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
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ANDROID 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]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━在实现前,先了解当前Android代码库的开发规范:
- 检查是否存在 - 如果存在,直接参考该文件,跳过手动分析
.claude/codebase-style.md - 在代码库中找到类似功能
- 记录使用的模式:
- 架构模式
- UI框架及模式
- 状态管理方案
- 网络请求方案
- 依赖注入方式
- 文件/文件夹组织方式
- 命名规范
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Android代码库模式
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
风格指南:[已找到 / 未找到]
从现有代码中观察到的模式:
- 架构:[使用的架构模式]
- UI:[UI构建方式]
- 状态管理:[状态管理方案]
- 网络请求:[API调用方式]
- 依赖注入:[依赖注入方式]
- 导航:[导航实现方式]
可参考的类似功能:
- [功能1]:[路径]
- [功能2]:[路径]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━Step 4: Create Implementation Plan
步骤4:制定实现计划
Map the iOS feature to Android equivalents using the patterns from Step 3:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
IMPLEMENTATION PLAN
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━结合步骤3总结的模式,将iOS功能映射为Android等效实现:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
实现计划
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━Files to Create
待创建文件
| # | File | Purpose | iOS Equivalent |
|---|---|---|---|
| 1 | [path matching codebase conventions] | [purpose] | [iOS file] |
| 2 | ... | ... | ... |
| 序号 | 文件路径 | 用途 | iOS等效文件 |
|---|---|---|---|
| 1 | [符合代码库规范的路径] | [用途说明] | [iOS对应文件] |
| 2 | ... | ... | ... |
Key Mappings
核心映射关系
| iOS Concept | Android Equivalent (matching codebase patterns) |
|---|---|
| [iOS thing] | [Android equivalent as done in this codebase] |
| ... | ... |
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
undefined| iOS概念 | Android等效实现(匹配代码库模式) |
|---|---|
| [iOS相关内容] | [当前代码库中采用的Android等效实现方式] |
| ... | ... |
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
undefinedStep 5: Implement
步骤5:实现功能
Create the Android 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
编写Android端实现代码:
- 严格匹配代码库现有模式
- 使用与其他功能相同的架构、UI模式、状态管理方案
- 遵循相同的命名规范
- 保持数据结构形态一致,确保API兼容性
Step 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 iOS codebase to the appropriate Android locations.
如果功能涉及资源文件,可提供复制服务:
可能需要复制的资源包括:
- 图片、图标、颜色、字体、Lottie动画、音效等
如果需要资源且用户希望复制,通过文件操作将资源从iOS代码库转移到Android端的对应位置。
Step 7: Report Results
步骤7:报告结果
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
iOS → ANDROID COMPLETE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
iOS → Android 移植完成
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━Feature: [Name]
功能:[名称]
Files Created
创建的文件
| File | Purpose |
|---|---|
| [path] | [description] |
| 文件路径 | 用途 |
|---|---|
| [路径] | [描述] |
Feature Parity Checklist
功能一致性检查清单
- Core functionality matches iOS
- Data structures equivalent
- Error handling preserved
- Loading states preserved
- Edge cases handled
- Matches Android codebase patterns
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
---- 核心功能与iOS端匹配
- 数据结构等效
- 错误处理逻辑保留
- 加载状态保留
- 边界情况已处理
- 符合Android代码库模式
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
---Triggers
触发指令
"ios to android"
"convert from ios"
"port this swift to kotlin"
"implement this ios feature for android"
"android version of this ios code""ios to android"
"convert from ios"
"port this swift to kotlin"
"implement this ios feature for android"
"android version of this ios code"Integration with style-guide
与风格指南的集成
Recommended: Run the skill on the Android codebase first.
style-guidestyle guide ← Run this first on Android codebase
ios to android ← 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
推荐流程: 先在Android代码库上运行技能
style-guidestyle guide ← 先在Android代码库上运行此命令
ios to android ← 再运行此命令这会生成文件,本技能会自动参考该文件。
.claude/codebase-style.md如果存在风格指南:
- 跳过手动模式分析(步骤3)
- 直接参考文档中记录的模式
- 确保与现有代码完全一致
如果没有风格指南:
- 本技能会手动分析模式(步骤3)
- 建议先运行以获得更好的结果
style-guide
Tips
提示
- Don't translate literally - Understand the feature, then implement idiomatically
- Match the codebase - Use the same patterns as existing Android 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
- 不要字面翻译 - 先理解功能,再以符合Android习惯的方式实现
- 匹配代码库规范 - 使用与现有Android代码相同的模式
- 保持数据结构一致 - API兼容性很重要
- 处理平台差异 - 部分功能的实现方式不同(生命周期、权限等)
- 验证功能一致性 - 确保行为相同,而非代码相同