You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native iOS项目Xcode构建成功但模拟器无法启动求助

Fixing React Native iOS Simulator Not Launching from Xcode (Works via Terminal)

Hey there, let's skip the tedious Xcode reinstall for now—your Swift projects work perfectly, so Xcode itself is likely fine. Let's walk through targeted fixes to get your React Native app launching from Xcode:

1. Make Sure Xcode Command Line Tools Match Your Active Xcode Version

  • Open Xcode, go to Preferences > Locations
  • Under Command Line Tools, confirm the selected version matches the Xcode you're using (no old/beta builds left selected by mistake)
  • Cross-check in terminal: Run xcode-select -p—if the path doesn't match /Applications/Xcode.app/Contents/Developer, fix it with:
    sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
    

2. Double-Check Your React Native Project's Xcode Setup

  • Always open .xcworkspace not .xcodeproj: React Native relies on CocoaPods, so opening the raw project file can cause missing dependencies or runtime blocks
  • Verify your Scheme: Go to Product > Scheme > Manage Schemes, make sure your main app scheme is marked Shared and selected
  • Switch simulators: Sometimes a specific simulator gets stuck in a broken state—try picking a different device (e.g., iPhone 14 instead of iPhone 15) from Xcode's top device selector

3. Dig Into Xcode's Hidden Run Logs

Build success doesn't guarantee runtime success. Head to the Report Navigator (left sidebar, 4th icon) to check the latest run attempt. Look for easy-to-miss errors like:

  • Unconfigured permission requests (e.g., camera/photos access not added to Info.plist)
  • Silent script execution failures (they might not break the build, but can block simulator launch)

4. Reset React Native Caches and Dependencies

  • Clear Metro's cache first:
    npx react-native start --reset-cache
    
  • Reinstall CocoaPods to fix dependency mismatches:
    cd ios
    pod deintegrate
    pod install
    
  • Close Xcode completely, then reopen the .xcworkspace and try running again

5. Fix a Misbehaving Simulator

  • Fully reset the simulator: Open Simulator → go to Device > Erase All Content and Settings..., then restart the simulator
  • Delete and recreate broken simulators:
    1. Run xcrun simctl list devices in terminal to list all devices and their IDs
    2. Delete any device marked "unavailable" or acting odd: xcrun simctl delete <DEVICE_ID>
    3. Create a new simulator via Xcode's Window > Devices and Simulators

6. Check React Native's Build Script Configuration

  • Open your project in Xcode, navigate to Build Phases > Bundle React Native code and images
  • Ensure the NODE_BINARY path is correct. If you use a node version manager (nvm, fnm), update the script to point to your active node path:
    export NODE_BINARY=$(which node)
    
    (Replace the existing export NODE_BINARY=node line)

If none of these work, reinstalling Xcode can be a last resort—but try reinstalling just the command line tools first with xcode-select --install before doing a full Xcode reinstall.

内容的提问来源于stack exchange,提问作者Silentboy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 16:52:35