客趣旅游网
发布网友 发布时间:2022-04-21 20:11
共1个回答
热心网友 时间:2023-07-10 01:57
iPhone何打包通用静态库文件(模拟器真机都用)1.先必须命令:~/Library目录lion默认隐藏便用命令使其显示:chflagsnohidden~/Library想再让其隐藏:chflagshidden~/Library2.静态库工程建立:XcodeNew新project选择IOS面Framework&Library面CocoaTouchStaticLibrary直接next建立MtimeLibrary工程(面功能要关注简单2数相加)?3.工程建立删除默认.h.m文件自创建CountNumbers..hCountNumbers..m文件图:4.OK选择iPhone5.1Simulator,Command+B编译我Procts面找我编译模拟器运行libMtimeLibrary.a文件,选择真机(图)再编译真机运行libMtimeLibrary.a库?5.libMtimeLibrary.a右键OpeninFinder找libMtimeLibrary.a所路径、面我新建项目添加.a文件测试打终端:输入命令(路径根据自决定)cd/Users/cash/Library/Developer/Xcode/DerivedData/MtimeLibrary-amyqbnwwzcivnyeijggzaorseihj/Build/Procts/Procts目录ls看:?再输入命令:cdDebug-iphonesimulator/通面命令查看libMtimeLibrary.a信息命令:lipo-infolibMtimeLibrary.a显示:cashmatoMacBook-Pro:Debug-iphonesimulatorcash$lipo-infolibMtimeLibrary.ainputfilelibMtimeLibrary.aisnotafatfileNon-fatfile:libMtimeLibrary.aisarchitecture:i386i386mac架构再输入面命令:cd../cdDebug-iphoneos/继续通命令查看lipo-infolibMtimeLibrary.a显示:cashmatoMacBook-Pro:Debug-iphoneoscash$lipo-infolibMtimeLibrary.ainputfilelibMtimeLibrary.aisnotafatfileNon-fatfile:libMtimeLibrary.aisarchitecture:armv7armv7iOSjia'ge架构我明白真机使用能模拟器使用吧我要做要让libMtimeLibrary.a文件同i386armv7信息通用静态库文件6.新建MtimeLibraryDemo应用真机或者模拟器libMtimeLibrary.aCountNumbers.h文件引入进图:?添加CountNumbers.h文件需要调用类面调用libMtimeLibrary.a面////AppDelegate.m//MtimeLibraryDemo////Createdbycashon12-3-23.//Copyright(c)2012__MyCompanyName__.Allrightsreserved.//#import"AppDelegate.h"#import"CountNumbers.h"@implementationAppDelegate@synthesizewindow=_window;-(void)dealloc{[_windowrelease];[superdealloc];}-(BOOL)application:(UIApplication*)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions{self.window=[[[UIWindowalloc]initWithFrame:[[UIScreenmainScreen]bounds]]autorelease];//Overridepointforcustomizationafterapplicationlaunch.CountNumbers*cn=[[CountNumbersalloc]init];intcount=[cnaddTwoNumbers:10:20];NSLog(@"count:%d",count);self.window.backgroundColor=[UIColorwhiteColor];[self.windowmakeKeyAndVisible];returnYES;}7.OK编译运行应用程序错误篇文档关键.?我找刚才真机模拟器libMtimeLibrary.a目录debug-iphoneos面基于arm6arm7编译库文件debug-iphonesimulator文件夹面基于i386编译文件?10.关键步骤:通lipo-create命令合并2静态库文件(-output面/Users/cash/Desktop/test/libMtimeLibrary.a合并路径文件名字)lipo-create"/Users/cash/Library/Developer/Xcode/DerivedData/MtimeLibrary-amyqbnwwzcivnyeijggzaorseihj/Build/Procts/Debug-iphonesimulator/libMtimeLibrary.a""/Users/cash/Library/Developer/Xcode/DerivedData/MtimeLibrary-amyqbnwwzcivnyeijggzaorseihj/Build/Procts/Debug-iphoneos/libMtimeLibrary.a"-output"/Users/cash/Desktop/test/libMtimeLibrary.a"功通命令lipo-infolibMtimeLibrary.a知道文件已经i386armv7信息cashmatoMacBook-Pro:testcash$lipo-infolibMtimeLibrary.aArchitecturesinthefatfile:libMtimeLibrary.aare:i386armv7cashmatoMacBook-Pro:testcash$w