XcodeGenとのマージの競合の防止

こんにちは、Habr!「iOSDeveloper。Professional」コースの開始を見越して、便利な資料の伝統的な翻訳を用意しました。また、コースの先生とのオンラインミーティングをご希望の方もご招待します。ここでは、トレーニングについて興味のある質問を先生に尋ねることができます。



そして最後に、ウェビナー
「SwiftUIとCombineを使用したアプリケーションの作成」の録画を視聴することをお勧めします。






I.はじめに

この記事では、ファイル内のマージの競合を即座に解決するソリューションについて説明します.xcodeproj



。これは、今日のiOSおよびmacOS開発チームが直面している最も時間のかかる問題の1つです。





画像ソース:https://medium.com/@kautilyasave/xcode-merge-conflict-debugging-5904c7e0cc59
画像ソース:https://medium.com/@kautilyasave/xcode-merge-conflict-debugging-5904c7e0cc59

, .





II -

1. XcodeGen

yonaskolb/XcodeGen

github.com





XcodeGen — , Swift, Xcode- .





XcodeGen Brew. brew install xcodegen ( ).





2.

. , ( ), , , CI . .





, , , XcodeGen, , .





プロジェクト構造の例

, :









  • Carthage-













III -

サンプルアプリの画面

1.

(sample project), , carthage-. makeProject.sh



. , .





プロジェクトのインストール(Brew、Carthage、XcodeGen、依存関係...)
(Brew, Carthage, XcodeGen, …)

2. XcodeGen

XcodeGen ( ) project.yml ( ).





このファイルは、.xcodeprojの仕様として機能します
.xcodeproj

XcodeGen/project.yml



: :





name: GoodToGo
options:
  bundleIdPrefix: com.GoodToGo
  xcodeVersion: '12.0.1'
  deploymentTarget: '12.0'
  groupSortPosition: top
  generateEmptyDirectories: true
  findCarthageFrameworks: true
  minimumXcodeGenVersion: '2.18.0'
      
      



  .xcodeproj



GoodToGo



— , — com.GoodToGo



— , Xcode, …





3. XcodeGen

, , xcodegen -s ./XcodeGen/project.yml -p ./



.





, ./XcodeGen/project.yml



— . /, .





XcodeGen / project.yml:最初の実行
XcodeGen/project.yml:

, . , !





, :





, … , , . , project.yml.





4.

XcodeGen/project.yml



: . project.yml



:





configs:
  Debug.Dev: debug   
  Debug.Prod: debug
  Release: release

targets:
  GoodToGo:
    type: application
    platform: iOS
    deploymentTarget: 12.0
    settings:
      base:
        MARKETING_VERSION: 1.0
    sources:
       - path: ../GoodToGo
      
      



, 3 — Debug.Dev, Debug.Prod Release, GoodToGo, iOS 12 ( ), GoodToGo.





, :





Spec validation error: TargetGoodToGo” has a missing source directory 
“/Users/ricardosantos/Desktop/GitHub/RJPS_Articles/7/sourcecode/THE_FOLDER_THAT_DOES_NOT_EXISTS_NAME
      
      



( ) …





… ( ) , !





5.

, , — . , , .





, , Framework.





, project.yml, , .





XcodeGen/project.yml



: :





targetTemplates:
  Framework:
    type: framework
    platform: iOS
    deploymentTarget: 11.0
    settings:
      base:
        MARKETING_VERSION: 1.0
      
      



, :





  • framework,





  • iOS,





  • 1.0,





  • , , iOS 11.0.





( ).





: AppTheme AppResources.





project.yml 2 (AppTheme AppResources). , .





 AppTheme:
    templates: 
      - Framework
    sources: 
      - path: ../AppTheme
  AppResources:
    templates: 
      - Framework
    sources: 
      - path: ../AppResources
      
      



XcodeGen/project.yml



:





( ) …





… 2 , .





: project.yml



:





targets:
  GoodToGo:
    type: application
    platform: iOS
    deploymentTarget: 12.0
    settings:
      base:
        MARKETING_VERSION: 1.0
    sources:
       - path: ../GoodToGo
  AppTheme:
    templates: 
      - Framework
    sources: 
      - path: ../AppTheme
  AppResources:
    templates: 
      - Framework
    sources: 
      - path: ../AppResources
      
      



, project.yml



:





name: GoodToGo

## options section ##

options:
  bundleIdPrefix: com.GoodToGo
  xcodeVersion: '12.0.1'
  deploymentTarget: '12.0'
  groupSortPosition: top
  generateEmptyDirectories: true
  findCarthageFrameworks: true
  minimumXcodeGenVersion: '2.18.0'

