美文网首页工作生活
快速创建真机和模拟器framework

快速创建真机和模拟器framework

作者: iOS白水 | 来源:发表于2019-07-02 11:26 被阅读0次
    
    ######################
    # Options
    ######################
    
    #verbose
    set -x
    
    REVEAL_ARCHIVE_IN_FINDER=true
    
    FRAMEWORK_NAME="这里修改名称"
    
    SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework"
    
    DEVICE_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphoneos/${FRAMEWORK_NAME}.framework"
    
    UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/${CONFIGURATION}-iphoneuniversal"
    
    FRAMEWORK="${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_NAME}.framework"
    
    
    ######################
    # Build Frameworks
    ######################
    # Build for simulator
    xcrun xcodebuild BITCODE_GENERATION_MODE=bitcode OTHER_CFLAGS="-fembed-bitcode" -target ${FRAMEWORK_NAME} -sdk iphonesimulator -configuration ${CONFIGURATION} ARCHS="i386 x86_64" ONLY_ACTIVE_ARCH=NO clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphonesimulator
    
    # Build for device
    xcrun xcodebuild BITCODE_GENERATION_MODE=bitcode OTHER_CFLAGS="-fembed-bitcode" -target ${FRAMEWORK_NAME} -sdk iphoneos -configuration ${CONFIGURATION} ARCHS="armv7 armv7s arm64" ONLY_ACTIVE_ARCH=NO clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphoneos
    
    ######################
    # Create directory for universal
    ######################
    
    rm -rf "${UNIVERSAL_LIBRARY_DIR}"
    
    mkdir "${UNIVERSAL_LIBRARY_DIR}"
    
    mkdir "${FRAMEWORK}"
    
    
    ######################
    # Copy files Framework
    ######################
    
    cp -r "${DEVICE_LIBRARY_PATH}/." "${FRAMEWORK}"
    
    
    ######################
    # Make an universal binary
    ######################
    
    lipo "${SIMULATOR_LIBRARY_PATH}/${FRAMEWORK_NAME}" "${DEVICE_LIBRARY_PATH}/${FRAMEWORK_NAME}" -create -output "${FRAMEWORK}/${FRAMEWORK_NAME}" | echo
    
    # For Swift framework, Swiftmodule needs to be copied in the universal framework
    if [ -d "${SIMULATOR_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/" ]; then
    cp -f ${SIMULATOR_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/* "${FRAMEWORK}/Modules/${FRAMEWORK_NAME}.swiftmodule/" | echo
    fi
    
    if [ -d "${DEVICE_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/" ]; then
    cp -f ${DEVICE_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/* "${FRAMEWORK}/Modules/${FRAMEWORK_NAME}.swiftmodule/" | echo
    fi
    
    ######################
    # On Release, copy the result to release directory
    ######################
    OUTPUT_DIR="${PROJECT_DIR}/build/${FRAMEWORK_NAME}-${CONFIGURATION}-iphoneuniversal/"
    
    rm -rf "$OUTPUT_DIR"
    mkdir -p "$OUTPUT_DIR"
    
    cp -r "${FRAMEWORK}" "$OUTPUT_DIR"
    
    if [ ${REVEAL_ARCHIVE_IN_FINDER} = true ]; then
    open "${OUTPUT_DIR}/"
    fi
    
    

    framework target版本号改一下,改成支持iOS8

    参考:
    https://www.jianshu.com/p/5959c6467dd7

    相关文章

      网友评论

        本文标题:快速创建真机和模拟器framework

        本文链接:https://www.haomeiwen.com/subject/qizacctx.html