简体   繁体   中英

Is there a way to avoid running `pod install` manually and not commiting Pods directory at the same time?

On my current project I am asked not to commit my Pods directory, and at the same time, guys want me to 'add some script' to XCode build phases which will run 'pod install' automatically before each installation if needed.

The goal is not to run pod install manually in terminal after you clone the repo.

I have spend a day trying to solve this and I've found a couple of references with no much detail:

iOS using pod install as Pre-action run script for building the project

CocoaPods version control, must use pod install when cloning repo

I've also found out that for CI the same problem is solved by setting actions in .yml file:

Travis-CI is unable to open file

Do you know what this kind of script could look like?

Maybe it would be best if this could be separated in 2 different questions.

But now that we are here already, to avoid the pods directory on your repository, add this line to your .gitignore file:

Pods/

For your second question regarding running pod install . On Xcode:

  • Click your scheme icon on the top left and select "Edit Scheme..."
    • Alternatively select from the menu "Product -> Scheme -> Edit scheme..."
  • In Scheme Window expand "Build"
  • Select "Pre-actions"
  • Click on + and choose "New Run Script Action"
  • Select to provide the build settings from your target
  • Add the script:

     cd ${PROJECT_DIR} test -e Pods || pod install && sleep 30

在此处输入图片说明

Description of the script:

  • Changes directory to the project's main folder
  • Checks if there is a file or folder named Pods, if not runs pod install and waits 30 seconds (before continue with the build). You might want to adjust to wait more or less, according to how long you need to wait for the pods to be downloaded.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM