์ƒˆ์†Œ์‹

๐Ÿ“ฑ iOS/-- UIKit

(iOS) - Bundle : Build version์™€ Version์˜ ์ฐจ์ด์™€ ๊ฐœ๋…

  • -

AppProject์˜ Identify์˜ ํ”„๋กœํผํ‹ฐ๋ฅผ ๋ณด๋ฉด Build์™€ Version์ด ์žˆ๋‹ค.

 

Build์™€ Version์˜ ์ฐจ์ด๋Š” ?

 

Version

Version์€ ์‚ฌ๋žŒ์ด ์ฝ๊ธฐ ์œ„ํ•œ ๋ฆด๋ฆฌ์Šค๋ฒ„์ „์„ ๊ด€๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋œ๋‹ค.

ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ ํ›„ Version์˜ ๋””ํดํŠธ๊ฐ’์€ 1.0์ด๋‹ค. ๋ณดํ†ต Version์€ 10.14.1๊ณผ ๊ฐ™์ด 1~3๊ฐœ์˜ ์ •์ˆ˜์™€ ๋งˆ์นจํ‘œ๋ฅผ ๊ตฌ๋ถ„์ž๋กœ ์“ด๋‹ค.๊ฐ ์ •์ˆ˜๋Š” [Major].[Minor].[Patch] ํ˜•์‹์œผ๋กœ ๋นŒ๋“œ ๋ฒ„์ „์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•œ๋‹ค.

  • ์ฒซ๋ฒˆ์งธ ์ž๋ฆฌ์˜ 1์€ ๋ฉ”์ด์ €ํ•œ ์—…๋ฐ์ดํŠธ์ผ๋•Œ ์ˆซ์ž๋ฅผ ์˜ฌ๋ฆฐ๋‹ค.
  • ๋‘๋ฒˆ์งธ ์ž๋ฆฌ๋Š” ๊ธฐ๋Šฅ ๋ฆฌ๋‰ด์–ผ์ •๋„์˜ ์ค‘๊ทœ๋ชจ ์—…๋ฐ์ดํŠธ๋•Œ ์ˆซ์ž๋ฅผ ์˜ฌ๋ฆฐ๋‹ค.
  • ์„ธ๋ฒˆ์งธ ์ž๋ฆฌ๋Š” ์ž์ž˜ํ•œ ๋””๋ฒ„๊น… ๋ฐ ์•ฝ๊ฐ„์˜ ์ˆ˜์ •์„ ์—…๋ฐ์ดํŠธํ• ๋•Œ ์˜ฌ๋ฆฐ๋‹ค.

3๊ฐœ ์ด์ƒ์˜ ์ˆซ์ž๋ฅผ ์“ฐ๋ฉด ์‹œ์Šคํ…œ์—์„œ ์ด๋ฅผ ๋ฌด์‹œํ•œ๋‹ค. ๋‘๊ฐœ์˜ ์ •์ˆ˜๋งŒ ์‚ฌ์šฉ ํ•  ๊ฒฝ์šฐ , ๋‚˜๋จธ์ง€ ํ•˜๋‚˜๋Š” 0์œผ๋กœ ๊ฐ„์ฃผํ•˜๊ฒŒ๋œ๋‹ค.

 

 

Build

Build๋Š” ๋งค๋ฒˆ์˜ ํ”„๋กœ์ ํŠธ ๋นŒ๋“œ์‹œ ๋ฒˆ๋“ค ๋ฒ„์ „์„ ํ‘œ์‹œํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋œ๋‹ค.

๊ฐœ๋ฐœ์ž๊ฐ€ ํ”„๋กœ๊ทธ๋žจ์„ ํŠธ๋ž˜ํ‚น ํ•˜๊ธฐ์œ„ํ•ด ์‚ฌ์šฉ๋˜๋Š”๊ฒƒ์ด๋‹ค. ๋”ฐ๋ผ์„œ ๊ฐœ๋ฐœ์ž ์Šค์Šค๋กœ ํฌ๋ฉง์„ ์ •ํ•ด์„œ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค. ์˜ˆ๋ฅผ๋“ค์–ด ๋งˆ์ง€๋ง‰์œผ๋กœ ๋นŒ๋“œํ–ˆ๋˜ ๋‚ ์งœ๋ฅผ ์ ๋Š”๋‹ค๊ฑฐ๋‚˜, ๋งค ๋นŒ๋“œ๋งˆ๋‹ค ์ˆซ์ž๋ฅผ 1์”ฉ ๋Š˜๋ฆฐ๋‹ค๊ฑฐ๋‚˜ ์ทจํ–ฅ๊ป ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.

