美文网首页
2020-05-23IOS创建 FRAMEWORK包含所有cpu

2020-05-23IOS创建 FRAMEWORK包含所有cpu

作者: 亮仔菲个 | 来源:发表于2020-05-23 11:04 被阅读0次

    1、需要添加的脚本

    if["${ACTION}"="build"]

    then

    INSTALL_DIR=${SRCROOT}/Products/${PROJECT_NAME}.framework

    DEVICE_DIR=${BUILD_ROOT}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework

    SIMULATOR_DIR=${BUILD_ROOT}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework

    if[ -d"${INSTALL_DIR}"]

    then

    rm -rf"${INSTALL_DIR}"

    fi

    mkdir -p"${INSTALL_DIR}"

    cp -R"${DEVICE_DIR}/""${INSTALL_DIR}/"

    #ditto "${DEVICE_DIR}/Headers" "${INSTALL_DIR}/Headers"

    lipo -create"${DEVICE_DIR}/${PROJECT_NAME}""${SIMULATOR_DIR}/${PROJECT_NAME}"-output"${INSTALL_DIR}/${PROJECT_NAME}"

    open"${DEVICE_DIR}"

    open"${SRCROOT}/Products"

    fi需要添加的脚本

    if["${ACTION}"="build"]

    then

    INSTALL_DIR=${SRCROOT}/Products/${PROJECT_NAME}.framework

    DEVICE_DIR=${BUILD_ROOT}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework

    SIMULATOR_DIR=${BUILD_ROOT}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework

    if[ -d"${INSTALL_DIR}"]

    then

    rm -rf"${INSTALL_DIR}"

    fi

    mkdir -p"${INSTALL_DIR}"

    cp -R"${DEVICE_DIR}/""${INSTALL_DIR}/"

    #ditto "${DEVICE_DIR}/Headers" "${INSTALL_DIR}/Headers"

    lipo -create"${DEVICE_DIR}/${PROJECT_NAME}""${SIMULATOR_DIR}/${PROJECT_NAME}"-output"${INSTALL_DIR}/${PROJECT_NAME}"

    open"${DEVICE_DIR}"

    open"${SRCROOT}/Products"

    fi

    2、# Sets the target folders and the final framework product.

    # 如果工程名称和Framework的Target名称不一样的话,要自定义FMKNAME

    # 例如: FMK_NAME = "MyFramework"

    FMK_NAME=${PROJECT_NAME}

    # Install dir will be the final output to the framework.

    # The following line create it in the root folder of the current project.

    INSTALL_DIR=${SRCROOT}/Products/${FMK_NAME}.framework

    # Working dir will be deleted after the framework creation.

    WRK_DIR=build

    DEVICE_DIR=${WRK_DIR}/Release-iphoneos/${FMK_NAME}.framework

    SIMULATOR_DIR=${WRK_DIR}/Release-iphonesimulator/${FMK_NAME}.framework

    # -configuration ${CONFIGURATION}

    # Clean and Building both architectures.

    xcodebuild -configuration"Release"-target"${FMK_NAME}"-sdk iphoneos -arch armv7 -arch armv7s -arch arm64 clean build

    xcodebuild -configuration"Release"-target"${FMK_NAME}"-sdk iphonesimulator -arch x86_64 clean build

    # Cleaning the oldest.

    if[-d"${INSTALL_DIR}"]

    then

    rm -rf"${INSTALL_DIR}"

    fi

    mkdir -p"${INSTALL_DIR}"

    cp -R"${DEVICE_DIR}/""${INSTALL_DIR}/"

    # Uses the Lipo Tool to merge both binary files (i386 + armv6/armv7) into one Universal final product.

    lipo -create"${DEVICE_DIR}/${FMK_NAME}""${SIMULATOR_DIR}/${FMK_NAME}"-output"${INSTALL_DIR}/${FMK_NAME}"

    rm -r"${WRK_DIR}"

    open"${SRCROOT}/Products/"

    3、

    FMK_NAME=${PROJECT_NAME}

    INSTALL_DIR=${SRCROOT}/Products/${FMK_NAME}.framework

    WRK_DIR=build

    DEVICE_DIR=${WRK_DIR}/Release-iphoneos/${FMK_NAME}.framework

    SIMULATOR_DIR=${WRK_DIR}/Release-iphonesimulator/${FMK_NAME}.framework

    xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphoneos clean build

    #Xcode10此次clean会把当前目录删除然后,重新编译生成新的(即上一步真机生成)。

    xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphonesimulator

    #clean build

    if [ -d "${INSTALL_DIR}" ]

    then

    rm -rf "${INSTALL_DIR}"

    fi

    mkdir -p "${INSTALL_DIR}"

    cp -R "${DEVICE_DIR}/" "${INSTALL_DIR}/"

    lipo -create "${DEVICE_DIR}/${FMK_NAME}" "${SIMULATOR_DIR}/${FMK_NAME}" -output "${INSTALL_DIR}/${FMK_NAME}"

    rm -r "${WRK_DIR}"

    open "${SRCROOT}/Products/"

    4、需要 配置的

    Build Settings >> Dead Code Stripping >> 设置为NO

    Build Settings >> Strip Debug Symbol During Copy >> 全部设置为NO

    Build Settings >> Strip Style >> 设置为Non-Global Symbols

    Build Settings >>  Link With Standard Libraries >> 设置为 NO

    Build Settings >>  Mach-O Type >> Static Library

    对于Mach-O Type:选择 Static Library 打包得到的是静态库

    5、报错 Showing Recent Messages    Undefined symbol: ___isPlatformVersionAtLeast

    从错误信息来看,是 __isPlatformVersionAtLeast 方法没有具体的实现,但是工程里根本没有这个方法。实际测试无论在哪里使用@available ,并使用 Xcode 11 打包成动态库或静态库,把打包的库添加到 Xcode 10 中编译都会出现这个错误,因此可以判断是 iOS 13 的 @available 的实现中使用了新的 api。

    解决 方法:if([UIDevice currentDevice].systemVersion.floatValue>=13.0){...}

    相关文章

      网友评论

          本文标题:2020-05-23IOS创建 FRAMEWORK包含所有cpu

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