ゆめみの iOS プロジェクトが
取り入れてる自動化の試み / What YUMEMI did to try to automate the process of iOS project development

Af64bc38c0ffcfcabdf430759ee491ce?s=47 Elvis Shi
August 20, 2020

ゆめみの iOS プロジェクトが
取り入れてる自動化の試み / What YUMEMI did to try to automate the process of iOS project development

Af64bc38c0ffcfcabdf430759ee491ce?s=128

Elvis Shi

August 20, 2020
Tweet

Transcript

  1. ΏΊΈͷJ04ϓϩδΣΫτ͕ औΓೖΕͯΔࣗಈԽͷࢼΈ f o r  : 6 . &

    . *  T X J G U   
  2. } var employedBy = "YUMEMI Inc." var job = "iOS

    Tech Lead" var favoriteLanguage = "Swift" var twitter = "@lovee" var qiita = "lovee" var github = "el-hoshino" var additionalInfo = """ ࣗ୐ʹ௕ډ͗ͯ͢͠ମ͕ͩΔ͍… """ final class Me: Developable, Talkable {
  3. ࣗಈԽΛܭΔϞνϕʔγϣϯ w ຊମίʔυҎ֎ͷ෦෼ʹແବͳ࿑ྗΛ͔͚ͳͯ͘ࡁΉ w ୯७Ͱॏෳͳ࡞ۀΛػցʹ೚ͤͯετϨεΛԼ͛Δ w ଐਓతͳ࡞ۀΛݮΒͯ͠୭Ͱ΋ࢀՃ͠΍͘͢Ͱ͖Δ w ࠷ऴతʹϓϩδΣΫτ඼্࣭͕͕Δ

  4. ΏΊΈͰ͸ࣗಈԽͷͨΊͷ༷ʑͳ؀ڥߏஙܥϑΝΠϧΛڞ௨Խ͍ͯ͠Δ

  5. ؀ڥߏங ϓϧϦΫ σϓϩΠ

  6. ؀ڥߏங ϓϧϦΫ σϓϩΠ w CPPUTUSBQTI w 16--@3&26&45@5 &.1-"5&NE w CJUSJTFZNM

    w %BOHFSpMFTXJGU w CJUSJTFZNM w SFMFBTF@DPEFTJHOTI
  7. CPPUTUSBQTIʢʣ install_prebuild_libraries() { # Gem BundleɺHomebrew ͱ Mint ΛඞཁʹԠͯ͡Πϯετʔϧ echo

    "Install Gems, Brews and Mints" if [ -e Gemfile ]; then bundle install fi if [ -e Brewfile ]; then brew bundle fi if [ -e Mintfile ]; then mint bootstrap fi }
  8. CPPUTUSBQTIʢʣ generate_xcode_project() { # XcodeGen Λಋೖͯ͠Δ৔߹͸ɺXcode ϓϩδΣΫτϑΝΠϧΛੜ੒ echo "Generate .xcodeproj

    file" if [ -e project.yml ]; then mint run xcodegen fi }
  9. CPPUTUSBQTIʢʣ install_embeded_libraries() { # ඞཁʹԠͯ͡ CocoaPodsɺCarthage ͱ SwiftPM ͷϥΠϒϥϦʔΛಋೖ echo

    "Install dependencies via CocoaPods, Carthage and SwiftPM" if [ -e Podfile ]; then bundle exec pod install --repo-update fi if [ -e Cartfile ]; then carthage bootstrap --use-ssh --no-use-binaries --cache- builds --platform ios fi if [ $(find . -maxdepth 4 -name swiftpm | wc -l) -gt 0 ]; then workspace_file="$(ls | grep '.*\.xcworkspace$')" scheme="$(xcodebuild -workspace $workspace_file -list | sed -n -e '/Schemes:/,$p' | sed -n -e 2p | xargs echo)" xcodebuild -resolvePackageDependencies -workspace "$workspace_file" -scheme "$scheme" fi }
  10. CPPUTUSBQTIʢಋೖ݁Ռʣ w λʔϛφϧͰ./bootstrap.shίϚϯυͰҰൃͰ ؀ڥߏங͕Ͱ͖Δ w #VOEMFSͷόʔδϣϯ΍ɺ$PDPB1PET$BSUIBHF ౳ͷύοέʔδ؅ཧͷ༗ແΛҙࣝ͠ͳͯ͘ࡁΉ w ٸʹϓϩδΣΫτʹࢀՃͤ͞ΒΕͯ΋ɺ؀ڥߏஙʹ ೰·͞Εͣʹ։ൃʹऔΓֻ͔ΕΔ

  11. 16--@3&26&45@5&.1-"5&NEʢʣ ## ֓ཁ <!-- Օ৚ॻ͖Ͱྑ͍ͷͰɺ؆ૉʹهࡌΛ͓ئ͍க͠·͢ɻ --> ## ϨϏϡʔ؍఺ <!-- ϨϏϡʔΞʹ֬ೝͯ͠΄͍͠ࣄฑͷهࡌΛ͓ئ͍க͠·͢ɻ

    ಛʹɺຊPRʹͯϨϏϡʔର৅֎ͷ಺༰͕͋Ε͹߹ΘͤͯهࡌΛ͓ئ͍க͠·͢ɻ (ྫ) Ϗϧυ͕௨Δঢ়ଶͱͳ͍ͬͯΔ͔ warnings ͕ग़ྗ͞Εͳ͍͜ͱ σβΠϯ͚ͩ૊ΈࠐΜͩͷͰɺ࢓༷ʹ͍ͭͯ͸ϨϏϡʔର৅֎ͱͯ͠ཉ͍͠ ͜ͷίϛοτ xxxxxxxxx(commit hash) ΛओʹϨϏϡʔͯ͠ཉ͍͠ --> ## ϨϏϡʔϨϕϧ <!-- ͲΕ͔ͷଧͪফ͠ઢΛ֎͍ͯͩ͘͠͞ɻ --> - ~~Lv0: ·ͬͨ͘ݟͳ͍ͰAccept͢Δ~~ - ~~Lv1: ͺͬͱΈͯҧ࿨ײ͕ͳ͍͔νΣοΫͯ͠Accept͢Δ~~ - ~~Lv2: ࢓༷Ϩϕϧ·Ͱཧղͯ͠ɺ࢓༷௨Γʹಈ͔͋͘Δఔ౓ݕূͯ͠Accept͢Δ~~ - ~~Lv3: ࣮ࡍʹ؀ڥͰಈ࡞֬ೝͨ͠͏͑ͰAccept͢Δ~~
  12. 16--@3&26&45@5&.1-"5&NEʢʣ ## ը໘ઃܭॻ΁ͷϦϯΫ <!-- ը໘ઃܭॻ͕͋Ε͹ϦϯΫͷهࡌΛ͓ئ͍͍ͨ͠·͢ɻ --> ## σβΠϯΨΠυ΁ͷϦϯΫ <!-- ը໘ઃܭॻʹՃ͑ඞཁͰ͋Ε͹σβΠϯΨΠυ΁ͷϦϯΫͷهࡌΛ͓ئ͍͍ͨ

    ͠·͢ɻ --> ## API࢓༷ॻ΁ͷϦϯΫ <!-- API࢓༷ॻ͕͋Ε͹ϦϯΫͷهࡌΛ͓ئ͍͍ͨ͠·͢ɻ -->
  13. 16--@3&26&45@5&.1-"5&NEʢʣ ## εΫϦʔϯγϣοτ <!-- ը໘දࣔʹมԽ͕͋Δ৔߹ɺఴ෇΍ࢀরϦϯΫٴͼมԽ಺༰ͷهࡌΛ͓ئ͍க͠·͢ɻ ಛʹɺಈ࡞΍ΞχϝʔγϣϯͳͲ΋ϨϏϡʔͯ͠ཉ͍͠৔߹͸ɺಈ࡞֬ೝखॱΛॻ͍ͨΓɺεΫϦʔϯγϣοτͷఴ෇Λ͓ئ͍க͠· ͢ɻ (ྫ) ݟͨ໨ʹؔ͢Δมߋ͕ͳ͍ͨΊলུ͠·͢ɻ ܾఆϘλϯΛλοϓ࣌ʹɺදࣔมԽ͕͋Γ·͢ɻಈըఴ෇க͠·͢ɻ

    ※ಈըΛఴ෇͢Δͱ͖͸ɺGitHubͷ੍ݶͷͨΊɺΞχϝʔγϣϯGifʹม׵͍ͯͩ͘͠͞ɻ γϛϡϨʔλʔͰ࿥ը͢Δͱ͖ͷίϚϯυɿ `$ xcrun simctl io booted recordVideo screen.mov` ࿥ը͞ΕͨಈըΛGifʹม׵͢Δͱ͖ͷίϚϯυɿ `$ ffmpeg -i screen.mov -vf scale=320:-1 -r 10 screen.gif` ΋͠ffmpeg͕Πϯετʔϧ͞Ε͍ͯͳ͍৔߹ɺHomebrwe͔Β؆୯ʹΠϯετʔϧͰ͖·͢ɻ --> | before | after | |--------|-------| | XXXXXX | XXXXX | ## උߟ <!-- ଞʹ఻͓͖͍͑ͯͨ͜ͱ͕͋Ε͹هࡌΛ͓ئ͍͍ͨ͠·͢ɻ -->
  14. 16--@3&26&45@5&.1-"5&NEʢಋೖ݁Ռʣ w 13ग़͢ͱ͖ʹࣗಈతʹઆ໌จ͕࡞੒͞ΕΔͨΊɺ ΤϯδχΞͱͯ͠ରԠ͠΍͍͢ w ඞཁͳ߲໨ͱͦΕʹ͍ͭͯͷ؆୯ͳઆ໌͕ςϯϓϨʹ ͋ΔͨΊɺࣄ߲ͷهೖ࿙Ε͕ൃੜ͠ʹ͍͘ w ૢ࡞ಈըͷ(JGԽͳͲͷΑ͏ͳൺֱతʹෳࡶͳૢ࡞͕ ςϯϓϨͷίϝϯτʹखॱॻ͔Ε͍ͯΔͨΊɺ୭Ͱ΋

    ͙͢ʹରԠͰ͖Δ
  15. #JUSJTFʢ֓ཁʣ IUUQTRJJUBDPNMPWFFJUFNTFBFGC

  16. #JUSJTFʢϓϧϦΫӡ༻ํ਑ʣ w EFWFMPQNBTUFSϒϥϯν΁ͷ13͕͋ͬͨΒɿ w 9DPEFςετΛ࣮ߦ w %BOHFSΛ࣮ߦ w ্ه݁ՌΛݩʹ13ʹϑΟʔυόοΫ

  17. #JUSJTFʢϓϧϦΫಋೖ݁Ռʣ w 13τϦΨʔʹΑΓ8PSLqPX͕ࣗಈతʹಈͨ͘Ίɺ 13Λग़͚ͩ͢Ͱे෼Ͱ͋Γແବͳ࡞ۀ͕ൃੜ͠ͳ͍ w ্هʹΑΓɺίʔυͷෆඋʹΑΔϓϩάϥϜͷόάΛ େ෯ʹ࡟ݮͰ͖ɺίʔυ඼࣭޲্ʹܨ͕ͬͨ

  18. %BOHFS4XJGUʢ֓ཁʣ IUUQTRJJUBDPNMPWFFJUFNTBEBFC

  19. %BOHFS4XJGUʢ֓ཁʣ IUUQTTQFBLFSEFDLDPNMPWFFQBUIUPJNQPSUEBOHFSTXJGU

  20. %BOHFS4XJGUʢӡ༻ํ਑ʣ w 13ͷIFBEͱCBTF͕ਖ਼͍͔͠Ͳ͏͔ΛνΣοΫ w มߋྔ΍ඞཁͳमਖ਼͕͋Δ͔Ͳ͏͔ΛνΣοΫ w 4XJGU-JOUͷ࣮ߦ݁ՌΛूܭ w 9DPEFͷ#VJME4VNNBSZΛूܭ w

    ςετΧόϨοδΛूܭ Ϗϧυϫʔχϯά΋ ڭ͑ͯ͘ΕΔ!
  21. %BOHFS4XJGUʢಋೖ݁Ռʣ w ػցతͰݕग़Ͱ͖Δ໰୊఺͕૿͑ɺϨϏϡΞʔͷෛ୲ ͕ݮͬͨ w ϨϏϡΞʔ͕ൺֱతʹΑΓຊ࣭ͷίʔυ΍ઃܭʹઐ೦ Ͱ͖ͨ

  22. #JUSJTFʢ֓ཁʣ IUUQTRJJUBDPNMPWFFJUFNTFBFGC

  23. #JUSJTFʢσϓϩΠӡ༻ํ਑ʣ w #JUSJTFʹϏϧυ൪߸ͷมߋΛ೚ͤΔ w EFWFMPQϒϥϯν΁ͷ13͕͋ͬͨΒɿ w ։ൃऀ޲͚ʹ%FW؀ڥΛ#JUSJTFʹσϓϩΠ w EFWFMPQϒϥϯν͕.FSHF͞ΕͨΒɿ w

    ΫϥΠΞϯτ޲͚ʹ4UH؀ڥΛ#JUSJTFʹσϓϩΠ w NBTUFSϒϥϯν͕.FSHF͞ΕͨΒɿ w Ϣʔβ޲͚ʹຊ൪؀ڥΛ"QQ4UPSFʹσϓϩΠ w σϓϩΠ݁ՌΛ4MBDLʹ23ίʔυ෇͖Ͱ௨஌ ɿ13ͷ৔߹͸ɺ13ͷϖʔδʹ΋σϓϩΠ݁ՌΛ23ίʔυ෇͖ͰίϝϯτΛೖΕΔ
  24. #JUSJTFʢσϓϩΠಋೖ݁Ռʣ w ඞཁͳλΠϛϯάͰඞཁͳλʔήοτʹϏϧυΛॻ͖ ग़ͤɺಈ࡞֬ೝͷͨΊͷલ४උͷख͕ؒল͚ͨ w 23ίʔυΛεΩϟϯ͢Δ͚ͩͰΠϯετʔϧͰ͖Δ ͨΊɺಈ࡞֬ೝͷͨΊͷखؒ΋ඇৗʹ௿͍ w "QQ4UPSF$POOFDUʹ΋௚઀*1"Λ্͛ΒΕΔͨΊɺ ৹ࠪʹग़͢खؒ΋ଟগվળͰ͖ͨ

  25. SFMFBTF@DPEFTJHOTIʢʣ development_release_action="development" development_bundle_id="DEVELOPMENT_BUNDLE_ID" development_team_id="DEVELOPMENT_TEAM_ID" staging_release_action="adhoc" staging_bundle_id="STAGING_BUNDLE_ID" staging_team_id="STAGING_TEAM_ID" production_release_action="appstore" production_bundle_id="PRODUCTION_BUNDLE_ID" production_team_id="PRODUCTION_TEAM_ID"

  26. SFMFBTF@DPEFTJHOTIʢʣ bootstrap() { fastlane match $development_release_action -a $development_bundle_id -b $development_team_id

    --git_branch $development_team_id --readonly fastlane match $staging_release_action -a $staging_bundle_id -b $staging_team_id --git_branch $staging_team_id --readonly fastlane match $production_release_action -a $production_bundle_id -b $production_team_id --git_branch $production_team_id --readonly } update() { echo "Please enter your Apple Developer Account ID to update the certificates:" read developer_id fastlane match $development_release_action -a $development_bundle_id -b $development_team_id -u $developer_id --git_branch $development_team_id fastlane match $staging_release_action -a $staging_bundle_id -b $staging_team_id -u $developer_id --git_branch $staging_team_id fastlane match $production_release_action -a $production_bundle_id -b $production_team_id -u $developer_id --git_branch $production_team_id } ౰વͳ͕ΒɺGBTUMBOFNBUDIΛར༻͍ͯ͠ΔͨΊɺূ໌ॻΛอ؅͢ΔHJUϦϙͷ63-ͳͲͷҰ෦ઃఆʹ.BUDIpMF΋ඞཁ
  27. SFMFBTF@DPEFTJHOTIʢʣ while getopts :-: OPT; do case $OPT in "-"

    ) case $OPTARG in "update" ) SHOULD_UPDATE="TRUE" ;; esac ;; esac done if ! type fastlane &> /dev/null; then echo "Fastlane is not installed. Please install Fastlane first" exit 1 fi if [ "$SHOULD_UPDATE" = "TRUE" ]; then update else bootstrap fi
  28. SFMFBTF@DPEFTJHOTIʢಋೖ݁Ռʣ w λʔϛφϧͰ./release_codesign.shίϚϯυͰ ҰൃͰσϓϩΠ༻ϦϦʔεূ໌ॻ͕औಘͰ͖Δ w #JUSJTF͚ͩͰͳ͘ɺΤϯδχΞͰ΋౰વར༻Մೳ w ূ໌ॻͷߋ৽͕ඞཁͳͱ͖ʹɺݖݶ͑͋͞Ε͹୭Ͱ΋ ./release_codesign.sh --updateͰ͙͢ߋ৽

    Ͱ͖ΔͨΊɺߋ৽͢Δख͚ؒͩͰͳ͘ɺ৽͍͠ূ໌ॻ Λ#JUSJTFʹ্͛Δखؒ΋ল͚Δ
  29. ࠓޙͷ໨ඪɿ ৽نϓϩδΣΫτ࡞੒ͷࣗಈԽ!

  30. ࢀߟࢿྉ w IUUQTTIFMMTDSJQUTVOPOFNFUVUPSJBMIUNM w IUUQTRJJUBDPNLBUTVLJJJUFNTCGFFBFF w IUUQTEPDTHJUIVCDPNKBHJUIVCCVJMEJOHBTUSPOHDPNNVOJUZ DPOpHVSJOHJTTVFUFNQMBUFTGPSZPVSSFQPTJUPSZ w IUUQTEFWDFOUFSCJUSJTFJP

    w IUUQTRJJUBDPNMPWFFJUFNTFBFGC w IUUQTEBOHFSTZTUFNTTXJGU w IUUQTRJJUBDPNMPWFFJUFNTBEBFC w IUUQTTQFBLFSEFDLDPNMPWFFQBUIUPJNQPSUEBOHFSTXJGU