安装homebrew

通过homebrew安装nodejs

通过npm安装weex-toolkit

npm install -g weex-toolkit

安装cocoapod

通过xcode创建项目WeexDemo

在WeexDemo目录下执行pod init创建Podfile文件

编辑Podfile

# Uncomment the next line to define a global platform for your project

platform :ios, '9.0'

target 'WeexDemo' do

# Uncomment the next line if you're using Swift or would like to use dynamic frameworks

# use_frameworks!

# Pods for WeexDemo

pod 'WeexSDK', '0.9.5'

end

执行命令pod install

创建文件hello.we

<template>
  <div class="wrapper">
    <text class="weex">Hello Weex !</text>
    <text class="vue">Hello Vue !</text>
  </div>
</template>
<style scoped>
  .wrapper {
    flex-direction: column;
    justify-content: center;
  }
  .weex {
   font-size: 60px;
   text-align: center;
   color: #1B90F7;
  }
  .vue {
   font-size: 60px;
   text-align: center;
   margin-top: 30px;
   color: #41B883;
  }
</style>

执行命令

weex hello.we -o hello.js

把生成的hello.js加入项目工程

编辑AppDelegate.m文件

#import <WeexSDK/WeexSDK.h>

@interface AppDelegate ()

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// Override point for customization after application launch.

//business configuration

[WXAppConfiguration setAppGroup:@"AliApp"];

[WXAppConfiguration setAppName:@"WeexDemo"];

[WXAppConfiguration setAppVersion:@"1.0.0"];

//init sdk enviroment

[WXSDKEngine initSDKEnviroment];

//register custom module and component,optional

//[WXSDKEngine registerComponent:@"MyView" withClass:[MyViewComponent class]];

//[WXSDKEngine registerModule:@"event" withClass:[WXEventModule class]];

//register the implementation of protocol, optional

//[WXSDKEngine registerHandler:[WXNavigationDefaultImpl new] withProtocol:@protocol(WXNavigationProtocol)];

//set the log level

[WXLog setLogLevel: WXLogLevelAll];

return YES;

}

编辑ViewController.h文件

#import <UIKit/UIKit.h>

#import <WeexSDK/WXSDKInstance.h>

@interface ViewController : UIViewController

@property (nonatomic, strong) WXSDKInstance * instance;

@property (nonatomic, strong) UIView * weexView;

@property (nonatomic, strong) NSURL * url;

@end

编辑ViewController.m文件

