2018技术笔记

2018笔记——处理静态库

2018-07-28  本文已影响32人  满庭花醉三千客

将自建的framework添加到项目中,然后上传到App store时报错:

屏幕快照 2018-07-25 下午3.34.34.png

得知我们上传时,需要把x86_64架构移除掉。

解决方案:

选中项目,然后找到Build Phases,然后添加Run Script

屏幕快照 2018-07-25 下午3.48.58.png

添加的内容:

# Without further ado, here’s the script. Add a Run Script step to your build steps, put it after your step to embed frameworks, set it to use /bin/sh and enter the following script:APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"# This script loops through the frameworks embedded in the application and# removes unused architectures.find "$APP_PATH"-name '*.framework'-typed | whileread-r FRAMEWORKdoFRAMEWORK_EXECUTABLE_NAME=$(defaults read"$FRAMEWORK/Info.plist"CFBundleExecutable) FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"echo"Executable is $FRAMEWORK_EXECUTABLE_PATH"EXTRACTED_ARCHS=()forARCH in$ARCHSdoecho"Extracting $ARCHfrom $FRAMEWORK_EXECUTABLE_NAME"lipo -extract "$ARCH""$FRAMEWORK_EXECUTABLE_PATH"-o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")doneecho"Merging extracted architectures: ${ARCHS}"lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged"-create "${EXTRACTED_ARCHS[@]}"rm "${EXTRACTED_ARCHS[@]}"echo"Replacing original executable with thinned version"rm "$FRAMEWORK_EXECUTABLE_PATH"mv "$FRAMEWORK_EXECUTABLE_PATH-merged""$FRAMEWORK_EXECUTABLE_PATH"done

然后重新打包就可以了。

加油~

上一篇 下一篇

猜你喜欢

热点阅读