XCode 5 中的胖库 [英] Fat libraries in XCode 5

查看:31
本文介绍了XCode 5 中的胖库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试构建一个静态库,然后在 Xamarin 中从它创建一个绑定项目.一切正常,直到 iOS 7 出现.我不得不获取最新版本的本机库并尝试在 XCode 5 中构建它,但它给我带来了各种各样的问题.我认为这可能与构建过程有关,或者可能与 XCode 5(与 4)中的某些更改设置有关,但我不确定.

I've been trying to build a static library and then create a binding project from it in Xamarin. Everything was working fine until iOS 7 hit. I had to grab the latest version of the native library and try and build it in XCode 5, but it's been giving me all kinds of problems. I think it might be related to the build process or possibly some changed setting in XCode 5 (vs. 4) but I'm not sure.

我使用的是这个 脚本来构建基于此问题中的工作的通用二进制文件:

I was using this script to build a universal binary which is based of work in this question:

构建胖静态库(设备+模拟器)使用 Xcode 和 SDK 4+

我注意到的一件事是,在旧的 iOS 6.1 版本的二进制文件(内置于 XCode 4)中,我的二进制文件大约为 24 Mb,现在使用 XCode 5,它膨胀到近 50 Mb!这让我认为编译和链接步骤有问题.

One thing I did notice is that previous, in the old iOS 6.1 version of my binary (built in XCode 4), my binary was about 24 Mb, now with XCode 5 it's ballooned to almost 50 Mb! Which is leading me to think that there is something wrong with the compiling and linking step.

有什么想法吗?有没有其他人遇到过 XCode 5(vs 4)中通用二进制文件的问题?

Any ideas? Has anybody else encountered problems with universal binaries in XCode 5 (vs 4)?

推荐答案

我正在为我的库使用下面的 makefile,即使使用 XCode 5 和 iOS7 SDK,它也能完美运行.

I'm using the makefile below for my library and it works flawless even with XCode 5 and the iOS7 SDK.

XBUILD=/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
PROJECT_ROOT=.
PROJECT=$(PROJECT_ROOT)/GIFLibFrontEnd.xcodeproj
TARGET=GIFLibFrontEnd

all: libUniversal.a

libi386.a:
    $(XBUILD) -project $(PROJECT) -target $(TARGET) -sdk iphonesimulator -configuration Release clean build
    -mv $(PROJECT_ROOT)/build/Release-iphonesimulator/lib$(TARGET).a $@

libArmv7.a:
    $(XBUILD) -project $(PROJECT) -target $(TARGET) -sdk iphoneos -arch armv7 -configuration Release clean build
    -mv $(PROJECT_ROOT)/build/Release-iphoneos/lib$(TARGET).a $@

libArmv7s.a:
    $(XBUILD) -project $(PROJECT) -target $(TARGET) -sdk iphoneos -arch armv7s -configuration Release clean build
    -mv $(PROJECT_ROOT)/build/Release-iphoneos/lib$(TARGET).a $@

libArm64.a:
    $(XBUILD) -project $(PROJECT) -target $(TARGET) -sdk iphoneos -arch arm64 -configuration Release clean build
    -mv $(PROJECT_ROOT)/build/Release-iphoneos/lib$(TARGET).a $@

libUniversal.a: libi386.a libArmv7.a libArmv7s.a libArm64.a
    lipo -create -output lib$(TARGET)Universal.a $^

clean:
    -rm -f *.a *.dll
    -rm -rf build

这篇关于XCode 5 中的胖库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