Verhindern von Zusammenführungskonflikten mit XcodeGen

Hallo Habr! Im Vorfeld des Starts des Kurses "iOS Developer. Professional" haben wir für Sie eine traditionelle Übersetzung nützlichen Materials vorbereitet. Wir laden auch diejenigen ein, die ein Online-Treffen mit dem Kurslehrer wünschen , bei dem Sie dem Lehrer alle Fragen stellen können, die Sie zum Training interessieren.



Und schließlich empfehlen wir
Ihnen , die Aufzeichnung des Webinars "Schreiben einer Anwendung mit SwiftUI und Combine" anzusehen.






I. Einleitung

In diesem Artikel wird eine Lösung zur sofortigen Lösung von Zusammenführungskonflikten in einer Datei vorgestellt. Dies .xcodeproj



ist eines der zeitaufwändigsten Probleme, mit denen iOS- und MacOS-Entwicklungsteams heute konfrontiert sind.





Bildquelle: https://medium.com/@kautilyasave/xcode-merge-conflict-debugging-5904c7e0cc59
Bildquelle: 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, , .





Beispiel Projektstruktur

, :









  • Carthage-













III -

Beispiel-App-Bildschirme

1.

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



. , .





Installieren des Projekts (Brew, Carthage, XcodeGen, Abhängigkeiten ...)
(Brew, Carthage, XcodeGen, …)

2. XcodeGen

XcodeGen ( ) project.yml ( ).





Diese Datei dient als Spezifikation für unser .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: Erster Lauf
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