如何使用bitcode选项制作胖框架? [英] How do i make fat framework with bitcode option?

查看:83
本文介绍了如何使用bitcode选项制作胖框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环境:XCode 7.0.1 模块:Objective-C 捆绑类型:框架

Environment: XCode 7.0.1 Module: Objective-C Bundle Type: Framework

我正在尝试创建一个框架来支持armv7,armv7s,arm64,i386和x86_64.我正在使用聚合来制作胖子库.在聚合脚本中,我正在运行两个xcodebuild命令1.用于armv7,armv7s和arm64,以及2.用于i386和x86_64体系结构.另外,我在目标构建设置下设置了Enable Bitcode = YES和Other C Flags = -fembed-bitcode.作为预防措施,我向xcodebuild命令添加了ENABLE_BITCODE = YES和OTHER_CFLAGS =-fembed-bitcode"选项

Hi, I am trying to create a framework to support armv7, armv7s, arm64, i386 and x86_64. I am using aggregate to make the fat library. Inside the aggregate script, i am running two xcodebuild commands 1. for armv7, armv7s and arm64 and 2. for i386 and x86_64 architectures. Also, I have set Enable Bitcode=YES and Other C Flags=-fembed-bitcode under target build settings. As a precautionary mesasure, i am adding ENABLE_BITCODE=YES and OTHER_CFLAGS="-fembed-bitcode" options to the xcodebuild command

我的xcode构建命令如下-

My xcode build commands are as follows -

#Build The framework Target for iPhoneOS
xcodebuild -project "${PROJECT_FILE_PATH}" -target "${AN_TARGET}" 
ONLY_ACTIVE_ARCH=NO -configuration "${CONFIGURATION}" -sdk iphoneos 
BUILD_DIR="${BUILD_DIR}" OBJROOT="${OBJROOT}" BUILD_ROOT="${BUILD_ROOT}" 
CONFIGURATION_BUILD_DIR="${IPHONE_DEVICE_BUILD_DIR}" SYMROOT="${SYMROOT}" 
ARCHS="armv7 armv7s arm64" ENABLE_BITCODE=YES OTHER_CFLAGS="-fembed-bitcode" $ACTION

#Build The framework Target for iPhoneSimulator
xcodebuild -project "${PROJECT_FILE_PATH}" -target "${AN_TARGET}" 
ONLY_ACTIVE_ARCH=NO -configuration "${CONFIGURATION}" -sdk iphonesimulator 
BUILD_DIR="${BUILD_DIR}" OBJROOT="${OBJROOT}" BUILD_ROOT="${BUILD_ROOT}" 
CONFIGURATION_BUILD_DIR="${IPHONE_SIMULATOR_BUILD_DIR}" SYMROOT="${SYMROOT}" 
ARCHS="i386 x86_64" ENABLE_BITCODE=YES OTHER_CFLAGS="-fembed-bitcode" $ACTION

运行上述两个命令后,我将使用以下命令将这两个构建组合在一起,以使胖框架成为二进制文件

after running the above two commands, i am combining these two builds to make a fat framework binary using the below command

# create a fat Framework
lipo -create 
"${IPHONE_DEVICE_BUILD_DIR}/${PROJECT_NAME}.framework/${PROJECT_NAME}" 
"${IPHONE_SIMULATOR_BUILD_DIR}/${PROJECT_NAME}.framework/${PROJECT_NAME}" -
output "${FRAMEWORK_FOLDER}/${AN_END_USER_FRAMEWORK_NAME}"

在创建lipo后,iam面临的问题是,我无法在启用了位码的应用程序中使用它.运行otool -l framework_binary | grep -LLVM之后,我看不到启用了位码的标志或__LLVM.

The issue iam facing is after the lipo is created, i am unable to use it in the bitcode enabled application. After running the otool -l framework_binary | grep -LLVM, i do not see the bitcode enabled flags or __LLVM.

Lipo从胖二进制文件中删除位代码.我有什么方法可以在执行lipo命令时保留位码吗?

Lipo removes bitcode from the fat binary. Is there a way i can retain bitcode while running the lipo command?

更正:根据内斯特的回复,我以otool -l -arch armv7 framework_binary | grep LLVM的身份运行了otool命令,令我惊讶的是,我看到了segname __LLVM叮当声.但是,当我将相同的胖框架二进制文件集成到我的项目中时,它可以在模拟器上很好地构建,但是在设备-ld上运行时会引发以下错误:'MyBinary'不包含位码.您必须在启用位码(Xcode设置ENABLE_BITCODE)的情况下重建它,从供应商处获取更新的库,或禁用此目标的位码.用于架构armv7

Correction: Based on the reply from Nestor, i ran the otool command as otool -l -arch armv7 framework_binary | grep LLVM and much to my surprise, i could see the segname __LLVM clang. However when i integrate the same fat framework binary into my project, it builds fine on simulator however throws the following error while running on device - ld: 'MyBinary' 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. for architecture armv7

推荐答案

这很奇怪,没有太多相关文档,最后我使用以下命令:

This is something weird, there are not many documentation for do this, at the end I use this command:

xcodebuild -project ${PROJECT_NAME}.xcodeproj -target ${FRAMEWORK_NAME} ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode FRAMEWORK_SEARCH_PATHS="${FRAMEWORK_SEARCH_PARTH} ${SRCROOT}/**" -sdk ${SIMULATOR_SDK} -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-${SIMULATOR_SDK} 2>&1

xcodebuild -project ${PROJECT_NAME}.xcodeproj -target ${FRAMEWORK_NAME} -sdk ${DEVICE_SDK} ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode FRAMEWORK_SEARCH_PATHS="${FRAMEWORK_SEARCH_PARTH} ${SRCROOT}/**" -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-${DEVICE_SDK} 2>&1

在xcodebuild命令中添加BITCODE_GENERATION_MODE = bitcode标志

Add the BITCODE_GENERATION_MODE=bitcode flag to the xcodebuild command

这篇关于如何使用bitcode选项制作胖框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