美文网首页
Cocoapods 集成 React-native

Cocoapods 集成 React-native

作者: 代码的艺术 | 来源:发表于2018-07-25 12:57 被阅读32次

1、安装 react-native  和 cocoapods

2、项目中即成Cocoapods

项目根目录下执行

pod init

pod install

3、在项目根目录下创建 react 文件夹

mkdir react

4、到react目录下创建 package.json 文件

cd react

5、package.json 内容,记得删除注释

{ "name": "你的项目名", "version": "0.0.1", "private": true, "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start" },"dependencies": { // 这里填入依赖项 "react": "16.0.0", // 其实 react也是作为一个第三方库存在的 "react-native": "0.50" // 这个也是 - - 依次可以加入很多第三方库,然后使用npm install初始化,其实这里和cocoapods很相似 }}

6、在react文件夹中安装react-native

npm install

7、在react目录下创建index.js文件

/** * Sample React Native App * https://github.com/facebook/react-native * @flow */ import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, View } from 'react-native'; export default class ModuleA extends Component { render() { return ( Welcome to React Native! To get started, edit index.ios.js Press Cmd+R to reload,{'\n'} Cmd+D or shake for dev menu ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, welcome: { fontSize: 20, textAlign: 'center', margin: 10, }, instructions: { textAlign: 'center', color: '#333333', marginBottom: 5, }, }); AppRegistry.registerComponent('ModuleA', () => ModuleA);  

相关文章

网友评论

      本文标题:Cocoapods 集成 React-native

      本文链接:https://www.haomeiwen.com/subject/vpjpmftx.html