【问题标题】:Building iOS framework missing architecture armv7s and x86_64 on fat file在 fat 文件上构建 iOS 框架缺少架构 armv7s 和 x86_64
【发布时间】:2015-02-02 03:05:54
【问题描述】:

我正在按照现场指南构建自己的框架

Create a framework for iOS - RayWenderlich

它运行良好,但是当我将框架集成到测试项目中时,它会将错误捕获为“架构 arm64 的未定义符号”。当我通过命令检查支持的架构时

<myframework>.framework xcrun lipo -info <myframework>

它错过了 2 个架构 armv7s 和 x86_64

这是我在聚合目标上的运行脚本

set -e

# If we're already inside this script then die
if [ -n "$RW_MULTIPLATFORM_BUILD_IN_PROGRESS" ]; then
exit 0
fi
export RW_MULTIPLATFORM_BUILD_IN_PROGRESS=1

RW_FRAMEWORK_NAME=${PROJECT_NAME}
RW_INPUT_STATIC_LIB="lib${PROJECT_NAME}.a"
RW_FRAMEWORK_LOCATION="${BUILT_PRODUCTS_DIR}/${RW_FRAMEWORK_NAME}.framework"

function build_static_library {
    # Will rebuild the static library as specified
    #     build_static_library sdk
    xcrun xcodebuild -project "${PROJECT_FILE_PATH}" \
    -target "${TARGET_NAME}" \
    -configuration "${CONFIGURATION}" \
    -sdk "${1}" \
    ONLY_ACTIVE_ARCH=NO \
    BUILD_DIR="${BUILD_DIR}" \
    OBJROOT="${OBJROOT}" \
    BUILD_ROOT="${BUILD_ROOT}" \
    SYMROOT="${SYMROOT}" $ACTION
}

function make_fat_library {
    # Will smash 2 static libs together
    #     make_fat_library in1 in2 out
    xcrun lipo -create "${1}" "${2}" -output "${3}"
}

# 1 - Extract the platform (iphoneos/iphonesimulator) from the SDK name
if [[ "$SDK_NAME" =~ ([A-Za-z]+) ]]; then
RW_SDK_PLATFORM=${BASH_REMATCH[1]}
else
echo "Could not find platform name from SDK_NAME: $SDK_NAME"
exit 1
fi

# 2 - Extract the version from the SDK
if [[ "$SDK_NAME" =~ ([0-9]+.*$) ]]; then
RW_SDK_VERSION=${BASH_REMATCH[1]}
else
echo "Could not find sdk version from SDK_NAME: $SDK_NAME"
exit 1
fi

# 3 - Determine the other platform
if [ "$RW_SDK_PLATFORM" == "iphoneos" ]; then
RW_OTHER_PLATFORM=iphonesimulator
else
RW_OTHER_PLATFORM=iphoneos
fi

# 4 - Find the build directory
if [[ "$BUILT_PRODUCTS_DIR" =~ (.*)$RW_SDK_PLATFORM$ ]]; then
RW_OTHER_BUILT_PRODUCTS_DIR="${BASH_REMATCH[1]}${RW_OTHER_PLATFORM}"
else
echo "Could not find other platform build directory."
exit 1
fi

# Build the other platform.
build_static_library "${RW_OTHER_PLATFORM}${RW_SDK_VERSION}"

# If we're currently building for iphonesimulator, then need to rebuild
#   to ensure that we get both i386 and x86_64
if [ "$RW_SDK_PLATFORM" == "iphonesimulator" ]; then
build_static_library "${SDK_NAME}"
fi

# Join the 2 static libs into 1 and push into the .framework
make_fat_library "${BUILT_PRODUCTS_DIR}/${RW_INPUT_STATIC_LIB}" \
"${RW_OTHER_BUILT_PRODUCTS_DIR}/${RW_INPUT_STATIC_LIB}" \
"${RW_FRAMEWORK_LOCATION}/Versions/A/${RW_FRAMEWORK_NAME}"

# Ensure that the framework is present in both platform's build directories
cp -a "${RW_FRAMEWORK_LOCATION}/Versions/A/${RW_FRAMEWORK_NAME}" \
"${RW_OTHER_BUILT_PRODUCTS_DIR}/${RW_FRAMEWORK_NAME}.framework/Versions/A/${RW_FRAMEWORK_NAME}"

# Copy the framework to the user's desktop
ditto "${RW_FRAMEWORK_LOCATION}" "${HOME}/Desktop/${RW_FRAMEWORK_NAME}.framework"

我认为在集成框架以测试项目时的构建错误是由于构建框架时缺少架构造成的

【问题讨论】:

  • 关于这方面的任何消息,我只缺少 armv7s。
  • @Sanandrea,在架构上我添加了 2 个架构 armv7 和 armv7s,在有效架构上,我添加了所有架构,包括 armv7、armv7s、arm64、i386 和 x86_64。解决我的问题
  • 我遇到了类似的问题,除了出于某种原因它只想在最终的 fat 文件中生成 i386 和 x86_64

标签: ios frameworks


【解决方案1】:

在我的情况下已解决:在主要目标(RWUIControls,如果您参考 Ray W. 帖子)中,我手动添加了 armv7s 架构。

请看下面的截图:

如果我从终端运行命令:

xcrun lipo -info RWUIControls 

现在我在框架文件夹中:

Architectures in the fat file: RWUIControls are: armv7 armv7s i386 x86_64 arm64

【讨论】:

    【解决方案2】:

    只需在项目Info中更改iOS Development Target即可。

    在我的情况下,我选择了 iOS 13,然后我将其更改为 iOS 10,现在我有了这些 Archs -> armv7 i386 x86_64 arm64。

    这些是取决于 iOS 设备的架构。

    armv64:iPhoneX、iPhone 5s-8、iPad Air — iPad Pro armv7 : iPhone3Gs-5c, iPad WIFI(第四代) armv6 : iPhone — iPhone3G 以上如果适用于真实设备 i386 : 32 位模拟器 x86_64 : 64位模拟器

    【讨论】:

      猜你喜欢
      • 2012-03-26
      • 1970-01-01
      • 2015-10-10
      • 2015-04-23
      • 1970-01-01
      • 2016-02-03
      • 2018-08-02
      • 2012-01-16
      • 2013-10-15
      相关资源
      最近更新 更多