背景
公司打算做App,但其实我们前端组都没有相关App经验,只能摸着石头过河了,跌跌撞撞到现在,总算是ios提交审核了,因为ios审核目前已被拒两次,目前还在审核中,想把整个过程整理出来,记录遇到的问题和解决办法
初始demo搭建
下载时按照文档中的国内下载链接指示一步步操作,在init项目的时候出现问题
不过现在官网提供了相关镜像,真的太好了
$ pod repo remove master
$ pod repo add master https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
$ pod repo update
$ cd ~/.cocoapods/repos
$ pod repo remove master
$ git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
项目构建完成后根据下图提示启动
cd AwesomeProject
react-native run-ios
项目启动
若启动报错,可以先尝试以下解决办法
下载后一直报错,最终解决办法是: 关掉所有终端,打开只打开一个终端,打开到我们对应的项目,执行npm start 然后在点击项目下的 ios/test.xcodeproj in Xcode
关于RN自带webview与react-native-webview
我们的项目用到了webview,因为在启动时有warnning,找到文章如下
依次执行下面两行代码再次重新启动
$ yarn add react-native-webview
$ react-native link react-native-webview
import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { WebView } from 'react-native-webview';
// ...
class MyWebComponent extends Component {
render() {
return (
<WebView source={{ uri: 'https://facebook.github.io/react-native/' }} />
);
}
}
ios真机调试报错
先检查以下两项: