存档时,Swift嵌入式框架构建失败

时间:2016-01-23 09:26:30

标签: ios xcode swift frameworks archive

我在项目中添加了一个快速框架作为子项目。当我在模拟器和设备上运行时,它工作正常。但是,当我尝试归档主要产品时,它失败并出现错误:
" /Users/mac/Library/Developer/Xcode/DerivedData/ProductName-bhtbyknuwzpjjwaadaqiytxtzypo/Build/Intermediates/ArchiveIntermediates/ProductName/BuildProductsPath/Release-iphonesimulator/MyFramework.framework:No这样的文件或目录" 我搜索了那条路径,结束了文件夹" / Users / mac / Library / Developer / Xcode / DerivedData / ProductName-bhtbyknuwzpjjwaadaqiytxtzypo / Build / Intermediates / ArchiveIntermediates / ProductName / BuildProductsPath&#34 它只有三个子文件夹:

  • 推出-的iPhoneOS
  • 释放的通用
  • SwiftSupport

左,没有" Release-iphonesimulator" 文件夹。

这是框架的构建脚本:

set -e
set +u
# Avoid recursively calling this script.
if [[ $SF_MASTER_SCRIPT_RUNNING ]]
then
exit 0
fi
set -u
export SF_MASTER_SCRIPT_RUNNING=1


# Constants
SF_TARGET_NAME=${PROJECT_NAME}
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal

# Take build target
if [[ "$SDK_NAME" =~ ([A-Za-z]+) ]]
then
SF_SDK_PLATFORM=${BASH_REMATCH[1]}
else
echo "Could not find platform name from SDK_NAME: $SDK_NAME"
exit 1
fi

#if [[ "$SF_SDK_PLATFORM" = "iphoneos" ]]
#then
#echo "Please choose iPhone simulator as the build target."
#exit 1
#fi

IPHONE_DEVICE_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphoneos

# Build the other (non-simulator) platform
xcodebuild -project "${PROJECT_FILE_PATH}" -target "${TARGET_NAME}" -configuration "${CONFIGURATION}" -sdk iphoneos BUILD_DIR="${BUILD_DIR}" OBJROOT="${OBJROOT}" BUILD_ROOT="${BUILD_ROOT}" CONFIGURATION_BUILD_DIR="${IPHONE_DEVICE_BUILD_DIR}/arm64" SYMROOT="${SYMROOT}" ARCHS='arm64' VALID_ARCHS='arm64' $ACTION

xcodebuild -project "${PROJECT_FILE_PATH}" -target "${TARGET_NAME}" -configuration "${CONFIGURATION}" -sdk iphoneos BUILD_DIR="${BUILD_DIR}" OBJROOT="${OBJROOT}" BUILD_ROOT="${BUILD_ROOT}"  CONFIGURATION_BUILD_DIR="${IPHONE_DEVICE_BUILD_DIR}/armv7" SYMROOT="${SYMROOT}" ARCHS='armv7 armv7s' VALID_ARCHS='armv7 armv7s' $ACTION

# Copy the framework structure to the universal folder (clean it first)
rm -rf "${UNIVERSAL_OUTPUTFOLDER}"
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework"

# Smash them together to combine all architectures
lipo -create  "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/arm64/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/armv7/${PROJECT_NAME}.framework/${PROJECT_NAME}" -output "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}"

注意: 我评论了以下内容,因为仅使用设备sdk平台(非模拟器)启用了归档

if [[ "$SF_SDK_PLATFORM" = "iphoneos" ]]
then
echo "Please choose iPhone simulator as the build target."
exit 1
fi

1 个答案:

答案 0 :(得分:0)

  • 在尝试将它们脂在一起之前先构建模拟器。

    echo "Building for iPhoneSimulator"
    xcodebuild -workspace "${WORKSPACE_PATH}" -scheme "${TARGET_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 7' ONLY_ACTIVE_ARCH=NO ARCHS='i386 x86_64' BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" ENABLE_BITCODE=YES OTHER_CFLAGS="-fembed-bitcode" BITCODE_GENERATION_MODE=bitcode clean build
    
  • 还请确保输出目录存在

    mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
    

    将此内容置于评论中

    #Take build target