- (void)viewDidLoad {

[super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

_instance = [[WXSDKInstance alloc] init];

_instance.viewController = self;

_instance.frame = self.view.frame;

__weak typeof(self) weakSelf = self;

_instance.onCreate = ^(UIView *view) {

[weakSelf.weexView removeFromSuperview];

weakSelf.view = view;

[weakSelf.view addSubview:weakSelf.weexView];

};

_instance.onFailed = ^(NSError *error) {

//process failure

};

_instance.renderFinish = ^ (UIView *view) {

//process renderFinish

};

self.url = [[NSBundle mainBundle] URLForResource:@"hello" withExtension:@"js"];

[_instance renderWithURL:self.url];

}

- (void)dealloc {

[_instance destroyInstance];

}

运行程序

源代码工程

https://github.com/chenhaifeng2016/WeexDemoIOS

IOS项目集成Weex相关推荐

  1. iOS 项目集成Flutter

    #最近移动端火爆无非是Flutter--舍我其谁,而官网的引导之中鲜有说怎么在已有项目中去集成Flutter,今天我们就再蹭个热门来进行一个iOS集成 1 创建iOS项目(做测试使用) 2 cocoa ...

  2. iOS项目集成react-native热更新(pushy:react-native-update)

    项目集成react-native参考官网文档 cd 项目文件夹 npm install -g react-native-update-cli (一台电脑只运行一次就行) npm install --s ...

  3. iOS项目集成unity(2020+ 版本)

    iOS 集成unity 随着unity版本的升级,老式unity(例如2017版本)的集成方式对于 2020 + 版本就不适用了,而且老式的unity集成相当复杂.新版的集成还相对容易一些. 这里我只 ...

  4. 现有的iOS项目集成ReactNative的记录文档

    为什么80%的码农都做不了架构师?>>>    原版地址,这里.中文翻译版,这里. 这里整理下遇到的问题 1.指定root入参数未生效,表现形式:无法获取index.ios.boun ...

  5. iOS native集成Weex js文件 不显示提示框问题

    问题: iOS集成0.15.1版本的WeexSDK,编译器Xcode9.2,加载js文件提示框不显示问题. 如图:不显示提示框: 正常情况下: 解决方法:找到项目的info.plist,删除Main ...

  6. Android项目集成Weex

    本文采用的是SDK依赖方式. 安装weex-toolkit npm install -g weex-toolkit 通过android studio创建一个项目WeexDemoAndroid 在mod ...

  7. IOS项目集成ShareSDK实现第三方登录、分享、关注等功能

    快速集成 第一步:将下载的SDK解压后导入您的工程中,见下图(点击这里查看视频教程) 拖到工程中后弹出以下对话框,勾选"Copy items into destination group's ...

  8. 原生App项目集成flutter混合开发详细指南

    记得去年9月份的时候谷歌在上海有一次开发者大会,去参加的时候关注到了flutter,随后没过多久就发布了1.0版本.18年底的时候用flutter做了个小项目,发现flutter确实挺好用的.于是尝试 ...

  9. 2019最新 iOS Native项目集成Unity3D

    经历了几天的不断尝试解决各种报错和网上寻得的资料最终成功在iOS项目中集成Unity3D,现有的资料都比较老,多数不适用或者说集成完报很多错误. 言归正传,目前我所做的集成是基于Xcode10.1(最 ...

最新文章

  1. Mysql客户端中文乱码问题解决
  2. linux 安装 celluloid 视频播放器
  3. 服务发布或重启,发生抖动怎么办?
  4. python在中小学教学中的应用-Python编程已经走进中小学课堂
  5. 窗体的扩展样式GWL_EXSTYLE:用于SetWindowLong
  6. CSS中content和attr的用法
  7. LiveVideoStackCon讲师热身分享 ( 十三 ) —— Intel QSV技术在FFmpeg中的实现与使用
  8. UVALive 4794 Sharing Chocolate DP
  9. Spring MVC学习总结(10)——Spring MVC使用Cors跨域
  10. nginx proxy_pass 使用变量报错_nginx自定义变量与内置预定义变量
  11. Javascript经典窍门
  12. UML类图中箭头和线条的含义和用法
  13. 如何使用谷歌云盘下载Kaggle数据集+解压
  14. python基础刻意练习--Task 7 文件与文件系统
  15. 通过2048学习自定义view(二) 滑动事件监听 与 事件回调
  16. pdf怎么转换成word格式不变?
  17. openGauss数据库开发调试工具指导
  18. SSL2811 2017年10月30日提高组T2 摘Galo(树形dp)
  19. 推荐系统综述--初识推荐系统(美研面试专用)
  20. van访谈_谷歌业务分析师访谈

热门文章

  1. 存储过程,触发器,分页练习
  2. 邮件系统三功能 建金字塔防护体系
  3. POJ-3070 Fibonacci 快速矩阵幂
  4. WSSv3 Technical Articles 系列文章
  5. 牛客多校4 - Harder Gcd Problem(构造+贪心)
  6. HDU - 1358 Period(KMP的next数组求最小循环节)
  7. php滚动公告源码,JavaScript_jquery垂直公告滚动实现代码,复制代码 代码如下: !DOCTYPE - phpStudy...
  8. 中国科学院大学计算机与科学技术学院,贺思敏 - 中国科学院大学 - 计算机科学与技术学院...
  9. 解决延迟有 Wi-Fi 6 就够了!
  10. Python2 常见问题