手动集成 SDK 打包失败问题
更新时间: 2025/07/15 16:59:37
问题描述
通过手动集成方式集成 IM iOS SDK 后,打包失败。
问题原因
在 手动集成 SDK 时,由于库包含模拟器版本,可能会导致打包失败。所以需要在打包之前去掉模拟器版本。
解决方法
-
在工程里创建
nim_strip_archs.sh脚本到指定目录,如Supporting Files。 -
在
Build Phases中增加过程,类型为New Run Script Phase。 -
在工程里添加以下内容。如
/bin/sh "${SRCROOT}/NIMDemo/Supporting Files/nim_strip_archs.sh"。Bash
/bin/sh 您的脚本路径 -
将以下内容复制到脚本中。
Bash#!/bin/sh # Strip invalid architectures strip_invalid_archs() { binary="$1" echo "current binary ${binary}" # Get architectures for current file archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" stripped="" for arch in $archs; do if ! [[ "${ARCHS}" == *"$arch"* ]]; then if [ -f "$binary" ]; then # Strip non-valid architectures in-place lipo -remove "$arch" -output "$binary" "$binary" || exit 1 stripped="$stripped $arch" fi fi done if [[ "$stripped" ]]; then echo "Stripped $binary of architectures:$stripped" fi } 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" strip_invalid_archs "$FRAMEWORK_EXECUTABLE_PATH" done
此文档是否对你有帮助?





