【发布时间】:2017-03-15 01:44:44
【问题描述】:
【问题讨论】:
-
我建议在应用任何更改之前清理您的项目并尝试运行它,因为在我的情况下也会发生同样的事情。我只是清理我的项目并运行它,它就可以工作了。
-
你绝对应该改变正确的答案! @mark 的答案是正确的,每个人都为之而来。
标签: ios xcode react-native
【问题讨论】:
标签: ios xcode react-native
https://github.com/facebook/react-native/blob/v0.63.3/template/ios/Podfile
用您的项目名称查找/替换HelloWorld。
将此文件放入项目中的./ios 文件夹中
gem install cocoapods
cd ios
pod install
然后在XCode中打开YourProject.xcworkspace文件
在 XCode 中,转到 Product -> Scheme -> Manage Schemes 并检查 React
然后再次尝试构建项目。
【讨论】:
最佳解决方案:
在 Xcode 中为您的项目打开“构建设置”,搜索“标题搜索路径”。
双击“标题搜索路径”旁边的其他属性有“是”或“否”的地方
现在将以下内容添加到“标题搜索路径”(在构建设置下):
$(SRCROOT)/../node_modules/react-native/React
$(SRCROOT)/../node_modules/react-native/React/Base
不要忘记让它们都递归。
【讨论】:
我正在使用 React Native 0.61。我创建了一个共享扩展并收到此错误。我需要更换:
#import "RCTBundleURLProvider.h"
与
#import "React/RCTBundleURLProvider.h"
【讨论】:
替我替换
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
通过
#import <RCTBundleURLProvider.h>
#import <RCTRootView.h>
在 AppDelegate.m 文件中工作。
【讨论】:
就我而言,我无法删除 node_modules 并重新安装,我也无法执行 react-native-git-updgrade 或 react-native upgrade,因为我想继续使用 RN-0.59,因为 .60 会导致我的依赖项出现问题。
无论如何,我的情况是我缺少“React/RCTBundleURLProvider.h”文件。我的模式中已经有 React 可用。它不在我的库目录中。我检查了我的 target 的构建设置。
在目标依赖项中,我也有 React。
我删除了“React”目标依赖项,然后重新添加。清理构建文件夹,重新构建项目。成功了。
【讨论】:
单击产品->方案->管理方案->+ 。然后将反应添加为共享。还要确保您的项目名称也在那里。
【讨论】:
安装 pod 后,您可能正在运行 .xcodeproj 文件。
关闭它并打开.xcworkspace 文件。它对我有用。
【讨论】:
对于我在 ReactNative "0.54.2" 中的情况,我使用以下解决方案解决了它
在 Xcode 中选择 Product->Scheme->Manage Schemes,取消勾选“YourProject”-tvOS 将其设置为不共享
【讨论】:
上面提到的所有答案我都看完了。
这是对我有用的解决方案:
第 1 步:
运行:
npm install react-native-fcm --save
这导致在您的项目中创建目录 node_modules > react-native-fcm
第 2 步:
您需要将'$(SRCROOT)/../node_modules/react-native-fcm/ios' 添加到
构建设置中的标头搜索路径。
这两个步骤帮助我消除了错误。
更多详情,您可以通过以下链接:
【讨论】:
在您的项目目录中运行npm install 以安装react-native 解决此错误。
【讨论】:
我尝试了所有建议,但没有一个在我删除存储库并再次克隆它时对我有用,所以我的建议是提交您的更改备份它们并再次克隆对我有用的存储库。
【讨论】:
确保您的项目的路径没有任何空格。 只需重命名文件夹和删除空格就可以解决我的问题。
【讨论】:
我在第一次尝试在 XCode 中运行 React 构建后遇到了这个问题,我所要做的就是构建并运行以消除错误(在选择团队并正确配置之后)。有时 XCode 显示的错误在第一次编译和链接之前并不是真正的错误。
【讨论】:
【讨论】:
react,有什么想法吗?
xcode Product->Scheme->Manage Schemes 点击Target处的'+'选择“React”并设置React是共享的。
【讨论】:
尝试以下方法:
【讨论】:
我遇到了同样的问题,我通过将 RNFIRMessaging.h 放在 React/RCTBundleURLProvider.h
上方来解决它所以看起来我会是这样的:
#import "AppDelegate.h"
#import "RNFIRMessaging.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
【讨论】:
我发现我在升级 React 后解决这个问题的方法是将 #import "RCTBundleURLProvider.h" 的声明更改为 #import <React/RCTBundleURLProvider.h>
【讨论】:
对于所有使用 React Native 0.40.0 或更高版本的用户,Header Imports 与 RN 0.40.0 相比发生了重大变化,并导致大量 .h 文件没有发现错误。 react-native-git-upgrade 在调试时为我解决了这个问题,但在发布/归档中构建失败。
我将 RN 0.42.3 与 cocoapods 和 Xcode 8.2.1
一起使用要彻底解决这个问题,请转到 Xcode>Product>Scheme>Edit Scheme>
现在清理项目并构建
【讨论】:
其他建议都没有解决我的错误,但这个解决了。
在您的 react-native 应用程序中创建一个名为 ios/Podfile 的文件,其内容如下:
# You Podfile should look similar to this file. React Native currently does not support use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target '<YOUR_APP_NAME>' do
# Fixes required for pod specs to work with rn 0.42
react_native_path = "../node_modules/react-native"
pod "Yoga", :path => "#{react_native_path}/ReactCommon/yoga"
pod "React", :path => react_native_path, :subspecs => [
'Core',
'RCTActionSheet',
'RCTAnimation',
'RCTGeolocation',
'RCTImage',
'RCTLinkingIOS',
'RCTNetwork',
'RCTSettings',
'RCTText',
'RCTVibration',
'RCTWebSocket'
]
pod 'GoogleMaps' # <~~ remove this line if you do not want to support GoogleMaps on iOS
# when not using frameworks we can do this instead of including the source files in our project (1/4):
# pod 'react-native-maps', path: '../../'
# pod 'react-native-google-maps', path: '../../' # <~~ if you need GoogleMaps support on iOS
end
从 ios 文件夹中运行命令pod install。
重新启动 XCode,错误应该消失了。
【讨论】:
删除节点模块,然后运行npm install(或更好的yarn)并在所有内容完成下载后运行react-native upgrade,它应该让您可以选择用模板文件替换旧文件,这样做您可以重新在 react-native 中链接您的本机依赖项,这应该可以解决您的问题。当然不要忘记在 Xcode 中清理你的项目。
【讨论】:
react-native upgrade 之后,我的所有构建设置都被删除了。
在我运行的项目的基本目录中:
node_modules/react-native/packager/packager.sh --reset-cache
导致:
Scanning 554 folders for symlinks in /Users/..../work/..../react_tutorial/AwesomeProject/node_modules (15ms)
┌────────────────────────────────────────────────────────────────────────────┐
│ Running packager on port 8081. │
│ │
│ Keep this packager running while developing on any JS projects. Feel │
│ free to close this tab and run your own packager instance if you │
│ prefer. │
│ │
│ https://github.com/facebook/react-native │
│ │
└────────────────────────────────────────────────────────────────────────────┘
Looking for JS files in
/Users/..../work/...../react_tutorial/AwesomeProject
Loading dependency graph... ERROR Packager can't listen on port 8081
Most likely another process is already using this port
Run the following command to find out which process:
lsof -i :8081
我发现当另一个打包器进程正在运行时,包管理器无法运行。
我发现进程正在运行:
lsof -i :8081
比我kill 9 ...这个过程。
在我关闭 Xcode 之后,运行:
npm install
然后再次启动 Xcode,从这一刻起一切正常!!
【讨论】:
你需要安装 react native, 在终端运行中
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
然后
brew install node
brew install watchman
npm install -g react-native-cli
来源:
https://facebook.github.io/react-native/docs/getting-started.html
【讨论】:
如果你没有运行npm install,你很可能会遇到这个问题。
【讨论】:
我遇到了同样的问题。然后我删除了节点。尝试使用这些步骤
然后进行构建并查看
【讨论】: