美文网首页持续集成 脚本
Jenkins中iOS打包shell脚本

Jenkins中iOS打包shell脚本

作者: yuandiLiao | 来源:发表于2017-08-07 14:57 被阅读220次
    ###############设置需编译的项目配置名称
    buildConfig="Release" #编译的方式,有Release,Debug,自定义的AdHoc等
    
    ##########################################################################################
    ##############################以下部分为自动生产部分,不需要手动修改############################
    ##########################################################################################
    projectName=`find . -name *.xcodeproj | awk -F "[/.]" '{print $(NF-1)}'` #项目名称
    target_name="Escort"  
    workspace_name="${target_name}.xcworkspace" 
    scheme="$target_name"  
    ExportOptionsPlistPath="./AdHocExportOptionsPlist.plist"
    
    scheme_name="Escort"
    
    # 强制删除旧的文件夹
    #rm -rf ./$scheme_name-IPA
    # 指定输出ipa路径
    export_path=./$scheme_name-IPA
    # 指定输出归档文件地址
    export_archive_path="$export_path/$scheme_name.xcarchive"
    # 指定输出ipa地址
    export_ipa_path="$export_path"
    
    projectDir=`pwd` #项目所在目录的绝对路径
    
    buildAppToDir=$projectDir/build #编译打包完成后.app文件存放的目录
    
    
    isWorkSpace=true  #判断是用的workspace还是直接project,workspace设置为true,否则设置为false
    
    echo "~~~~~~~~~~~~~~~~~~~开始编译~~~~~~~~~~~~~~~~~~~"
    
    ###############进入项目目录
    cd $projectDir
    #rm -rf ./build
    buildAppToDir=$projectDir/build #编译打包完成后.app文件存放的目录
    
    
    ###############获取版本号,bundleID
    infoPlist="$projectDir/Escort/Escort/Info.plist"
    
    bundleVersion=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" $infoPlist`
    bundleIdentifier=`/usr/libexec/PlistBuddy -c "Print CFBundleIdentifier" $infoPlist`
    bundleBuildVersion=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" $infoPlist`
    ###############开始编译app
        echo "版本信息"
        echo $bundleVersion
        echo $bundleIdentifier
    
        echo $bundleBuildVersion
        
    
        echo $projectName  
        
    
        echo -workspace
        security unlock-keychain -p "103503" ~/Library/Keychains/login.keychain
        echo "~~~~~~~~~~~~~~~~~~~pod install~~~~~~~~~~~~~~~~~~~"
        
        export LANG=en_US.UTF-8
        export LANGUAGE=en_US.UTF-8
        export LC_ALL=en_US.UTF-8
    
            #第一次执行了pod之后就不用再次执行了
        #pod install --verbose --no-repo-update  
        echo  "开始编译workspace...." 
    
    
        xcodebuild archive -workspace "$workspace_name" -scheme "$scheme" -configuration $buildConfig -archivePath $export_archive_path
    
    #CODE_SIGN_IDENTITY="iOS Distribution: Beijing Ubox Science & Trading Co, Ltd." PROVISIONING_PROFILE="32ba6a9e-e4d8-46e6-950d-af55549d831a"
      
        echo "~~~~~~~~~~~~~~~~~~~ 编译完成~~~~~~~~~~~~~~~~~~~"
        
        echo "~~~~~~~~~~~~~~~~~~~ 开始打包~~~~~~~~~~~~~~~~~~~"
    
        appDir=$projectDir/  #app所在路径
        echo "开始打包$projectName.app成$projectName.ipa....."
    
        echo "打包地址$export_archive_path"
        echo "输出地址$export_ipa_path"
    
        xcodebuild -exportArchive -archivePath $export_archive_path -exportPath $export_ipa_path -exportOptionsPlist $ExportOptionsPlistPath CODE_SIGN_IDENTITY="iOS Distribution: Beijing Ubox Science & Trading Co, Ltd." PROVISIONING_PROFILE="32ba6a9e-e4d8-46e6-950d-af55549d831a"
    
    
    fir login  7b444bd2c652a260d074845df04d2183
    fir publish $export_ipa_path/Escort.ipa
    
    
    #上传到fir
    #fir publish $export_ipa_path/Escort.ipa -T firtoken -c "7b444bd2c652a260d074845df04d2183"
    
    
    
    

    相关文章

      网友评论

        本文标题:Jenkins中iOS打包shell脚本

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