如何在xcode6中创建通用框架

时间:2014-11-13 10:26:41

标签: ios ios-universal-framework

我知道如何在Xcode 5中创建一个框架。但是在Xcode 6中如何结合一个模拟器框架和设备框架?当我尝试组合时,我得到代码签名错误。当我使用lipo来组合两个框架时,我也会收到错误。

错误: Command /bin/sh failed with exit code 65

2 个答案:

答案 0 :(得分:16)

我在xcode6中创建通用框架的解决方案。

请尝试以下步骤:

第1步:

File—> 
    New —> 
       Project —> 
           Framework & Library —> 
               Next —> 
                      Product Name

第2步:创建自定义类文件

第3步

Target -> 
       Build phase -> 
           Headers, 

将所有头文件公开。现在建立模拟器&设备

第4步:

File ->
    New ->
           Target ->
               iOS ->
                      Other -> 
                          Aggrigate ->somename eg: framework

第5步:

From Targets —> 
    Custom aggregate target(Eg: Framework)—> 
           Build Phase—> 
               Add Run script

第6步:在运行脚本中添加以下shell code

///

UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal

# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"

# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos  BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build

# Step 2. Copy the framework structure to the universal folder
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/"

# Step 3. Create universal binary file using lipo and place the combined executable in the copied framework directory
lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework/${PROJECT_NAME}"

第7步:

Goto active scheme —> 
    Custom aggregate —> 
           Build

第8步:现在右键点击Xcode&产品中的框架点击查看器中显示。

检查" Debug-universal“文件夹&获得通用框架。

答案 1 :(得分:0)

替换

xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build

xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build

清理构建