发布网友 发布时间:2022-04-21 20:11
共1个回答
热心网友 时间:2023-10-04 10:42
iPhone何打包通用静态库文件(模拟器真机都用)
1.先必须命令:
~/Library目录lion默认隐藏便用命令使其显示:
chflags nohidden ~/Library
想再让其隐藏:
chflags hidden ~/Library
2.静态库工程建立:Xcode New新project选择IOS面Framework&Library面Cocoa Touch Static Library直接next建立MtimeLibrary工程(面功能要关注简单 2数相加)
?
3.工程建立删除默认.h .m 文件自创建CountNumbers..h CountNumbers..m文件图:
4.OK选择iPhone 5.1Simulator ,Command + B 编译我Procts面找我编译模拟器运行libMtimeLibrary.a文件,选择真机(图)再编译真机运行libMtimeLibrary.a库
?
5. libMtimeLibrary.a 右键 Open in Finder找libMtimeLibrary.a所路径、面我新建项目添加.a文件测试
打终端:输入命令(路径根据自决定)
cd /Users/cash/Library/Developer/Xcode/DerivedData/MtimeLibrary-amyqbnwwzcivnyeijggzaorseihj/Build/Procts/
Procts目录ls 看:
?
再输入命令: cd Debug-iphonesimulator/
通面命令查看libMtimeLibrary.a信息
命令:lipo -info libMtimeLibrary.a
显示:
cashmatoMacBook-Pro:Debug-iphonesimulator cash$ lipo -info libMtimeLibrary.a
input file libMtimeLibrary.a is not a fat file
Non-fat file: libMtimeLibrary.a is architecture: i386
i386mac架构
再输入面命令:
cd ../
cd Debug-iphoneos/
继续通命令查看 lipo -info libMtimeLibrary.a
显示:
cashmatoMacBook-Pro:Debug-iphoneos cash$ lipo -info libMtimeLibrary.a
input file libMtimeLibrary.a is not a fat file
Non-fat file: libMtimeLibrary.a is architecture: armv7
armv7iOSjia'ge架构
我明白真机使用能模拟器使用吧
我要做要让libMtimeLibrary.a文件同i386armv7信息通用静态库文件
6. 新建MtimeLibraryDemo应用真机或者模拟器libMtimeLibrary.a CountNumbers.h文件引入进图:
?
添加CountNumbers.h文件需要调用类面调用libMtimeLibrary.a面
//
// AppDelegate.m
// MtimeLibraryDemo
//
// Created by cash on 12-3-23.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "AppDelegate.h"
#import "CountNumbers.h"
@implementation AppDelegate
@synthesize window = _window;
- (void)dealloc
{
[_window release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
CountNumbers *cn = [[CountNumbers alloc] init];
int count = [cn addTwoNumbers:10 :20];
NSLog(@"count:%d",count);
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
7. OK编译运行应用程序 错误篇文档关键.
?
我找刚才真机模拟器libMtimeLibrary.a目录
debug-iphoneos面基于arm6 arm7编译库文件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 -info libMtimeLibrary.a 知道文件已经i386armv7信息
cashmatoMacBook-Pro:test cash$ lipo -info libMtimeLibrary.a
Architectures in the fat file: libMtimeLibrary.a are: i386 armv7
cashmatoMacBook-Pro:test cash$
w