XcodeGen超入門

011714704c4a925e542d426d4cdaa4e3?s=47 giginet
January 21, 2020

 XcodeGen超入門

try! Swift Tokyo 2020 Meetup!!
https://tryswifttokyo.connpass.com/event/160481/

011714704c4a925e542d426d4cdaa4e3?s=128

giginet

January 21, 2020
Tweet

Transcript

  1. XcodeGen௒ೖ໳ try! Swift Tokyo 2020 Meetup!! @giginet

  2. ୭ • ΫοΫύουϞόΠϧج൫෦ • ج൫վળ͍ͯ͠Δ • Core Commiter of fastlane/Carthage/

    XcodeGen • झຯɿϙέοτϞϯελʔιʔυγʔ ϧυ
  3. XcodeGenͱ͸ • XcodeϓϩδΣΫτ(*.pbxproj)Λఆ͔ٛΒࣗಈੜ੒͢Δ։ൃ πʔϧ

  4. project.yml targets: MyApp: type: application platform: iOS sources: - path:

    MyApp
  5. $ xcodegen Loaded project: Name: MyApp Targets: MyApp: iOS application

    Schemes: MyApp ⚙ Generating project... ⚙ Writing project... Created project at MyApp.xcodeproj
  6. None
  7. େن໛ͳiOS։ൃͷ໰୊఺

  8. ΫοΫύουΞϓϦͷ։ൃ • ௕͍ྺ࢙(2012/8~) • िʹ10ਓҎ্͕։ൃʹࢀՃ • σΧ͍(291,000ߦ) • Ϗϧυ͕࣌ؒ௕͍

  9. ίϯϑϦΫτ͕ى͜Γ·͘Δ • XcodeͰ͸ϑΝΠϧͷ௥Ճ͚ͩͰίϯϑϦΫτ͕ൃੜ͢Δ • ΫοΫύουͷΞϓϦͰ͸ɺिʹ10ਓҎ্͕։ൃ͍ͯ͠Δͷ ͰɺpbxprojͷίϯϑϦΫτ͕೔ৗ஡൧ࣄͩͬͨ

  10. ϓϩδΣΫτ͕ࢄΒ͔Δ • XcodeϓϩδΣΫτ͸ɺϑΝΠϧγεςϜ্ͷπϦʔͱϓϩ δΣΫτ಺ͷϑΝΠϧҐஔ͕ඞͣ͠΋Ұக͠ͳ͍ • ιʔτ΋खಈ

  11. λʔήοτͷ௥Ճ͕೉͍͠ • ϚϧνϞδϡʔϧԽɻݱࡏ20λʔήο τ΄Ͳ • ϨϏϡʔ͕೉͍͠ • ίϯϑϦΫτͷղফ͕ෆՄೳ • ಉ༷ͷઃఆͷίϐʔ͕೉͍͠

  12. XcodeGenࣄྫ • 2018/11 XcodeGenΛಋೖ • 2019/4 XcodeGen঺հهࣄΛॻ͍ͨ • 2019/9 XcodeGenίϛολʔʹ

    XcodeGenʹΑΔ৽࣌୅ͷiOSϓϩδΣΫτ؅ཧ - ΫοΫύου։ ൃऀϒϩά https://techlife.cookpad.com/entry/2019/04/26/110000
  13. ೖΕͯྑ͔ͬͨ͜ͱ • ϑΝΠϧγεςϜ͔ΒϑΝΠϧπϦʔ Λ૊Έཱͯͯ͘ΕΔ • ίϯϑϦΫτ͠ͳ͍ • ࢄΒ͔Βͳ͍ • λʔήοτͷ௥Ճ΋༰қʹ

    • ઃఆͷมߋ͕͠΍͘͢
  14. ηοτΞοϓ $ brew install xcodegen • ࣮ࡍͷӡ༻Ͱ͸HomebrewͰೖΕͳ͍ํ͕ྑ͍ʢޙड़ʣ

  15. Project Spec • ϓϩδΣΫτͷఆٛϑΝΠϧʢproject.ymlʣ • هड़ํ๏͸υΩϡϝϯτ XcodeGen/ProjectSpec.md at master ·

    yonaskolb/XcodeGen https://github.com/yonaskolb/XcodeGen/blob/master/Docs/ ProjectSpec.md
  16. None
  17. options: deploymentTarget: iOS: "12.0" name: MyApp targets: MyFramework: sources: MyFramework

    platform: iOS type: framework sources: MyFramework MyApp: type: application platform: iOS sources: MyApp settings: base: INFOPLIST_FILE: MyApp/Info.plist PRODUCT_BUNDLE_IDENTIFIER: com.myapp Debug: GCC_PREPROCESSOR_DEFINITIONS: DEBUG=1 dependencies: - target: MyFramework
  18. ߴ౓ͳػೳ

  19. Include • ଞͷProject SpecΛ෼཭ͯ͠ಡΈࠐΊΔ • ෳ਺ͷSpec͸Ϛʔδ͞ΕΔ • ಡΈࠐΜͩॱʹΦʔόʔϥΠυ include: -

    other_spec.yml targets: MyApp: ...
  20. Target Template • ςϯϓϨʔτ͔ΒλʔήοτΛෳ੡Ͱ͖Δ • ϚϧνϞδϡʔϧԽͳͲʹศརɹ targetTemplates: Framework: platform: iOS

    type: framework sources: - ${frameworkName} targets: MyFramework: templates: - Framework templateAttributes: frameworkName: AwesomeFramework
  21. Carthage • Carthageͷґଘؔ܎Λهड़Ͱ͖Δ • ґଘؔ܎ͷઃఆ΍Copy FrameworkͳͲ΋উखʹૠೖͯ͘͠ΕΔ targets: MyTarget: dependencies: -

    target: MyFramework - carthage: RxSwift MyFramework: type: framework
  22. None
  23. SwiftPM • SwiftPMύοέʔδΛ૊ΈࠐΊΔ packages: Yams: url: https://github.com/jpsim/Yams from: 2.0.0 targets:

    App: dependencies: - package: Yams
  24. Α͋͘Δ࣭໰

  25. ສ͕ҰXcodeGenͷ։ൃ͕ࢭ·ͬͨΒࠔΓ·ͤΜ͔ʁ • Xcode͕ޙํޓ׵ੑΛอ͍ͬͯΔݶΓେৎ෉ • ݹ͍όʔδϣϯͰ࡞੒ͨ͠෺͸৽͍͠෺Ͱ΋։͚Δ • ສ͕ҰXcodeGenΛ΍Ί͍ͨͱ͖͸ɺ࠷ऴ੒Ռ෺Λ·ͨϦϙδ τϦʹؚΊΕ͹OK

  26. νʔϜશମͰXcodeGenΛ࢖͍͍ͨͰ͢ • Mint + MintfileΛ༻͍ͨόʔδϣϯ؅ཧΛ͍ͯ͠Δ • νʔϜ಺ͰXcodeGenࣗମͷόʔδϣϯΛἧ͍͑ͨͨΊ • minimumXcodeGenVersion ΋ࢦఆͰ͖Δ

  27. Mintfile yonaskolb/XcodeGen@2.11.0 setup.sh $ mint run XcodeGen xcodegen

  28. CocoaPodsΛ࢖͍͍ͨͰ͢ • xcodegenͰੜ੒͔ͯ͠Β pod install ͠·͠ΐ͏ • CocoaPods͸ *.xcodeproj ΛݩʹઃఆΛ஫ೖͯ͠

    *.xcworkspaceΛੜ੒͢ΔͨΊɺຖճ࣮ߦ͕ඞཁ • Shell ScriptͳͲͰbootstrapͷखஈΛ༻ҙ͓ͯ͘͠ $ xcodegen $ pod install
  29. ঃʑʹطଘͷϓϩδΣΫτΛҠߦ͍ͨ͠Ͱ͢ • ϑΝΠϧ੔ཧ͔Β࢝ΊΔɻಉ͡Groupͷ෺Λಉ͡σΟϨΫτϦ ʹҠ͢ • طଘͷϓϩδΣΫτ͸ϦϙδτϦʹ࢒ͨ͠··ɺXcodeGenͰ্ ॻ͖͢Δͷ͕Φεεϝ • CI؀ڥ͔Β΍Ұ෦ͷਓ͔ΒҠߦͯ͠ɺͷͪʹશ։ൃऀʹదԠ

  30. 1. ϑΝΠϧ੔ཧ͢Δ 2. project.ymlॻ͘ɻطଘͷ*.xcodeproj͸ignore͠ͳ͍ 3. ಛఆͷ؀ڥ͚ͩXcodeGenΛ࣮ߦ͢ΔɻطଘͷxcodeprojΛ্ॻ ͖͠ɺ͠͹Β͘໰୊͕ແ͍͔؂ࢹ͢Δ • CI্ͷΈɻ؀ڥม਺Λ༗ޮʹͨ͠ͱ͖ͷΈ 4.

    ྑͦ͞͏ͳΒຖճηοτΞοϓΛඞਢʹ͢Δɻ *.xcodeprojΛ ϦϙδτϦ͔Β࡟আͯ͠ignore
  31. ࢖Θͳ͍΂͖ϓϩδΣΫτ͸͋Γ·͔͢ʁ • খن໛ͳϓϩδΣΫτ͸ඞͣ͠΋ෆཁ • Ҡߦʹ΋ίετ͕͔͔ΔͷͰϓϩδΣΫτͷن໛ʹΑΔ • ࠷ॳ͔ΒೖΕͯ΋ྑ͍ • ΞϓϦέʔγϣϯҎ֎ʢϥΠϒϥϦʣͰ͸࢖Θͳ͍ํ͕ແ೉ •

    SwiftPMࣗମ͕*.xcodeprojΛੜ੒͢ΔػೳΛ͍࣋ͬͯΔ • CarthageରԠͷͨΊʹ݁ہ*.xcodeproj͕ඞཁ
  32. XcodeGen΁ͷߩݙ

  33. ίϛολʔͰ͢ • 4Ґͷίϛοτྔ • ඞཁͳػೳΛೖΕͯͨΒ͜͏ͳͬͨ

  34. None
  35. ؀ڥηοτΞοϓ 1. git clone https://github.com/yonaskolb/XcodeGen.git 2. XcodeͰSwift Packageͱͯ͠։͘

  36. σόοάํ๏ • xcodegenεΩʔϚΛϏϧυͯ͠σόοά • XcodeͷεΩʔϚͰίϚϯυϥΠϯҾ਺Λ౉͢ͷ͕Φεεϝ

  37. PRΛૹΔ • ԿΛղܾ͍ͨ͠ͷ͔ॻ͘(Motivation) • όάͷ৔߹͸࠶ݱঢ়گΛॻ͘(Project SpecͳͲ) • मਖ਼ޙͷڍಈΛॻ͘(Description) • εΫϦʔϯγϣοτ΋షΔ

    • Ϣχοτςετ͸ॻ͘ • ӳޠ͸ؤுΔ
  38. ྫ • @giginet͕ߦͬͨվળΛ͍͔ͭ͘঺հ

  39. -pΦϓγϣϯͷ૬ରύε͕յΕΔ https://github.com/yonaskolb/XcodeGen/pull/681

  40. Carthage Static FrameworkରԠ targets: MyTarget: dependencies: - carthage: AStaticFramework linkType:

    static https://github.com/yonaskolb/XcodeGen/pull/688
  41. એ఻ • SwiftPMύοέʔδͷ։ൃख๏͕໾ཱ ͭ • SwiftPMೖ໳هࣄΛॻ͖·ͨ͠ • WEB+DB PRESS Vol.115

    2020೥2݄22 ೔ൃച • ʰXcode 11ʹΑΔSwiftύοέʔδೖ ໳ʱ
  42. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ • ࠙਌ձͰͳΜͰ΋ฉ͍ͯ͘Εʂʂʂ • XcodeGenɺfastlaneɺCarthageɺϙέϞϯͳͲ