我不能保证这会解决你的这个问题的版本。但我终于得到了我的工作。
说要删除 i386 和 x86_64 的人有部分答案。
在我的目标中,我将架构部分设置如下
Architectures <multiple values>
Debug
Standard Architectures <$(ARCHS_STANDARD)>
Any iOS Simulator SDK <i386 x86_64>
Any iOS SDK <$(ARCHS_STANDARD)>
Release
Standard Architectures <$(ARCHS_STANDARD)>
Any iOS Simulator SDK <i386 x86_64>
Any iOS SDK <$(ARCHS_STANDARD)>
Base SDK <Latest iOS>
Build active Architecture only <No>
Supported Platforms <iOS>
Valid Architectures <armv7 arm64 i386 x86_64>
然后我创建了另一个目标。这是一个聚合(File->new->Target->iOS->Other->Aggregate)我没有更改此目标的构建设置,将它们全部保留为默认值。在 Build Phases 部分,我将预先存在的目标拖到“Target Dependencies”部分。
在运行脚本部分,我放置了以下内容。
# define output folder environment variable
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# Step 1. Build Device and Simulator versions
xcodebuild -target MiniZip ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"
xcodebuild -target MiniZip ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphonesimulator BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 2. Create universal binary file using lipo "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/lib${PROJECT_NAME}.a"
lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/lib${PROJECT_NAME}.a" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/lib${PROJECT_NAME}.a" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/lib${PROJECT_NAME}.a"
# Last touch. copy the header files. Just for convenience
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphoneos/include" "${UNIVERSAL_OUTPUTFOLDER}/"
我试图将 MiniZip 库构建为 4 路胖库,所以在我的脚本显示“MiniZip”的地方,你显然会输入你的目标名称。
而我的最终结果?
Admins-Mac-mini-2:scratch JoeC$ file libminizip.a
libminizip.a: Mach-O universal binary with 4 architectures
libminizip.a (for architecture armv7): current ar archive random library
libminizip.a (for architecture i386): current ar archive random library
libminizip.a (for architecture x86_64): current ar archive random library
libminizip.a (for architecture arm64): current ar archive random library
成功!好吧,反正对我来说。我希望这也能解决你的问题!
编辑:我应该把大部分功劳归功于 Ray Wenderlich。我的剧本是基于他发布的。