iOS 添加第三方.framework 打包上传iTunesConnect 遇到的坑

1、添加完第三方库,模拟器运行没事,打iOS通用设备包的时候报一个错。

ld: '/Users/jiangwei.wang/Documents/Project/APP NAME/SeosMobileKeysSDK.framework/SeosMobileKeysSDK' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '/Users/jiangwei.wang/Documents/Project/APP NAME/SeosMobileKeysSDK.framework/SeosMobileKeysSDK' for architecture arm64

 大概意思是说用的第三方库 不包含 bitcode ,要么需要第三方库包含 bitcode ,要么把 enable bitcode 设置为NO.

 第三方库没有乱动,target->build setting->search "enable bitcode" 把 enable bitcode 设置为NO.重新编译。build success

 2、第一步完成之后,打好包,上传到iTunes connect 时遇到的错误:

错误类型(1)、

  ERROR ITMS-90087: "Unsupported Architectures. The executable for APP NAME.app/Frameworks/BerTlv.framework contains unsupported architectures '[x86_64, i386]'."

大概意思是说,*.framework 包含了上架不需要的架构('[x86_64, i386]')支持。应该去除。

错误类型 (2)、

ERROR ITMS-90209: "Invalid Segment Alignment. The app binary at 'APP NAME.app/Frameworks/BerTlv.framework/BerTlv' does not have proper segment alignment. Try rebuilding the app with the latest Xcode version."

错误类型 (3)、

ERROR ITMS-90125: "The binary is invalid. The encryption info in the LC_ENCRYPTION_INFO load command is either missing or invalid, or the binary is already encrypted. This binary does not seem to have been built with Apple's linker."

以上2、3个错误都应该是错误类型1导致的。

解决办法:去除第三方框架中不需要的架构支持

  target --> build Phases --> 第一行最左边+ --> new run script support.

  注意:最好把脚本下面的 “run scripts only on installing”, 不然的话,跑模拟器是会报错的:原因是,真机调试或者打包不需要 i386 支持, 真机是 苹果的A7, A10 等处理器架构,ARMS V7S 等,但是 在 MAC 上,模拟器的处理器还是基于Intel CPU的 i386架构的。

 

Showing Recent Errors Only

fatal error: lipo: -extract i386 specified but fat file: /Users/jiangwei.wang/Library/Developer/Xcode/DerivedData/APP NAME-ffatymfkewtsvbanmvhqynqbhveq/Build/Products/Release-iphonesimulator/APP NAME.app/Frameworks/SeosMobileKeysSDK.framework/SeosMobileKeysSDK does not contain that architecture

 

 

  在脚本添加以下语句。可以保证打包时去除不必要的架构支持

用脚本:

 

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    

  

 

 

 

 

 

 

 

 

 

 

posted @ 2018-04-03 14:22  wjwdive  阅读(1366)  评论(0编辑  收藏  举报