weex 安装、创建项目并在iOS模拟器中运行

weex 安装、创建项目并在iOS模拟器中运行

  1. 安装npm,百度会告诉你各种姿势安装

  2. 安装 weex

    $ npm install -g weex-toolkit
    如果安装过程中出现等待时间过长的情况,请设置一下npm的代理
    $ npm config set registry https://registry.npm.taobao.org
    $ npm config list

    出现如下显示表示 weex 安装成功

    + weex-toolkit@1.3.4
    updated 1 package in 24.354s
  3. 创建 weex 项目

    $ weex create firstWeexApp

    这一步会让你填写项目名、描述、作者等信息,按着提示写就行

    需要注意的选项

    • Use ESLint to lint you code ? 据说校验比较严格,我选的是No
    • npm or yarn 的选项就选 npm 就行

这就完成了吗 ?对于安装过 phantomjs 的用户是的,但对于第一次玩 weex 的朋友们来讲会出现如下提示:


PhantomJS not found on PATH
Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-macosx.zip
Saving to /var/folders/cw/4mqt3r156j30shm3x91dyd9c0000gn/T/phantomjs/phantomjs-2.1.1-macosx.zip
Receiving...
[====------------------------------------] 9%

没开 vpn 的话你就在这儿等吧,我是等了很久


  1. 在 iOS模拟器中运行

    执行 npm install 可能会出现如下提示

    npm WARN ajv-keywords@3.1.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
    
    npm WARN babel-loader@6.4.1 requires a peer of webpack@1 || 2 || ^2.1.0-beta || ^2.2.0-rc but none is installed. You must install peer dependencies yourself.
    
    npm WARN babel-loader@6.4.1 requires a peer of webpack@1 || 2 || ^2.1.0-beta || ^2.2.0-rc but none is installed. You must install peer dependencies yourself.

    只需要按着提示进行安装就可以,如:

    $ npm install ajv
    $ npm install babel
    $ npm install webpack

    使用 weex platform list 命令查看你的项目中支持的平台

    $ weex platform list
    Installed platforms:
    - ios 4.1.6
    
    Available platforms:
    - android ^6.3.8

    如果没有出现 iOS 的支持平台请执行 weex platform add ios ,出现如下提示

    $ weex platform add ios
    18:01:32 : Adding ios weexpack-ios@4.1.6 ...
    18:01:32 : Success!

    运行 iOS 项目

    $ weex run ios
    ... (一堆提示信息)
    ...
    /bin/sh: pod: command not found
    18:01:56 : Command run error, please check if there has the same issue here: https://github.com/weexteam/weex-toolkit/issues/337
    18:01:56 : Error:Error: Command failed: pod update
    /bin/sh: pod: command not found

    安装 pod

    $ sudo gem install -n /usr/local/bin cocoapods

    安装成功后再次运行 weex run ios 出现 iOS 模拟器,并显示默认页面

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值