ํ”„๋กœ์ ํŠธ ๊ด€๋ฆฌ์‹œ ๋นŒ๋“œ์™€ ๋ฒ„์ „์„ ์ž๋™ํ™”ํ• ์ˆ˜ ์žˆ๋‹ค. Bundle์˜ infoDictionary์—์„œ ๊ฐ๊ฐ ๋‹ค์Œ์˜ ํ‚ค๋กœ ์ ‘๊ทผ ๊ฐ€๋Šฅํ•˜๋‹ค.

  • Version: CFBundleShortVersionString
  • Build: CFBundleVersion

 

 

์•„๋ž˜์™€ ๊ฐ™์ด extension์„ ๋งŒ๋“ค๋ฉด, ํ”„๋กœ์ ํŠธ ๋‚ด์—์„œ ์ ‘๊ทผํ•˜๊ธฐ ํŽธํ•ด์ง„๋‹ค.

extension Bundle{
    class var displayName : String{
        if let value = Bundle.main.infoDictionary?["CFBundleDisplayName"] as? String{
            return value
        }
        return ""
    }

    class var appVersion: String{
        if let value = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String {
            return value
        }
        return ""
    }

    class var appBuildVersion: String{
        if let value = Bundle.main.infoDictionary?["CFBundleVersion"] as? String{
            return value
        }
        return ""
    }

    class var bundleIdentifier: String{
        if let value = Bundle.main.infoDictionary?["CFBundleIdentifier"] as? String {
            return value
        }
        return ""
    }
}

 

 

 

ํ”„๋กœ์ ํŠธ๋ฅผ ๋นŒ๋“œํ• ๋•Œ๋งˆ๋‹ค,<yyyymmdd + ๋นŒ๋“œํšŸ์ˆ˜>๋กœ Build ๊ฐ’์„ ์—…๋ฐ์ดํŠธํ•ด์ฃผ๋Š” ์ž๋™ํ™” ์‰˜์Šคํฌ๋ฆฝํŠธ์ด๋‹ค.

์•„๋ž˜์ฒ˜๋Ÿผ Build Phases์˜ run Script์— ๋„ฃ์–ด์ฃผ๋ฉด๋œ๋‹ค.


#!/bin/bash
buildDay=$(/usr/libexec/PlistBuddy -c "Print buildDay" "$INFOPIST_FILE")
buildCount=$(/usr/libexec/PlistBuddy -c "Print buildCount" "$INFOPLIST_FILE")
today=$(date +%Y%m%d)

if [ x$buildDay == x ]; then
buildDay=${today}
buildCount=1
printf -v zeroPadBuildCount "%03d" $buildCount
buildNumber=${buildDay}${zeroPadBuildCount}

/usr/libexec/PlistBuddy -c "Add :buildDay string $buildDay" "$INFOPLIST_FILE"
/usr/libexec/PlistBuddy -c "Add :buildCount string $buildCount" "$INFOPLIST_FILE"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"

elif [ $buildDay != $today ]; then
buildDay=${today}
buildCount=1
printf -v zeroPadBuildCount "%03d" $buildCount
buildNumber=${buildDay}${zeroPadBuildCount}

/usr/libexec/PlistBuddy -c "Set :buildDay $buildDay" "$INFOPLIST_FILE"
/usr/libexec/PlistBuddy -c "Set :buildCount $buildCount" "$INFOPLIST_FILE"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"

else
buildCount=$(($buildCount + 1))
printf -v zeroPadBuildCount "%03d" $buildCount
buildNumber=${buildDay}${zeroPadBuildCount}

/usr/libexec/PlistBuddy -c "Set :buildDay $buildDay" "$INFOPLIST_FILE"
/usr/libexec/PlistBuddy -c "Set :buildCount $buildCount" "$INFOPLIST_FILE"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"

fi
Contents

ํฌ์ŠคํŒ… ์ฃผ์†Œ๋ฅผ ๋ณต์‚ฌํ–ˆ์Šต๋‹ˆ๋‹ค

์ด ๊ธ€์ด ๋„์›€์ด ๋˜์—ˆ๋‹ค๋ฉด ๊ณต๊ฐ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.