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

指定.xcworkspace执行react-native run-ios失败,现如何用Cocoapods命令行运行?

Hey there, I get that frustration—trying to specify your .xcworkspace directly with react-native run-ios only to hit that "Could not find Xcode project files" error is a bummer, especially since official support for this is still on the roadmap. But don’t worry, there are a few solid workarounds to get you running your React Native project with Cocoapods via the command line right now:

1. Use xcodebuild directly (the most straightforward command-line approach)

Skip the React Native CLI altogether and use Xcode’s native command-line tool to target your workspace. Here’s a command that builds and runs your app on the iPhone 8 Plus simulator:

xcodebuild -workspace ios/myProject.xcworkspace -scheme myProject -destination 'platform=iOS Simulator,name=iPhone 8 Plus' build &&
xcrun simctl install booted ios/build/Build/Products/Debug-iphonesimulator/myProject.app &&
xcrun simctl launch booted com.yourcompany.myProject

Just make sure to replace myProject with your actual scheme name, and com.yourcompany.myProject with your app’s bundle identifier.

The React Native CLI looks for a workspace or project file in the ios directory that matches your root project’s name. If your workspace is named differently (like myProject.xcworkspace instead of [RootProjectName].xcworkspace), create a symbolic link to match what the CLI expects:

cd ios
ln -s myProject.xcworkspace [YourRootProjectName].xcworkspace

Replace [YourRootProjectName] with the name of your React Native root project folder. Once you’ve done this, you can use the standard react-native run-ios command without issues:

react-native run-ios --simulator="iPhone 8 Plus"

3. Use a custom shell script for repeatability

If you want a reusable command without modifying files or dealing with symlinks, create a simple shell script in your project root. Name it something like run-ios-custom.sh:

#!/bin/bash
# Build the app via the workspace
xcodebuild -workspace ios/myProject.xcworkspace -scheme myProject -destination 'platform=iOS Simulator,name=iPhone 8 Plus' build
# Install the app to the booted simulator
xcrun simctl install booted ios/build/Build/Products/Debug-iphonesimulator/myProject.app
# Launch the app
xcrun simctl launch booted com.yourcompany.myProject

Then make it executable:

chmod +x run-ios-custom.sh

Now you can run your app anytime with:

./run-ios-custom.sh

All these are temporary workarounds, but they’ll get you up and running until the official --project-path support for workspaces lands.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.22 08:26:27