在xcode 4.6里添加 Cordova static library 静态库,避免繁琐的官网

08-09 01:44:41   来源:互联网   评论: 点击:

第一次接触Cordova,被官网的安装guide吓到了。后面发现Cordova是个静态库,那就好办了。直接当做静态库引入我们现成的项目中。
第一次接触Cordova,被官网的安装guide吓到了。后面发现Cordova是个静态库,那就好办了。直接当做静态库引入我们现成的项目中。

步骤如下:(一开始看这个英文,纠结了很久。好在坚持住了,继续找了另一个资料,两个资料合起来就完美了。所以写下博客,保存起来,希望对大家有帮助)

     按照英文步骤实现。

Use Cordova for iOS as static library

By  admin  on Thu, 02/28/2013 - 11:10

After version 2.0.0  Cordova  library for iOS provided as Xcode project. 
The main problem is that you can not open two projects with Cordova, only one. 
But you can use the following trick to get around this. 
1. Set "Skip install" property of CordovaLib project to "No" 。这个配置要设置NO.跳过安装Cordeva才可以使用的限制。 

2. Run "Product" => "Archive" command from menu. After successful build was opened Organizer - Archives(这里是用发布版本) 
3. Press "Distribute" button, select "Save Build Products" and press next 
4. Save Cordova Library build 
5. On file system you can see a files 

6. After it you could include this file in own project 
6.1 Open "Build Phases" tab and in "Link Binary with Libraries" press plus button, in dialog press "Add Other..." and select libCordova.a file

引入发布版的lib. 

6.2 Open "Build Settings" tab, find property with name "Header Search Paths" and write full path to "include" folder of compiled Cordova library

路径是你之前发布lib的位置。直接找到include文件然后把这个文件夹拖进 "Header Search Paths"。选择recursive. 

7. 不要忘记了头文件的引用(我一开始就忘记这个,纠结了好久)

 

#ifdef CORDOVA_FRAMEWORK
    #import <Cordova/CDV.h>
#else
    #import "CDV.h"
#endif

 

You would just have:

#import <Cordova/CDV.h>

 这俩个头文件,最好放到 prefix文件里这样就不用到处写import了。  

相关热词搜索:xcode cordova

上一篇:第一个PhoneGap(cordova)应用 下一篇:浅析 Cordova for iOS
分享到: 收藏