JiFu's Wiki JiFu's Wiki
首页
  • HTML
  • JavaScript
  • NodeJS
  • Vuejs
  • 微信小程序
  • Python
  • 数据库
  • 中间件
  • 算法
  • 软件工程
  • Wordpress
  • iOS开发
  • Android开发
  • Linux
  • Windows
  • MacOS
  • Docker
  • Vim
  • VSCode
  • Office
  • 其他
  • Photoshop
  • Sketch
  • Mac
  • 游戏
关于
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
首页
  • HTML
  • JavaScript
  • NodeJS
  • Vuejs
  • 微信小程序
  • Python
  • 数据库
  • 中间件
  • 算法
  • 软件工程
  • Wordpress
  • iOS开发
  • Android开发
  • Linux
  • Windows
  • MacOS
  • Docker
  • Vim
  • VSCode
  • Office
  • 其他
  • Photoshop
  • Sketch
  • Mac
  • 游戏
关于
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • iOS开发

    • iOS开发介绍
    • Apple Store上iOS App上架流程
    • Xcode开发中Build与version区别 & build自增设置?
      • 发布app到AppStore时候
      • 列表
      • 步骤
      • 代码
      • build与version的区别
      • 区别1
      • 区别2
      • 区别3
      • Version
      • build
    • Swift:解包的正确姿势
    • Swift 5.4 有什么新功能?
  • Android开发

  • 移动端开发
  • iOS开发
JiFu
2023-09-13
目录

Xcode开发中Build与version区别 & build自增设置?

# 摘要

xcode开发中,version和build可能总是让大家迷惑。 其实version平时大家叫做发布版本号,build叫做编译版本号。

# 发布相关

# 发布app到AppStore时候

version相同时候,build相同提交构建版本失败, version相同时候,build不相同提交构建版本成功

# 列表

名称 解释
Version 发布版本号
Build 编译版本号

# 装逼技能:build的自增?跟随时间变化?

# 步骤

Xcode ——> target——>general ———> Build Phases——> "+"——>Run scripe——>复制代码

# 代码

# 跟随时间变化(release和Debug不同情况)

#!/bin/bash
    // 判断是哪个configuration
    // Release Debug 或者只自定义的配置
    if [ "Release" != "${CONFIGURATION}" ]
        // 如果是Release做哪些事情
        then
        // 如果不是Release做哪些事情
        // exit 0 退出 不执行下面的代码
        fi

        // 获取info.plist信息 CFBundleVersion 可以更改为想获取的信息的名字
        buildNumber=$(/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
        shortVersion=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "${PROJECT_DIR}/${INFOPLIST_FILE}")
        buildNumber=`date +"%m%d"`
        buildNumber="$shortVersion.$buildNumber"

        // 设置info.plist
        /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${INFOPLIST_FILE}"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

# 跟随时间变化

#!/bin/bash
    buildNumber=$(date +%Y%m%d%H%M%S)
    /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
1
2
3

# 自动加1

#!/bin/bash
    buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
    buildNumber=$(($buildNumber + 1))
    /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
1
2
3
4

# 修改项目显示名称为版本号

(适用于不同版本号装到一个机器里面,便于区分是哪个版本)

#/bin/bash
    if [ "Release" != "${CONFIGURATION}" ]; then

    DisplayName=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$INFOPLIST_FILE")
    DisplayName="ep${DisplayName}-I"
    /usr/libexec/PlistBuddy -c "Set :CFBundleDisplayName $DisplayName" "$INFOPLIST_FILE"

    else

        DisplayName="真正的项目名称"
        /usr/libexec/PlistBuddy -c "Set :CFBundleDisplayName $DisplayName" "$INFOPLIST_FILE"

        fi
1
2
3
4
5
6
7
8
9
10
11
12
13

# build与version的区别

# 区别1

首先,Version是显示对外的版本号,(itunesconect和Appstore用户可以看到),对应O-C中获取version的值:[[[NSBundle mainBundle]infoDictionary]valueForKey:@"CFBundleShortVersionString"]; 该版本的版本号是三个分隔的整数组成的字符串。 第一个整数代表重大修改的版本,如实现新的功能或重大变化的修订。 第二个整数表示的修订,实现较突出的特点。 第三个整数代表维护版本例如:1.0.12或者 1.2.3等等

# 区别2

build别人看不到,只有开发者自己才能看到,相当于内部版本号。 【更新版本的时候,也要高于之前的build号】 对应获取方式:[[[NSBundle mainBundle]infoDictionary]valueForKey:@"CFBundleVersion"]; 标示(发布或者未发布)的内部版本号。 这是一个单调增加的字符串,包括一个或者多个分割的整数。

# 区别3

附加解释InfoDictionary version CFBundleInfoDictionaryVersion Info.plist格式的版本信息,一般这个值不改动;

# 总结

# Version

Bundle versions string, short:用于iTunes上显示的版本号,即对外的版本。 (最多是3个部分组成即 x.y.z)。

# build

Bundle version: 内部项目管理的版本号,不对外。 所以,可以定义任意形式一般要检查版本更新,要用到的是Version,而不是用build;

# 参考资料

-Xcode进行iOS开发中Build与version区别?build自增设置?build随时间变化? (opens new window)

#iOS#xcode
上次更新: 2024/08/11, 01:59:03
Apple Store上iOS App上架流程
Swift:解包的正确姿势

← Apple Store上iOS App上架流程 Swift:解包的正确姿势→

最近更新
01
WPS快捷键
05-21
02
Disable notification "to get future google chrome updates you'll need macos 10.13 or later" on mac
05-14
03
MacOS软件推荐
04-30
更多文章>
Theme by Vdoing | Copyright © 2019-2025 Ji Fu | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式