You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ha...@apache.org on 2018/01/18 06:13:51 UTC
[2/4] incubator-weex-site git commit: * [doc] add integrate to your
app documentation
* [doc] add integrate to your app documentation
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex-site/commit/85e67204
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex-site/tree/85e67204
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex-site/diff/85e67204
Branch: refs/heads/master
Commit: 85e67204ea296c1093ee34c2262ff4ab854d5d90
Parents: 1a6d8ce
Author: zifan.zx <zi...@alibaba-inc.com>
Authored: Thu Jan 18 13:56:52 2018 +0800
Committer: zifan.zx <zi...@alibaba-inc.com>
Committed: Thu Jan 18 13:56:52 2018 +0800
----------------------------------------------------------------------
source/cn/guide/integrate-to-your-app.md | 90 +++++++++++++++----------
source/guide/integrate-to-your-app.md | 97 ++++++++++++++++-----------
2 files changed, 112 insertions(+), 75 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex-site/blob/85e67204/source/cn/guide/integrate-to-your-app.md
----------------------------------------------------------------------
diff --git a/source/cn/guide/integrate-to-your-app.md b/source/cn/guide/integrate-to-your-app.md
index 8cc3b4a..5c37bac 100644
--- a/source/cn/guide/integrate-to-your-app.md
+++ b/source/cn/guide/integrate-to-your-app.md
@@ -208,46 +208,40 @@ WXSample地址
## 集成到 iOS
-### 通过cocoaPods 集成 Weex iOS SDK到你的项目
+### 通过 [CocoaPods](https://cocoapods.org/) 或者 [Carthage](https://github.com/Carthage/Carthage) 集成 Weex iOS SDK到你的项目
-首先假设你已经完成了安装 [iOS 开发环境](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppStoreDistributionTutorial/Setup/Setup.html) 和 [CocoaPods](https://guides.cocoapods.org/using/getting-started.html)
+首先假设你已经完成了安装 [iOS 开发环境](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppStoreDistributionTutorial/Setup/Setup.html) 和 [CocoaPods](https://guides.cocoapods.org/using/getting-started.html)(或者[Carthage](https://github.com/Carthage/Carthage#installing-carthage))
#### 第一步:添加依赖
-导入 Weex iOS SDK 到你已有的项目, 如果没有,可以[参考](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppStoreDistributionTutorial/Setup/Setup.html)新建项目
-在继续下面内容之前,确保你已有的项目目录有名称为 `Podfile` 文件,如果没有,创建一个,用文本编辑器打开
+导入 Weex iOS SDK 到你已有的项目, 如果没有,可以[参考](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppStoreDistributionTutorial/Setup/Setup.html)新建项目。
+在继续下面内容之前,确保你已有的项目目录有名称为 `Podfile` 文件,如果没有,创建一个,用文本编辑器打开(如果使用 Carthage ,请确保已有项目目录下存在 [`Cartfile`](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile))。选择其中一个集成方法就可以。
-- 集成 framework
+- 添加依赖
- WeexSDK 在 cocoaPods 上最新版本 可以在[这](https://cocoapods.org/pods/WeexSDK)获取
+ - 使用[CocoaPods](https://cocoapods.org/)
+ WeexSDK 在 cocoaPods 上最新版本 可以在[这](https://cocoapods.org/pods/WeexSDK)获取
在 `Podfile` 文件中添加如下内容
-
- ```
- source 'git@github.com:CocoaPods/Specs.git'
- target 'YourTarget' do
- platform :ios, '7.0'
- pod 'WeexSDK', '0.9.5' ## 建议使用WeexSDK新版本
- end
- ```
-
-- 源码集成
-
- 首先 拷贝 `ios/sdk` 目录到你已有项目目录 (此处以拷贝到你已有项目的根目录为例子),然后在 `Podfile` 文件中添加
-
- ````object-c
- source 'git@github.com:CocoaPods/Specs.git'
- target 'YourTarget' do
- platform :ios, '7.0'
- pod 'WeexSDK', :path=>'./sdk/'
- end
- ````
-
-#### 第二步:安装依赖
-
-打开命令行,切换到你已有项目 `Podfile` 这个文件存在的目录,执行 `pod install`,没有出现任何错误表示已经完成环境配置。
-
-#### 第三步:初始化 Weex 环境
+
+ ```
+ source 'git@github.com:CocoaPods/Specs.git'
+ target 'YourTarget' do
+ platform :ios, '7.0'
+ pod 'WeexSDK', '0.17.0' ## 建议使用WeexSDK新版本
+ end
+ ```
+ 打开命令行,切换到你已有项目 `Podfile` 这个文件存在的目录,执行 `pod install`,没有出现任何错误表示已经完成环境配置。
+
+ - 使用 [Carthage](https://github.com/Carthage/Carthage)
+
+ 可以在[这](https://github.com/apache/incubator-weex/tags)查询到当前最新的版本。
+ 在 [`Cartfile`](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile) 中添加如下内容
+ `github "apache/incubator-weex"`
+ 在包含 `Cartfile` 文件目录的终端中执行 `carthage update`。
+ [添加 framework 到你的工程](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application)
+
+#### 第二步:初始化 Weex 环境
在 `AppDelegate.m` 文件中做初始化操作,一般会在 `didFinishLaunchingWithOptions` 方法中如下添加。
@@ -271,7 +265,7 @@ WXSample地址
[WXLog setLogLevel: WXLogLevelAll];
```
-#### 第四步:渲染 weex Instance
+#### 第三步:渲染 weex Instance
Weex 支持整体页面渲染和部分渲染两种模式,你需要做的事情是用指定的 URL 渲染 Weex 的 view,然后添加到它的父容器上,父容器一般都是 viewController。
@@ -306,7 +300,7 @@ Weex 支持整体页面渲染和部分渲染两种模式,你需要做的事情
WXSDKInstance 是很重要的一个类,提供了基础的方法和一些回调,如 `renderWithURL`, `onCreate`, `onFailed` 等,可以参见 `WXSDKInstance.h` 的声明。
-#### 第五步:销毁 Weex Instance
+#### 第四步:销毁 Weex Instance
在 viewController 的 dealloc 阶段 销毁掉 Weex instance,释放内存,避免造成内存泄露。
@@ -320,5 +314,29 @@ WXSDKInstance 是很重要的一个类,提供了基础的方法和一些回调
### 导入 Weex SDK framework 到工程
可以通过源码编译出 Weex SDK,可以在新的 feature 或者 bugfix 分支,尝试最新的 feature。
-
- 参考[此处](https://open.taobao.com/doc2/detail?spm=a219a.7629140.0.0.tFddsV&&docType=1&articleId=104829)直接导入 weexSDK。
+ - 使用 git clone [Weex](https://github.com/apache/incubator-weex.git)
+ SSH
+ ```
+ git clone git@github.com:apache/incubator-weex.git
+ ```
+ 或者 https
+ ```
+ git clone https://github.com/apache/incubator-weex.git
+ ```
+
+- 打开 WeexSDK.xcodeproj in `weex/ios/sdk`
+ 切换到如下图所示 target
+ 
+
+- 编译当前target,可以直接用快捷键 `⌘ + b`
+
+- 最后找到产物在 `weex/ios/sdk/Products` 目录
+ 
+
+- 导入 framework 到自己工程
+ - 需要添加如下图系统依赖
+ 
+ - 添加 `-ObjC` 到工程设置中
+ 
+ - 添加 `js-framework` 到自己的 main bundle, `js-framework` 的位置在 WeexSDK.framework 中,文件名称为 `native-bundle-main.js`
+ 
http://git-wip-us.apache.org/repos/asf/incubator-weex-site/blob/85e67204/source/guide/integrate-to-your-app.md
----------------------------------------------------------------------
diff --git a/source/guide/integrate-to-your-app.md b/source/guide/integrate-to-your-app.md
index 970a95d..453ca20 100644
--- a/source/guide/integrate-to-your-app.md
+++ b/source/guide/integrate-to-your-app.md
@@ -119,43 +119,33 @@ Tip: Click QRCode Image in Demo Source Page, your will see compiled bundle js.
## Integrated to iOS
-Through the cocoaPods integrated Weex iOS SDK to the project.
-First assume that you have finished installing the [iOS development environment](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppStoreDistributionTutorial/Setup/Setup.html) and [CocoaPods](https://guides.cocoapods.org/using/getting-started.html).
+Through the [CocoaPods](https://cocoapods.org/) or [Carthage](https://github.com/Carthage/Carthage) integrated Weex iOS SDK to your project.
+First assume that you have finished installing the [iOS development environment](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppStoreDistributionTutorial/Setup/Setup.html) and [CocoaPods](https://guides.cocoapods.org/using/getting-started.html)(or [Carthage](https://github.com/Carthage/Carthage#installing-carthage)).
### Step 1: Add Dependencies
-Import Weex iOS SDK to your existing project, if not, you can create a new project.
-Before proceeding, make sure that the Podfile file is under the project file. If not, create one and open with text editor.
-
-+ Integration framework
-
-WeexSDK The latest version on cocoaPods can be obtained [here](https://cocoapods.org/pods/WeexSDK) .
-Add the following to the Podfile file:
-
-```object-c
-source 'git@github.com:CocoaPods/Specs.git'
-target 'YourTarget' do
- platform :ios, '7.0'
- pod 'WeexSDK', '0.9.5' ## Suggest using latest Weex SDK
-end
-```
-
-+ Integrate with source code
-
-First copy the ios / sdk directory to your existing project directory (here to copy the root directory of your existing project as an example), and then add the Podfile file.
-
-```object-c
-source 'git@github.com:CocoaPods/Specs.git'
-target 'YourTarget' do
- platform :ios, '7.0'
- pod 'WeexSDK', :path=>'./sdk/'
-end
-```
-
-### Step 2: Install Dependencies
-
-Open the command line, switch to the directory of the Podfile file, and run the pod install command. If there are no errors, it means that the environment has been configured.
-
-### Step 3: Initialize the Weex environment
+Import Weex iOS SDK to your existing project, if not, you can create a new project according to the [tutorial](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppStoreDistributionTutorial/Setup/Setup.html)).
+Before proceeding, make sure that the Podfile file is under the project file. If not, create one and open with text editor(if Carthage, please ensure the [`Cartfile`](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile) in your project directory). You can choose one of Integration method.
+
+- using [CocoaPods](https://cocoapods.org/)
+ WeexSDK The latest version on cocoaPods can be obtained [here](https://cocoapods.org/pods/WeexSDK) .
+ Add the following to the Podfile file:
+
+ ```object-c
+ source 'git@github.com:CocoaPods/Specs.git'
+ target 'YourTarget' do
+ platform :ios, '7.0'
+ pod 'WeexSDK', '0.17.0' ## latest Weex SDK recommended
+ end
+ ```
+ Open the command line, switch to the directory of the Podfile file, and run the pod install command. If there are no errors, it means that the environment has been configured.
+- using [Carthage](https://github.com/Carthage/Carthage)
+ [here](https://github.com/apache/incubator-weex/tags) you can get the latest version of WeexSDK.
+ Add `github "apache/incubator-weex"` to [`Cartfile`](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile)
+ Open the command line, switch to the directory of the Cartfile, and run `carthage update`.
+ [Add Carthage build framework to your project](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application)
+
+
+### Step 2: Initialize the Weex environment
In the AppDelegate.m file to do the initialization operation, usually in the didFinishLaunchingWithOptions method as follows to add.
```object-c
@@ -174,7 +164,7 @@ In the AppDelegate.m file to do the initialization operation, usually in the did
[WXLog setLogLevel: WXLogLevelAll];
```
-### Step 4: Render weex Instance
+### Step 3: Render weex Instance
Weex supports both full page rendering and partial rendering. What you need to do is render Weex's view with the specified URL and add it to its parent container. The parent container is generally a viewController.
@@ -205,7 +195,7 @@ Weex supports both full page rendering and partial rendering. What you need to d
WXSDKInstance is a very important class that provides a basic method and some callbacks, such as renderWithURL, onCreate, onFailed, etc., can be found in WXSDKInstance.h.
-### Step 5: Destroy Weex Instance
+### Step 4: Destroy Weex Instance
In the dealloc phase of the viewController destroyed Weex instance, can play a role in avoiding memory leaks.
```object-c
@@ -215,6 +205,35 @@ In the dealloc phase of the viewController destroyed Weex instance, can play a r
}
```
-#### Import the Weex SDK framework to the project.
+#### Build your own WeexSDK.framework and Import to your project.
The Weex SDK can be compiled from the source code. You can try the latest feature in the new feature or bugfix branch.
-Refer to [here](https://open.taobao.com/doc2/detail?spm=a219a.7629140.0.0.tFddsV&&docType=1&articleId=104829) for direct import of weexSDK.
+
+- clone [Weex](https://github.com/apache/incubator-weex.git) project
+ you can use SSH
+
+ ```
+ git clone git@github.com:apache/incubator-weex.git
+ ```
+ or use https
+
+ ```
+ git clone https://github.com/apache/incubator-weex.git
+ ```
+
+- open WeexSDK.xcodeproj in `weex/ios/sdk`
+ switch target just below
+ 
+
+- Build this project or just use the xcode default hot key `⌘ + b`
+
+- Finally you can find `Products` directory in `weex/ios/sdk`, `WeexSDK.framework` was here
+ 
+
+- Add `js-framework`(which is in the `WeexSDK.framework` and renamed to `native-bundle-main.js`) to your main bundle
+ 
+- Import the framework you get above and import system framework
+ 
+- add `-ObjC` to your project settings,just like this
+
+
+