使用命令行编译xcode项目并加入版本信息

xcodebuild -workspace ${SOLUTION_NANE} -scheme ${SCHEME_NAME}  -configuration ${BUILD_CONFIRUATION} 

example:

xcodebuild -workspace Test -scheme translate  -configuration Release

那么如何查看你的工作空间有哪些scheme呢

先cd到工作空间目录下

xcodebuild -list

显示内容

Information about project "MakeFileTest":
    Targets:
        MakeFileTest

    Build Configurations:
        Debug
        Release

    If no build configuration is specified and -scheme is not passed then "Release" is used.

    Schemes:
        MakeFileTest

如果想要添加版本信息

echo 获取git版本号
svnInfoResult=`git rev-list HEAD --count`
svnVersion=${svnInfoResult##* }
DYLIB_CURRENT_VERSION="1.1.${svnVersion}"
DYLIB_COMPATIBILITY_VERSION="1.0.1"
GCC_PREPROCESSOR_DEFINITIONS="LIB_VERSION=\\\"${DYLIB_CURRENT_VERSION}\\\""



echo 编译代码

BUILD_SETTING=" -configuration $CONFIG DYLIB_CURRENT_VERSION=${DYLIB_CURRENT_VERSION} DYLIB_COMPATIBILITY_VERSION=${DYLIB_COMPATIBILITY_VERSION} GCC_PREPROCESSOR_DEFINITIONS=${GCC_PREPROCESSOR_DEFINITIONS} build"
xcodebuild -workspace ${SOLUTION_NANE} -scheme ${SCHEME_NAME}  ${BUILD_SETTING}

DYLIB_CURRENT_VERSION表示当前版本

DYLIB_COMPATIBILITY_VERSION 表示最低兼容版本

example:

xcodebuild -workspace Test -scheme translate  ${BUILD_SETTING}

还可以单独编译项目

  xcodebuild -project translate.xcodeproj -target translate ${BUILD_SETTING}
posted @ 2022-01-13 00:46  乘舟凉  阅读(188)  评论(0编辑  收藏  举报