Xcode5打包静态库
来源:互联网 发布:淘宝商城百度 编辑:程序博客网 时间:2024/05/16 07:00
今天研究了一下怎么打包静态库,从网上查了很多资料,但目前大多数都是说在Xcode4上怎么打包静态库的,所以今天我用Xcode5打包了静态库,其实都差不多呢。
打包的步骤如下:
1、创建一个静态库项目,如下图:
2、在这个项目中我创建了一个UIViewController类,上面就一个UIWebView,加载百度的地址,代码如下:
WebViewController.h文件
#import <UIKit/UIKit.h>@interface WebViewController : UIViewController<UIWebViewDelegate>@end
WebViewController.m文件
#import "WebViewController.h"#define CURRENT_DEVICE_SYSTEMVERSION [[UIDevice currentDevice] systemVersion]#define iOS7_VERSIONS_LATTER ([CURRENT_DEVICE_SYSTEMVERSION floatValue] >= 7.0)@interface WebViewController () @property (nonatomic, retain) UIWebView *webView; @end@implementation WebViewController- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self;}- (void)viewDidLoad{ [super viewDidLoad]; if (iOS7_VERSIONS_LATTER) { [self setNeedsStatusBarAppearanceUpdate]; self.edgesForExtendedLayout = UIRectEdgeBottom; self.extendedLayoutIncludesOpaqueBars = NO; self.automaticallyAdjustsScrollViewInsets = NO; } self.webView = [[[UIWebView alloc] initWithFrame:self.view.frame] autorelease]; self.webView.delegate = self; [self.view addSubview:self.webView]; [self loadWebPageWithString:@"http://www.baidu.com"];}- (void)didReceiveMemoryWarning{ [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.} - (void)dealloc{ self.webView = nil; [super dealloc];} - (void)loadWebPageWithString:(NSString*)urlString{ NSURL *url =[NSURL URLWithString:urlString]; NSLog(@"%@",urlString); NSURLRequest *request =[NSURLRequest requestWithURL:url]; [self.webView loadRequest:request];}
3、如果你的这个静态库是给其他developer用,你就给他们Release版本的,在Edit Scheme中设置,如下图:
4、静态库的制作方法可分为两种:第一种为在真机上使用的静态库,第二种为在模拟器中使用的静态库。他们的区别如下:
当制作在真机上使用的静态库时,选择iOS Device,编译,你会得到一个支持真机的静态库。
右击Products目录下的libWebViewSDK.a文件open in finder,找到这个文件所在的目录,选择Release-iphoneos目录下的libWebViewSDK.a文件。
当制作在模拟器上运行的静态库时,选择iPhone Simulator,编译,你会得到一个支持模拟器的静态库。
右击Products目录下的libWebViewSDK.a文件open in finder,找到这个文件所在的目录,选择Release-iphoneosimulator目录下的libWebViewSDK.a文件。
5、静态库的使用
把此静态库和此库中必要的头文件加到你要使用此库的项目中,如我建立了一个WebImageTest的项目,然后我把相应的静态库libWebViewSDK.a(真机版或模拟器版的)和前面写的WebViewController.h文件加入到此项目中
调用此静态库的代码如下:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. WebViewController *webVC = [[WebViewController alloc] init]; self.window.rootViewController = webVC; [webVC release]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES;}在ios7模拟器上运行的效果图如下:
这个效果图好像太白了点啊。。。。
- Xcode5打包静态库
- Xcode5打包静态库
- Xcode5之打包静态库
- Xcode5 制作静态库
- 参加iOS开发之——Xcode5之打包静态库
- Xcode5制作iOS静态库
- 新 xcode5.1 即简介静态库
- IOS 使用Xcode5制作静态库详解
- xcode5.0 修改静态库输出路径
- xcode5.0 设置静态库头文件
- xcode5下ffmpeg静态库配置
- 【转载】Xcode5制作iOS静态库
- IOS 使用Xcode5制作静态库详解
- IOS 使用Xcode5制作静态库详解
- xcode5.0打包IPA
- xcode5.0打包IPA
- xcode5.0打包IPA
- xcode5.0打包IPA
- [Err] 1005 - Can't create table 'xx' (errno: 150) 解决方案
- RedHat5.5 升级安装GCC-4.6.1详细教程之二
- vs2010 The program '[5008] txic.exe: Native' has exited with code -1073741811 (0xc000000d).
- linux下ln命令学习
- Eclipse开发初阶之Eclipse安装
- Xcode5打包静态库
- MySQL中,使用RAND()的查询优化
- OpenCV函数cvWaitKey(k)简介
- Sqoop安装配置与从mysql中导入数据到hbase
- 更完美的log
- 更新linux gcc版本到gcc 4.4.2之三
- ubuntu下sudo apt-get update Sources 404 Not Found [IP: 91.189.92.200 80]解决办法
- 关于Java虚拟机
- IOS 清除svn信息