mobile-app-debugging

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Mobile App Debugging

移动应用调试

Debug mobile applications across iOS, Android, and cross-platform frameworks.
针对iOS、Android及跨平台框架调试移动应用。

iOS Debugging (Xcode)

iOS调试(Xcode)

swift
// Breakpoint with condition
// Right-click breakpoint > Edit > Condition: userId == "123"

// LLDB commands
po variable          // Print object
p expression         // Evaluate expression
bt                   // Backtrace
swift
// Breakpoint with condition
// Right-click breakpoint > Edit > Condition: userId == "123"

// LLDB commands
po variable          // Print object
p expression         // Evaluate expression
bt                   // Backtrace

Memory Debugging

内存调试

  • Use Memory Graph Debugger to find retain cycles
  • Enable Zombie Objects for use-after-free bugs
  • Profile with Instruments > Leaks
  • 使用Memory Graph Debugger查找循环引用
  • 启用Zombie Objects检测野指针错误
  • 使用Instruments > Leaks进行性能分析

Android Debugging (Android Studio)

Android调试(Android Studio)

kotlin
// Logcat filtering
Log.d("TAG", "Debug message")
Log.e("TAG", "Error", exception)

// Filter: tag:MyApp level:error
kotlin
// Logcat filtering
Log.d("TAG", "Debug message")
Log.e("TAG", "Error", exception)

// Filter: tag:MyApp level:error

Common Issues

常见问题

  • ANR: Check main thread blocking
  • OOM: Profile with Memory Profiler
  • Layout issues: Use Layout Inspector
  • ANR:检查主线程阻塞情况
  • OOM:使用Memory Profiler进行分析
  • 布局问题:使用Layout Inspector

React Native

React Native

javascript
// Remote debugging
// Shake device > Debug JS Remotely

// Console logging
console.log('Debug:', variable);
console.warn('Warning');
console.error('Error');

// Performance Monitor
// Shake > Show Perf Monitor
// Target: 60 FPS, <16ms per frame
javascript
// Remote debugging
// Shake device > Debug JS Remotely

// Console logging
console.log('Debug:', variable);
console.warn('Warning');
console.error('Error');

// Performance Monitor
// Shake > Show Perf Monitor
// Target: 60 FPS, <16ms per frame

Network Debugging

网络调试

javascript
// Intercept requests
XMLHttpRequest.prototype._send = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function() {
  console.log('Request:', this._url);
  this._send.apply(this, arguments);
};
javascript
// Intercept requests
XMLHttpRequest.prototype._send = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function() {
  console.log('Request:', this._url);
  this._send.apply(this, arguments);
};

Debug Checklist

调试检查清单

  • Test on physical devices (not just simulators)
  • Test on older device models
  • Simulate slow 3G network
  • Test offline mode
  • Check memory under load
  • Test rotation and safe areas
  • Verify 60 FPS target
  • 在物理设备上测试(不只是模拟器)
  • 在旧型号设备上测试
  • 模拟慢速3G网络
  • 测试离线模式
  • 检查高负载下的内存情况
  • 测试屏幕旋转和安全区域
  • 验证60 FPS目标

Performance Targets

性能指标目标

MetricTarget
Frame rate60 FPS (16ms/frame)
Memory<100MB
App launch<2 seconds
指标目标值
帧率60 FPS(每帧<16ms)
内存占用<100MB
应用启动时间<2秒