本机链接和cocoapods之间的区别? [英] difference between react-native link and cocoapods?

查看:75
本文介绍了本机链接和cocoapods之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

react-native链接的作用是什么?

https://github.com/react-native-community/react-native-svg 文档说可以做到

react-native link react-native-svg

是否与

pod 'RNSVG', :path => '../node_modules/react-native-svg'  
# pod install 


推荐答案

Cocoapods是iOS的依赖项管理器。就像npm用于JavaScript(更具体地说是Node.js)项目一样。

Cocoapods is the dependency manager for iOS. Just like npm is for JavaScript (more specifically Node.js) projects.

让我们切换示例以使用 react-native-device-info

Let's switch the example to use react-native-device-info.

该项目要求您创建以下内容或将其添加到 Podfile

The project asks for you to create or add the following to a Podfile (if you're linking manually).

pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'

这将添加 RNDeviceInfo 作为iOS依赖项,它将在'../ node_modules / react-native-device-info'的内部进行获取。更具体地说,它将查找 .podspec 文件。

This will add RNDeviceInfo as an iOS dependency and will look inside of '../node_modules/react-native-device-info' to get it. More specifically it'll look for the .podspec file.

如果您查看.podspec文件,则会看到类似

If you take a look at the .podspec file, you'll see something like

s.source_files = RNDeviceInfo / *。{h,m} 。文件要做的就是获取匹配的源( RNDeviceInfo.h RNDeviceInfo.m )并存储它们在 RNDeviceInfo 目录中。我认为(总猜测),目录名称匹配 s.name

s.source_files = "RNDeviceInfo/*.{h,m}". All the file is going to do is grab the matching sources (RNDeviceInfo.h and RNDeviceInfo.m) and store them inside of RNDeviceInfo directory. I think (total guess), the directory name matches s.name.

react -native链接... 有效地自动执行相同的操作。我引用了React文档:

react-native link ... effectively does the same thing, automatically. I quote from React docs:


链接您的本地依赖项: react-native链接
完成!所有具有本机依赖项的库都应成功链接到您的iOS / Android项目。

Link your native dependencies: react-native link Done! All libraries with native dependencies should be successfully linked to your iOS/Android project.

使用<$ c $都可以达到相同的结果c> react-native链接将自动链接本机库。

Both accomplish the same result, using react-native link will automate the linking of native libraries.

这篇关于本机链接和cocoapods之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