调试

工程开发 社区

技能解读

当前原文的自动摘译,尚未人工审校。

对于构建失败

运行构建并捕获错误:识别失败的文件和错误类型读取失败的文件和周围的上下文此代码库中的常见根本原因:缺少模块:检查 Modules/Package.swift 目标依赖项

对于测试失败

运行特定的失败测试(目标测试直接需要xcodebuild): 读取测试文件并了解其期望内容 读取正在测试的实现文件 检查模拟类设置 常见测试失败模式:

流狐档案 运行与权限由流狐静态检查推断,不代表作者声明或实际测试结果。
领域
工程开发
作者声明的智能体
未找到明确声明;不据此推断已兼容或已测试
静态检查
94 / 100 · 启发式扫描,不代表运行安全
运行环境证据
未执行;当前没有隔离运行测试证据
作者 / 版本 / 许可证
@woocommerce · GPL-2.0
上下文用量评级
低消耗
接入复杂程度
需简单配置
是否需要外部接口密钥
不需要
兼容的系统
未声明(默认跨平台)
运行环境要求
未检出明确要求
检测到的文件与系统行为
  • 只读
  • 允许写入 / 修改
  • 命令执行
网络行为
仅限本地
安装命令数
无(仅作为资料)

需要注意: 未声明工具权限范围;实际权限由运行环境决定。

作者说明文件(原文) SKILL.md

Debug a build failure or test failure in the WooCommerce iOS project.

## For Build Failures

1. Run the build and capture errors:
```bash
bundle exec fastlane build_for_testing 2>&1 \
  | grep -E "error:|fatal|cannot find|undefined|ambiguous" | head -30
```

2. Identify the failing file and error type
3. Read the failing file and surrounding context
4. Common root causes in this codebase:
   - **Missing module**: Check Modules/Package.swift target dependencies
   - **Type mismatch**: A Networking model changed — check if Yosemite/Storage need updates
   - **Cannot find type**: May need `bundle exec rake generate` after adding GeneratedCopiable/Fakeable
   - **Ambiguous reference**: Duplicate type names across Networking vs Storage
   - **CoreData model errors**: Check Storage/CoreData/ model versions
5. Propose or apply the fix

## For Test Failures

1. Run the specific failing test (targeted tests require `xcodebuild` directly):
```bash
xcodebuild -workspace WooCommerce.xcworkspace -scheme WooCommerce \
  -destination 'platform=iOS Simulator,name=iPhone 16' \
  -sdk iphonesimulator test \
  -only-testing:"<target>/<class>/<method>" 2>&1 | tail -50
```

2. Read the test file and understand what it expects
3. Read the implementation file being tested
4. Check the mock class setup
5. Common test failure patterns:
   - **Assertion mismatch**: Verify expected vs actual, check mock stub values
   - **Async timeout**: Check if mock callbacks are being invoked, verify continuation setup
   - **Nil unwrap**: Check if mock return values are configured
   - **Wrong mock state**: Verify spy properties are set correctly
   - **CoreData errors**: Ensure InMemoryStorage is used, not persistent storage
   - **Missing @MainActor**: Some tests need MainActor annotation
6. Propose or apply the fix

If the simulator destination fails, run `xcrun simctl list devices available` to discover available simulators, then re-run with a matching device name.

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。