ios 检查并删除 IPA / Archive 中不支持的架构 [x86_64, i386]
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42641806/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Check and Remove Unsupported Architecture [x86_64, i386] in IPA / Archive
提问by user1046037
Problem:
问题:
While submitting the app to the App Store the following error is reported:
提交应用到App Store时报如下错误:
Unsupported Architecture. Your executable contains unsupported architecture '[x86_64, i386]
Unsupported Architecture. Your executable contains unsupported architecture '[x86_64, i386]
Questions:
问题:
How can the above error be resolved ?
How can I check the architectures used by the archive or IPA ?
How can I ensure that the
Release
archive doesn't includex86_64
andi386
(simulator architectures).- Is it only possible through script or is there is a setting in
Build Settings
or else where ?
- Is it only possible through script or is there is a setting in
如何解决上述错误?
如何检查存档或 IPA 使用的架构?
我如何确保
Release
存档不包含x86_64
和i386
(模拟器架构)。- 是否只能通过脚本或是否有设置
Build Settings
或其他地方?
- 是否只能通过脚本或是否有设置
回答by nikdange_me
Apple has started complaining if app contains simulator architectures during distribution.
如果应用程序在分发过程中包含模拟器架构,Apple 已经开始抱怨。
How can the above error be resolved ?
如何解决上述错误?
Solution :
解决方案 :
Add below code in run script of Project target, this remove the simulator architecture (x86_64 and i386) from your app on building process:
在项目目标的运行脚本中添加以下代码,这会在构建过程中从您的应用程序中删除模拟器架构(x86_64 和 i386):
Shell :
贝壳 :
/bin/sh
Code :
代码 :
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' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
EXTRACTED_ARCHS=()
for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done
echo "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
Solution :
解决方案 :
There one more solution, if you wish to do it only once. But be careful though as after doing following steps, you will not be able to run app on simulator. Do it just before deploying the app on Testflight/App-store.
还有一个解决方案,如果你只想做一次。但是请注意,在执行以下步骤后,您将无法在模拟器上运行应用程序。在将应用程序部署到 Testflight/App-store 之前执行此操作。
Go inside the your ProjectFramework.framework folder of your project from terminal. Run following commands:
从终端进入项目的 ProjectFramework.framework 文件夹。运行以下命令:
lipo -remove i386 ProjectFramework_SDK -o ProjectFramework_SDK
lipo -remove x86_64 ProjectFramework_SDK -o ProjectFramework_SDK
Check the architectures from framework?
从框架检查架构?
$ lipo -info PathToProject/ProjectName.framework/ProjectName
Output will be :→ Architectures in the fat file: ProjectName are: i386 x86_64 armv7 arm64
输出将是:→fat 文件中的架构:ProjectName 是:i386 x86_64 armv7 arm64
Ref. doc: http://ikennd.ac/blog/2015/02/stripping-unwanted-architectures-from-dynamic-libraries-in-xcode/
参考 文档:http: //ikennd.ac/blog/2015/02/stripping-unwanted-architectures-from-dynamic-libraries-in-xcode/
回答by MAhipal Singh
For custom created Dynamic Framework
对于自定义创建的动态框架
Open Terminal
Open your project drag path of respective framework to Terminal
For example,
cd /Users/mahipal/Desktop/masterTest/Alamofire.framework
Set your Framework name in below command and run
lipo -remove i386 Alamofire -o Alamofire && lipo -remove x86_64 Alamofire -o Alamofire
打开终端
打开相应框架的项目拖动路径到终端
例如,
cd /Users/mahipal/Desktop/masterTest/Alamofire.framework
在下面的命令中设置您的框架名称并运行
lipo -remove i386 Alamofire -o Alamofire && lipo -remove x86_64 Alamofire -o Alamofire
回答by Henrik Lineholm
When using the script of nikdange_me I got:
使用 nikdange_me 的脚本时,我得到:
error: exportArchive: ipatool failed with an exception: #<CmdSpec::NonZeroExcitException: ... >
error: Framework not found in dylib search path
So I altered it and used lipo -remove
instead of lipo -extract
and lipo -create
which solved my problem:
所以,我改变了它,并使用lipo -remove
的,而不是lipo -extract
和lipo -create
它解决了我的问题:
# This script loops through the frameworks embedded in the application
# and removes unused architectures.
find "${TARGET_BUILD_DIR}/${WRAPPER_NAME}" -name '*.framework' -type d | while read -r FRAMEWORK; do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
for arch in $(lipo -archs $FRAMEWORK_EXECUTABLE_PATH); do
if ! printf '%s\n' ${ARCHS[@]} | egrep -q "^$arch$"; then
lipo -remove $arch "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH"
fi
done
done