问题描述
自从升级到Xcode和iOS8以来,我一直在构建一个胖的静态库时遇到了麻烦。有一些相当不错的说明和,但我认为第一条说明的部分内容和第二条说明的全部内容均注明日期。第一条指令声明使用静态iOS框架,第二条指令声明使用 Cocoa Touch静态库。在使用Xcode6之前,我会使用静态iOS框架,但现在它们已将其重命名为 Cocoa Touch Framework 。我不确定。
因此,对于初学者来说,我应该使用哪个来创建胖静态库?它是 Cocoa Touch框架?或 Cocoa Touch静态库?
然后我创建一个新的汇总目标:
然后我创建一个运行脚本:
以下是我正在使用的运行脚本(完整):
#此脚本基于Jacob Van Order在苹果开发论坛上的答案
https://devforums.apple.com/message/971277
#另请参阅http://spin.atomicobject.com/2011/12/13/building-a-universal-framework-for-ios/为开始
#为了得到这个工作Xcode 6 Cocoa Touch Framework,创建Framework
#然后创建一个ne w综合目标。把这个脚本放到总结
$ b上的构建脚本语句######################
#选项
######################
REVEAL_ARCHIVE_IN_FINDER = true
FRAMEWORK_NAME =$ {PROJECT_NAME}
SIMULATOR_LIBRARY_PATH =$ {BUILD_DIR} / $ {CONFIGURATION} -iphonesimulator / $ {FRAMEWORK_NAME} .framework
DEVICE_LIBRARY_PATH =$ {BUILD_DIR} / $ {CONFIGURATION} -iphoneos / $ {FRAMEWORK_NAME} .framework
UNIVERSAL_LIBRARY_DIR =$ {BUILD_DIR} / $ {CONFIGURATION} -iphoneuniversal
FRAMEWORK =$ { UNIVERSAL_LIBRARY_DIR} / $ {FRAMEWORK_NAME} .framework
######################
#Build框架
######################
xcodebuild -project $ {PROJECT_NAME} .xcodeproj -sdk iphonesimulator -target $ {PROJECT_NAME} -configuration $ {CONFIGURATION} clean build CONFIGURATION_BUILD_DIR = $ {BUILD_DIR} / $ {CONFIGURATION} -iphonesimulator | echo
xcodebuild -project $ {PROJECT_NAME} .xcodeproj -sdk iphoneos -target $ {PROJECT_NAME} -configuration $ {CONFIGURATION} clean build CONFIGURATION_BUILD_DIR = $ {BUILD_DIR} / $ {CONFIGURATION} -iphoneos | echo
$ b #xcodebuild -target $ {PROJECT_NAME} ONLY_ACTIVE_ARCH = NO -configuration $ {CONFIGURATION} -sdk iphoneos BUILD_DIR =$ {BUILD_DIR}BUILD_ROOT =$ {BUILD_ROOT}| echo
$ b $#BUILD_DIR}BUILD_ROOT =$ {BUILD_ROOT}| echo
######################
#为通用
##创建目录####################
$ b $ r rm -rf$ {UNIVERSAL_LIBRARY_DIR}
mkdir$ {UNIVERSAL_LIBRARY_DIR }
mkdir$ {FRAMEWORK}
##################### #
#复制文件Framework
######################
cp -r$ {DEVICE_LIBRARY_PATH } /。 $ {FRAMEWORK}
######################
#使胖通用二进制
######################
lipo$ {SIMULATOR_LIBRARY_PATH} / $ {FRAMEWORK_NAME}$ {DEVICE_LIBRARY_PATH} / $ {FRAMEWORK_NAME}-create -output$ {FRAMEWORK} / $ {FRAMEWORK_NAME}| echo
######################
#发布时,将结果复制到桌面文件夹
######################
if [$ {CONFIGURATION}==Release];然后
mkdir$ {HOME} / Desktop / $ {FRAMEWORK_NAME} - $ {CONFIGURATION} -iphoneuniversal /
cp -r$ {FRAMEWORK}$ {HOME} / Desktop / $ { FRAMEWORK_NAME} - $ {CONFIGURATION} -iphoneuniversal /
fi
######################
#如果需要,打开Framework文件夹
######################
if [$ { REVEAL_ARCHIVE_IN_FINDER} = true];那么
if [$ {CONFIGURATION}==Release];然后
打开$ {HOME} / Desktop / $ {FRAMEWORK_NAME} - $ {CONFIGURATION} -iphoneuniversal /
else
打开$ {UNIVERSAL_LIBRARY_DIR} /
fi
fi
但是当我尝试构建时,我收到了以下消息:
致命错误:lipo:无法打开输入文件:/ Users / pdl / Library / Developer / Xcode / DerivedData / innerIDMobileLicense -b1xjfvoxnqfelftmzojgdwhvazk / Build / Products /Debug-iphonesimulator/innerIDMobileLicense.framework/innerIDMobileLicense(没有这样的文件或目录)
没错,文件不在那里!注意下面的第一张图片,有一个Unix可执行文件 IdAirOpenCv 。然后查看第二张图片,注意 IdAirOpenCv 不存在。
这是我在升级前习惯看到的内容:
这就是我现在所拥有的:
根据脚本,Unix可执行文件 innerIDMobileLicense 应位于框架的所有三个文件夹与Headers和Modules文件夹位于同一级别。
有人知道我做错了什么吗?
致命错误:lipo:无法打开输入文件:
/ Users / pdl / Library / Developer / Xcode / DerivedData / innerIDMobileLicense -blnxjfvoxnqfelftmzojgdwhvazk / Build / Products / Debug-iphonesimulator / innerIDMobileLicense.framework / innerIDMobileLicense
(没有这样的文件或目录)
您得到的这个lipo错误很可能是由于包含的目录不存在。
脚本是在xcode没有框架项目时创建的。
Lipo基本上将两个不同架构的二进制版本链接在一起,以构建一个胖版本。
任何一个都可以工作。 Lipo可以链接框架内的二进制文件和一个简单的静态库
我所做的是创建一个静态库项目和一个框架项目。将静态库目标设置为设备或模拟器(使用sdk iphoneos或iphonesimulator)将通用框架脚本添加到框架项目中,以便使用另一个sdk构建静态库并将fat二进制文件放到框架中。框架项目。框架不需要编译任何东西。
Since the upgrade to Xcode and iOS8, I've been having trouble building a fat static library. There are some pretty good instructions here and here but I think parts of the first instructions and all of the second instructions are dated. The first instructions say to use Static iOS Framework and the second instructions say to use Cocoa Touch Static Library. Prior to Xcode6, I would use the Static iOS Framework but now that they have renamed it to Cocoa Touch Framework I'm not sure.
So, for starters, which should I use to create a fat static library? Is it Cocoa Touch Framework? Or Cocoa Touch Static Library?
Then I create a new Aggregate Target:
Then I create a Run Script:
Here is the Run Script I am using (in its entirety):
# This script is based on Jacob Van Order's answer on apple dev forums
https://devforums.apple.com/message/971277
# See also http://spin.atomicobject.com/2011/12/13/building-a-universal-framework-for-ios/ for the start
# To get this to work with a Xcode 6 Cocoa Touch Framework, create Framework
# Then create a new Aggregate Target. Throw this script into a Build Script Phrase on the Aggregate
######################
# Options
######################
REVEAL_ARCHIVE_IN_FINDER=true
FRAMEWORK_NAME="${PROJECT_NAME}"
SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework"
DEVICE_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphoneos/${FRAMEWORK_NAME}.framework"
UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/${CONFIGURATION}-iphoneuniversal"
FRAMEWORK="${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_NAME}.framework"
######################
# Build Frameworks
######################
xcodebuild -project ${PROJECT_NAME}.xcodeproj -sdk iphonesimulator -target ${PROJECT_NAME} -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphonesimulator | echo
xcodebuild -project ${PROJECT_NAME}.xcodeproj -sdk iphoneos -target ${PROJECT_NAME} -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphoneos | echo
#xcodebuild -target ${PROJECT_NAME} ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" | echo
#xcodebuild -target ${PROJECT_NAME} ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphonesimulator BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" | echo
######################
# Create directory for universal
######################
rm -rf "${UNIVERSAL_LIBRARY_DIR}"
mkdir "${UNIVERSAL_LIBRARY_DIR}"
mkdir "${FRAMEWORK}"
######################
# Copy files Framework
######################
cp -r "${DEVICE_LIBRARY_PATH}/." "${FRAMEWORK}"
######################
# Make fat universal binary
######################
lipo "${SIMULATOR_LIBRARY_PATH}/${FRAMEWORK_NAME}" "${DEVICE_LIBRARY_PATH}/${FRAMEWORK_NAME}" -create -output "${FRAMEWORK}/${FRAMEWORK_NAME}" | echo
######################
# On Release, copy the result to desktop folder
######################
if [ "${CONFIGURATION}" == "Release" ]; then
mkdir "${HOME}/Desktop/${FRAMEWORK_NAME}-${CONFIGURATION}-iphoneuniversal/"
cp -r "${FRAMEWORK}" "${HOME}/Desktop/${FRAMEWORK_NAME}-${CONFIGURATION}-iphoneuniversal/"
fi
######################
# If needed, open the Framework folder
######################
if [ ${REVEAL_ARCHIVE_IN_FINDER} = true ]; then
if [ "${CONFIGURATION}" == "Release" ]; then
open "${HOME}/Desktop/${FRAMEWORK_NAME}-${CONFIGURATION}-iphoneuniversal/"
else
open "${UNIVERSAL_LIBRARY_DIR}/"
fi
fi
But when I try to Build I receive this message:
fatal error: lipo: can't open input file: /Users/pdl/Library/Developer/Xcode/DerivedData/innerIDMobileLicense-blnxjfvoxnqfelftmzojgdwhvazk/Build/Products/Debug-iphonesimulator/innerIDMobileLicense.framework/innerIDMobileLicense (No such file or directory)
That's correct, the file isn't there! Notice in the first image below, there is a Unix Executable File IdAirOpenCv. Then look at the second image and notice that IdAirOpenCv isn't there.
This is what I am used to seeing prior to upgrading:
This is what I have now:
According to the script, the Unix Executable File innerIDMobileLicense should be located inside all three of the framework folders at the same level as the Headers and Modules folders.
Does anybody have a clue what I am doing wrong?
This lipo error you got is most likely due to the containing directory does not exists.
The script is created when xcode does not have a framework project.
Lipo basically links two binary build for different architecture together to build a fat one.
Either one will work. Lipo can link the binary inside the framework and a simple static library
What I did is to create a static library project, and a framework project. Set the static library target to be either device or simulator (using sdk iphoneos or iphonesimulator. Add the Universal Framework script into the framework project to build the static library with the other sdk and put the fat binary to the framework. Also copy needed headers to the framework project. The framework do not need to compile anything.
这篇关于Xcode6创建Fat静态库iOS通用框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!