您的位置:首页 > Web前端 > React

React Native 学习一 搭建开发环境

2017-09-14 18:18 501 查看
参考文章
https://reactnative.cn/ http://www.jianshu.com/p/3dc9d70a790f http://www.jianshu.com/p/b88944250b25 http://www.jianshu.com/p/9211f42d5c25 http://www.cocoachina.com/ios/20170511/19250.html http://www.jianshu.com/p/978c4bd3a759
1按照https://reactnative.cn/

操作:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"[/code] 
出现需要brew更新错误信息后 ,去往目录手动删除就可以了,不要rm -rf(后果很惨痛)


输入:react-native run-ios 出现以下错误

he following build commands failed:

PhaseScriptExecution Install\ Third\ Party /Users/kangxg/AwesomeProject/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/double-conversion.build/Script-190EE32F1E6A43DE00A8543A.sh

(1 failure)

Installing build/Build/Products/Debug-iphonesimulator/AwesomeProject.app

An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):

Failed to install the requested application

An application bundle was not found at the provided path.

Provide a valid path to the desired application bundle.

Print: Entry, ":CFBundleIdentifier", Does Not Exist

Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/AwesomeProject.app/Info.plist

Print: Entry, ":CFBundleIdentifier", Does Not Exist

运行 AwesomeProject.xcodeproj 错误:#include <boost/iterator/iterator_adaptor.hpp>



原因:init命令默认会创建最新的版本,而目前最新的0.45版本需要下载boost库编译。此库体积庞大,在国内即便翻墙也很难下载成功,导致很多人无法正常运行iOS项目,推荐暂时使用0.44.3的版本。

解决办法: 创建项目暂时先使用react-native init AwesomeProject --version 0.44.3,指定某个版本。

再次react-native run-ios 运行 AwesomeProject.xcodeproj





运行成功

如果 要运行最新的0.45版本 需要 brew install boost

安装 boost 库即可,但在最后生成软链接的过程中可能出目录写权限的报错问题

Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink include/boost
/usr/local/include is not writable.

观察报错信息发现/usr/local/include与/usr/local/lib无法写入,

故手动修改权限:

sudo chmod -R 777 /usr/local/include
sudo chmod -R 777 /usr/local/lib
1

之后 brew link boost 库即可

如果上面还是解决不了,就是初始化的时候,有四个包没有安装完整参考下面的地址去做即可解决:
https://hacpai.com/article/1497235254333
//包下载
http://blog.csdn.net/u013751625/article/details/75046147
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: