【发布时间】:2019-09-19 15:01:08
【问题描述】:
如果我没有遇到很多问题,并且如果我没有花几天时间尝试在 React Native 中正确链接库,我就不会在这里发帖。大多数情况下我没有遇到问题,但这个特殊的库似乎几乎是不可能的。
https://github.com/jerson/react-native-palette-full
这是我的代码,非常基础:
import Palette from "react-native-palette-full";
componentDidMount() {
Palette.getAllSwatchesFromUrl(this.state.merchant.coverPhoto);
}
正是您对图书馆说明的期望。
相反,我得到了这个:
我试过手动链接:
react-native link react-native-palette-full
我已经尝试了这些手动安装说明:
In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name]
Go to node_modules ➜ react-native-palette-full and add RNPalette.xcodeproj
In XCode, in the project navigator, select your project. Add libRNPalette.a to your project's Build Phases ➜ Link Binary With Libraries
Go to Podfile and add "SDWebImage", "~>4.3.3"
Run your project (Cmd+R)<
这只会导致找不到 RNPalette,尽管该项目就在我的 Xcode 库下。
如何解决此问题并使其正常工作?我简直是在扯头发——我想做的就是从图像中获取颜色样本,而这在 React Native 中似乎几乎是不可能的。
我在注册护士 .60
编辑:
我一直在尝试手动链接,但无论我尝试什么,我都一直收到错误,即找不到 ImageLoader:
#import <React/RCTImageLoader.h> 'React/RCTImageLoader.h' file not found
我也尝试将它作为依赖项添加到库中的 podspec 文件中:
Pod::Spec.new do |s|
s.name = "RNPalette"
s.version = "1.0.0"
s.summary = "RNPalette"
s.description = <<-DESC
Info about colors from images or url, compatible with **Android** and **iOS**
DESC
s.homepage = "https://github.com/jerson/react-native-palette-full"
s.license = "MIT"
# s.license = { :type => "MIT", :file => "FILE_LICENSE" }
s.author = { "author" => "jeral17@gmail.com" }
s.platform = :ios, "7.0"
s.source = { :git => "https://github.com/jerson/react-native-palette-full.git", :tag => "master" }
s.source_files = "RNPalette/**/*.{h,m}"
s.requires_arc = true
s.dependency "React"
s.dependency "SDWebImage", "~>4.3.3"
s.dependency 'React-Core'
s.dependency 'React-RCTImage'
end
如何链接这个库?有什么办法吗?
编辑:在尝试以下建议之一时,我收到以下错误消息:
【问题讨论】:
标签: javascript xcode react-native