• ios .a和.framework


    创建Aggregate来合并模拟器和真机通用的framework

    然后在Build Phases下New Run Script Phase创建合并脚本:

    # Constants
    SF_TARGET_NAME=${PROJECT_NAME}
    #自定义的用来存放最后合并的framework
    UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
    #IPHONE_DEVICE_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphoneos
    WORKSPACE_NAME=${PROJECT_NAME}.xcworkspace
    YO_SCHEME=${PROJECT_NAME}
    #clean build是先清除原来的build
    xcodebuild -workspace ${WORKSPACE_NAME} -scheme ${YO_SCHEME} -sdk iphonesimulator -configuration"${CONFIGURATION}"clean build
    xcodebuild -workspace ${WORKSPACE_NAME} -scheme ${YO_SCHEME} -sdk iphoneos -configuration"${CONFIGURATION}"clean build
    # build project
    #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)
    #因为framework的合并,lipo只是合并了最后的二进制可执行文件,所以其它的需要我们自己复制过来
    #先移除原来的
    rm -rf "${UNIVERSAL_OUTPUTFOLDER}"
    mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
    cp -R "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework"
    #合并模拟器和真机的架构
    lipo -create  "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}""${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework/${PROJECT_NAME}"-output"${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}"
    open "${UNIVERSAL_OUTPUTFOLDER}"

    对于以上的脚本,其中用到了很多的 xcode预定义的变量,这些变量怎么来的呢?你可以在命令行下, 输入

    xcodebuild -workspace YohunlUtilsLib.xcworkspace -scheme YohunlUtilsLib -sdk iphonesimulator -configuration Debug -showBuildSettings > xcodebuild_showBuildSettings.txt

    来将所有的xcode预定义变量都导入到文本xcodebuild_showBuildSettings.txt 中,然后你就可以选用你需要的啦

    当然了,我们一般都应该合并release模式的,而不是debug模式的framework

    查看.framework的信息:

    lipo -info aa.framework/aa

    显示:

    Architectures in the fat file: aa.framework/aa are: armv7 arm64

    说明我们生成的真机framework:aa.framework 包含了两种架构 armv7 arm64

    分离架构(以分离armv7为例)

      当前目录建立文件夹,用于存放分离后的架构,和分离出的.o文件

    mkdir armV7

    分离出armv7架构到文件夹armV7下:

    lipo aa.framework/aa -thin armv7 -output ./armv7/aa_armv7

    分离armv7架构所有的.o文件

    cd armV7
    ar -x aa_armv7
  • 相关阅读:
    1049: 贝贝的车牌问题(car)
    漂亮的验证码(.Net MVC)
    低危漏洞- X-Frame-Options Header未配置
    Linq中的连接(join)
    定时执行任务FluentScheduler
    NET定时任务执行管理器开源组件–FluentScheduler
    在ASP.NET中如何运行后台任务
    【译】微型ORM:PetaPoco
    3389凭据不工作
    C# LDAP认证登录
  • 原文地址:https://www.cnblogs.com/wenrisheng/p/6189098.html
Copyright © 2020-2023  润新知