## configs section ##

configs:
  Debug.Dev: debug
  Debug.Prod: debug
  Release: release

## targetTemplates section ##

targetTemplates:
  Framework:
    type: framework
    platform: iOS
    deploymentTarget: 11.0
    settings:
      base:
        MARKETING_VERSION: 1.0

## targets section ##
        
targets:
  GoodToGo:
    type: application
    platform: iOS
    deploymentTarget: 11.0
    settings:
      base:
        MARKETING_VERSION: 1.0
    sources:
       - path: ../GoodToGo
  AppTheme:
    templates: 
      - Framework
    sources: 
      - path: ../AppTheme
  AppResources:
    templates: 
      - Framework
    sources: 
      - path: ../AppResources
  AppConstants:
    templates: 
      - Framework
    sources: 
      - path: ../AppConstants
  Core:
    templates: 
      - Framework
    sources: 
      - path: ../Core
  Core.GalleryApp:
    templates: 
      - Framework
    sources: 
      - path: ../Core.GalleryApp
  Domain:
    templates: 
      - Framework
    sources: 
      - path: ../Domain
  Core.GalleryApp:
    templates: 
      - Framework
    sources: 
      - path: ../Core.GalleryApp
  Designables:
    templates: 
      - Framework
    sources: 
      - path: ../Designables    
  DevTools:
    templates: 
      - Framework
    sources: 
      - path: ../DevTools   
  Extensions:
    templates: 
      - Framework
    sources: 
      - path: ../Extensions   
  Factory:
    templates: 
      - Framework
    sources: 
      - path: ../Factory   
  PointFreeFunctions:
    templates: 
      - Framework
    sources: 
      - path: ../PointFreeFunctions   
  Repositories:
    templates: 
      - Framework
    sources: 
      - path: ../Repositories    
  Repositories.WebAPI:
    templates: 
      - Framework
    sources: 
      - path: ../Repositories.WebAPI         
  UIBase:
    templates: 
      - Framework
    sources: 
      - path: ../UIBase  

  Test.GoodToGo:
    type: bundle.unit-test
    platform: iOS
    sources:
       - path: ../Test.GoodToGo
    scheme: {}
      
      



XcodeGen/project.yml



: ()





https://seattle.eater.com/2019/7/2/20679237/july-4th-seattle-where-to-eat-drink-and-watch-the-fireworks
https://seattle.eater.com/2019/7/2/20679237/july-4th-seattle-where-to-eat-drink-and-watch-the-fireworks

XcodeGen !

, . — .plist



. 2- : project.yml



.plist



, GoodToGo-info.plist Info.plist.





6.

, . .





, , Domain RxCocoa RxSwift, carthage.





-, Domain project.yml





XcodeGen/project.yml



: Domain :





  Domain:
    templates: 
      - Framework
    sources: 
      - path: ../Domain
      
      



… (carthage) . !

XcodeGen / project.yml



: Domain :





Domain:
    templates: 
      - Framework
    sources: 
      - path: ../Domain
    dependencies:
      - carthage: RxSwift
      - carthage: RxCocoa
      
      



, 3:





  • carthage-,





  • (link: true),





  • (link: false).





    XcodeGen/project.yml



    : (carthage, ):





 dependencies:
      - carthage: RxSwift
      - carthage: RxCocoa
      - target: BaseUI
        link: false
      - target: DevTools
        link: true
      - target: UICarTrack
        link: false
      
      



.





, ! « » — , , , , .. :





  • 1. .xcodeproject



    ,





  • 2. ,





  • 3. project.yml



    ,





  • 4. 1.





7. :

( ):





, postCompileScript



.





GoodToGo:
    type: application
    platform: iOS
    deploymentTarget: 12.0
    settings:
      base:
        MARKETING_VERSION: 1.0
    sources:
       - path: ../GoodToGo
    dependencies:
       ...
    postCompileScripts:
      - script: |
                if which swiftlint >/dev/null; then
                   swiftlint
                else
                   echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
                fi
        name: Run SwiftLint
      
      



8. : Documents

Documents. , , . fileGroups ( fileGroups ).





fileGroups:
  - ../Documents
      
      



IV -

  • project.yml



    XcodeGen, ( )





  • ( )









  • ( )





  • ( )









1. , :

. / Remove Reference . , XcodeGen (, ). , Documents.





2. , :

. , , , , . , Documents.





V -

  • XcodeGen .





  • .





  • .





  •   project.yml .





  • .






"iOS Developer. Professional".



« SwiftUI Combine».








All Articles