[英]Can't run react native project for ios
我正在開發 react native 應用程序,我是 react-native 的新手,首先我為 android 平台工作並成功構建了 apk 文件。 現在我想使用我的 mackbook 中的命令react-native run-ios為 ios 版本運行它,但它會引發錯誤:
注意:從一開始我就在 macbook 上開發了這個應用程序
user-MacBook-Pro:myApp user$ react-native run-ios
error Cannot read property 'podfile' of null. Run CLI with --verbose flag for more details.
TypeError: Cannot read property 'podfile' of null
at warnAboutPodInstall (/Users/user/project/myApp/node_modules/@react-native-community/cli-platform-ios/build/link/warnAboutPodInstall.js:43:90)
at Object.runIOS [as func] (Users/user/project/myApp/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js:80:36)
at Command.handleAction (Users/user/project/myApp/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:164:23)
at Command.listener (Users/user/project/myApp/node_modules/commander/index.js:315:8)
at Command.emit (events.js:198:13)
at Command.parseArgs (Users/user/project/myApp/node_modules/commander/index.js:651:12)
at Command.parse (Users/user/project/myApp/node_modules/commander/index.js:474:21)
at setupAndRun (Users/user/project/myApp/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:237:24)
at Object.run (Users/user/project/myApp/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:184:11)
at Object.<anonymous> (/usr/local/lib/node_modules/react-native-cli/index.js:117:7)
播客文件
platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
target 'myApp' do
# Pods for myApp
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/'
pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
target 'myAppTests' do
inherit! :search_paths
# Pods for testing
end
use_native_modules!
end
target 'myApp-tvOS' do
# Pods for myApp-tvOS
target 'myApp-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
請幫助我知道解決方案的人。 提前致謝。
首先你需要了解 React Native 的基礎知識。 你可以從 這里查看如何在設備上運行 React Native 項目的官方說明
但是在 iOS 上運行應用程序之前你需要做一些額外的事情
吊艙安裝
如果您需要更多關於 cocoapods 的信息,請訪問這里
之后打開 XCODE 並導航到ios文件夾並打開擴展名為 .xcworkspace 的項目文件
我的項目.xcworkspace
在終端中,從您的頂級項目目錄運行以下命令:
cd ios <-- 進入你的 ios 子目錄 ls
您應該會看到一個名為“Podfile”的文件,如下所示:
drwxr-xr-x 8 r 員工 256 Sep 21 14:04 AwesomeTSProject -rw-r--r-- 1 r 員工 749 Sep 21 14:04 Podfile
接下來運行以下命令:
吊艙安裝
您應該看到創建的文件如下:
drwxr-xr-x 4 r 員工 128 Sep 21 14:04 AwesomeTSProjectTests drwxr-xr-x@ 5 r 員工 160 Sep 21 14:22 AwesomeTSProject.xcworkspace drwxr-xr-x 10 r 員工 320 Sep 29 10:00 。 drwxr-xr-x@ 4 r 員工 128 Sep 29 10:19 AwesomeTSProject.xcodeproj -rw-r--r-- 1 r 員工 19077 Sep 29 10:19 Podfile.lock -rw-r--r--@ 1 r 員工 6148 9 月 30 日 04:00 .DS_Store drwxr-xr-x 26 r 員工 832 1 月 9 日 09:01 豆莢 drwxr-xr-x 25 r 員工 800 1 月 9 日 09:42 ..
只要您沒有看到任何錯誤,您現在就可以運行以下命令:
光盤..
您應該會從 ios 文件夾中彈出並向上移動到您的父項目目錄。
npx react-native run-ios
如果一切順利,您應該會在您的 App 中看到一個 iOS 模擬器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.