ios - React Native SVG - (iOS) 不变违规 : Native component for "RNSVGSvgView" does not exist

标签 ios svg react-native react-native-ios

我在使用 iOS 模拟器上运行的 React Native 的 SVG 库时遇到问题。

enter image description here

"dependencies": { 
     "better-fetch": "^1.1.2", 
     "firebase": "^4.8.1", 
     "lodash": "^4.17.4", 
     "react": "16.0.0", 
     "react-native": "0.51.0", 
     "react-native-svg": "^6.0.1-rc.1", 
     "react-redux": "^5.0.6", 
     "redux": "^3.7.2", 
     "redux-logger": "^3.0.6", 
     "redux-thunk": "^2.2.0" 
}

我试过以下方法都没有用:

npm install react-native-svg --save //(again)
react-native link react-native-svg //(again)
watchman watch-del-all
rm -rf node_modules/ && yarn cache clean && yarn install

enter image description here

最佳答案

图像显然表明问题出在链接中。因此,如果自动链接对您不起作用,可以尝试手动链接。 IOS 设备缺少手动链接指南;但是,IOS 缺少它。

但您可以按照以下步骤在 IOS 上进行手动链接:

  1. 在 XCode 中打开您的项目

  2. 转到 .../node_modules/react-native-svg/ios

  3. 找到文件 RNSVG.xcodeproj 并将其拖到 XCode 中显示的库目录中。

  4. 展开您刚刚添加的文件 (RNSVG.xcodeproj),直到您看到 libRNSVG.a,它位于 RNSVG.xcodeproj > Products)

  5. libRNSVG.a 拖到 Link Binary With Libraries 部分(位于 Build Phases 中,可在 XCode 窗口顶部找到)

现在你可以开始了:)

关于ios - React Native SVG - (iOS) 不变违规 : Native component for "RNSVGSvgView" does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48120430/

相关文章:

ios - 来自 locationManager didUpdateLocations 的 CLLocationCoordinates

SVG - 弧形动画跳跃步骤

react-native - 如何定位 React Native Picker 的下拉菜单

javascript - React Native : Background image loads as the last component, 尽管它是先添加的

javascript - 在 iOS 模拟器上测试 Web 应用程序

iphone - b2 body 问题

ios - 当 extendedLayoutIncludesOpaqueBars 设置为 true 时,UICollectionView 不工作

javascript - 在 RaphaelJS 中自定义饼图

graphics - 用于构建动态图表的最佳网络技术

react-native - 如何检查项目的 native 版本?