您的位置:首页 > 其它

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

2013-05-09 19:57 453 查看
第一次接触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了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: