【问题标题】:How to create universal framework in xcode6如何在 xcode6 中创建通用框架
【发布时间】:2014-11-13 10:26:40
【问题描述】:

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

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

【问题讨论】:

  • 您正在创建静态库?
  • 您的组合库(.a 文件)意味着(debug.a 和 release.a)一旦向我展示您的 lipo 语句

标签: ios ios-universal-framework


【解决方案1】:

我在 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 中产品的框架并单击在 finder 中显示。

检查“Debug-universal”文件夹并获取通用框架。

【讨论】:

  • 这对我很有用。我所做的唯一更改是删除 -arch x86_64。这导致无法在 i386 模拟器上运行(5s 之前的任何东西)的问题。 -sdk iphonesimucator 为编译器提供了足够的信息来为 i386 和 x86_64 构建。如果您明确指定一个,它将排除另一个。谢谢!
  • @Chad 你是如何删除 -arch x86_64 的。因为当我从运行脚本中删除时,它仍然没有为模拟器运行。
  • @Chad : 您需要尝试第 8 步。然后您将获得同时支持设备和模拟器的通用框架。
  • @Chad 它也没有在我的模拟器中运行。
  • @AnsariAwais 能否让我设置部署目标的方法?你做了什么?
【解决方案2】:

替换

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

干净的构建

【讨论】:

    猜你喜欢
    • 2015-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-22
    • 1970-01-01
    • 2014-10-01
    相关资源
    最近更新 更多