<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: ryanzzff</title>
    <description>The latest articles on Forem by ryanzzff (@ryanzzff).</description>
    <link>https://forem.com/ryanzzff</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F298019%2Ffa48ddda-f758-4425-a2f4-0017c917eb41.jpeg</url>
      <title>Forem: ryanzzff</title>
      <link>https://forem.com/ryanzzff</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ryanzzff"/>
    <language>en</language>
    <item>
      <title>Setup CI pipeline for iOS projects on gitlab.com</title>
      <dc:creator>ryanzzff</dc:creator>
      <pubDate>Sat, 10 Jul 2021 13:27:16 +0000</pubDate>
      <link>https://forem.com/ryanzzff/setup-ci-pipeline-for-ios-projects-on-gitlab-com-4nhl</link>
      <guid>https://forem.com/ryanzzff/setup-ci-pipeline-for-ios-projects-on-gitlab-com-4nhl</guid>
      <description>&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Setup CI pipeline with &lt;code&gt;.gitlab-ci.yml&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Adding badges for pipeline status and code coverage&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Prerequisite
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A macOS machine with Xcode and Xcode command line tools installed &lt;/li&gt;
&lt;li&gt;The above macOS machine is registered as a GitLab runner&lt;/li&gt;
&lt;li&gt;An iOS app with a testing scheme with test cases&lt;/li&gt;
&lt;li&gt;Tools

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://bundler.io/" rel="noopener noreferrer"&gt;bundler&lt;/a&gt; (optional, if you have dependency for Ruby gems like cocoapods/fastlane, etc.)&lt;/li&gt;
&lt;li&gt;jq (optional, for processing the code coverage report)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;brew install jq&lt;/code&gt; &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Terms of GitLab CI/CD
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Pipelines&lt;/code&gt; are the top-level component of continuous integration, delivery, and deployment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Jobs&lt;/code&gt; defines what to do, executed by runners&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Stages&lt;/code&gt; defines when to run the jobs&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Setup CI pipeline with .gitlab-ci.yml&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;stages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;prebuild&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;

&lt;span class="na"&gt;cache&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${CI_COMMIT_REF_SLUG}&lt;/span&gt;
  &lt;span class="na"&gt;paths&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;my-project-path/.bundle&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;my-project-path/vendor&lt;/span&gt;

&lt;span class="na"&gt;install_dependencies&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;prebuild&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;unset cd&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;cd my-project-path&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;bundle config set --local deployment 'true'&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;bundle install&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;macos_11-2-3&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;xcode_12-4&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ios_14-4&lt;/span&gt;

&lt;span class="na"&gt;build_project&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;unset cd&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;cd my-project-path&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;xcodebuild clean build test -project my-project.xcodeproj -scheme "CI" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;xcrun xccov view --report --json DerivedData/my-project-path/Logs/Test/*.xcresult &amp;gt; xcresult.json&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;cat xcresult.json | jq ".lineCoverage" -j | awk '{printf "XCTEST_COVERAGE=%0.2f%%\n",$1*100}'&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;macos_11-2-3&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;xcode_12-4&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ios_14-4&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Structure of the configuration file:
&lt;/h3&gt;

&lt;p&gt;line 1-3: defined a pipeline with 2 stages, &lt;code&gt;prebuild&lt;/code&gt; and &lt;code&gt;build&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;line 5-9: defined the paths that will be cached between the jobs&lt;/p&gt;

&lt;p&gt;line 11-21: defined the &lt;code&gt;install_dependencies&lt;/code&gt; Job&lt;/p&gt;

&lt;p&gt;line 23-34: defined the &lt;code&gt;build_project&lt;/code&gt; Job&lt;/p&gt;

&lt;p&gt;line 28: build and test the Xcode project&lt;/p&gt;

&lt;p&gt;line 29-30: gather the code coverage stat   &lt;/p&gt;

&lt;h3&gt;
  
  
  Cache the dependencies between Jobs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;my-project-path/.bundle&lt;/code&gt; is storing the bundle config&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;my-project-path/.vendor&lt;/code&gt; is storing the installed gems&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;${CI_COMMIT_REF_SLUG}&lt;/code&gt; is the branch or tag name for which project is built&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without cache, the gems installed in the &lt;code&gt;prebuild&lt;/code&gt; stage will be deleted when the &lt;code&gt;build&lt;/code&gt; stage is executed, even the Jobs are executed on the same machine&lt;/p&gt;

&lt;p&gt;The example will share the caches across the same branch&lt;/p&gt;

&lt;h3&gt;
  
  
  The use of &lt;code&gt;unset cd&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;when &lt;code&gt;rvm&lt;/code&gt; is used, it will redefine the &lt;code&gt;cd&lt;/code&gt; command as below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd () 
{ 
    __zsh_like_cd cd "$@"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;When the &lt;code&gt;cd&lt;/code&gt; command is used in the Job, it will throw &lt;code&gt;ERROR: Build failed with: exit status 1&lt;/code&gt; and exit immediately&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;unset cd&lt;/code&gt; is used to reset &lt;code&gt;cd&lt;/code&gt; to be the shell builtin command

&lt;ul&gt;
&lt;li&gt;it can be added before the step that used the &lt;code&gt;cd&lt;/code&gt; command (as in the example)&lt;/li&gt;
&lt;li&gt;or can be added in &lt;code&gt;.bash_profile&lt;/code&gt; &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Other points to note
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;the &lt;code&gt;tags&lt;/code&gt; must match the configs in the &lt;strong&gt;Runners&lt;/strong&gt; section in gitlab.com -&amp;gt; project settings -&amp;gt; CI/CD&lt;/li&gt;
&lt;li&gt;the file &lt;code&gt;.gitlab-ci.yml&lt;/code&gt; should be placed in the root of the git repo&lt;/li&gt;
&lt;li&gt;the DerivedData path is set relative to the Xcode project&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Adding badges for pipeline status and code coverage
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Pipeline Status Badge
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flg956q7ddlu0zu7pg7s1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flg956q7ddlu0zu7pg7s1.png" alt="status badges"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To configure the pipeline status:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;gitlab.com -&amp;gt; project settings -&amp;gt; General -&amp;gt; Expand the Badges Section&lt;/li&gt;
&lt;li&gt;Add Badges with following settings:

&lt;ul&gt;
&lt;li&gt;Name: &lt;code&gt;Pipeline Status&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Link: &lt;code&gt;https://gitlab.com/%{project_path}/-/commits/%{default_branch}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Badge image URL: &lt;code&gt;https://gitlab.com/%{project_path}/badges/%{default_branch}/pipeline.svg&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnwo6a8ub33enuljb8m1t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnwo6a8ub33enuljb8m1t.png" alt="GitLab Badge Pipeline"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Coverage Badge
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Get the code coverage report in JSON format after the project is built&lt;br&gt;&lt;br&gt;
&lt;code&gt;xcrun xccov view --report --json DerivedData/my-project/Logs/Test/*.xcresult &amp;gt; xcresult.json&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Print the code coverage to the job log&lt;br&gt;&lt;br&gt;
&lt;code&gt;cat xcresult.json | jq ".lineCoverage" -j | awk '{printf "XCTEST_COVERAGE=%0.2f%%\n",$1*100}'&lt;/code&gt; &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;the above line is to &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;get the &lt;code&gt;lineCoverage&lt;/code&gt;field from the JSON&lt;/li&gt;
&lt;li&gt;multiply the value by 100&lt;/li&gt;
&lt;li&gt;convert the value in percentage&lt;/li&gt;
&lt;li&gt;print the value with 2 decimal places&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;noted that the percentage sign &lt;code&gt;%&lt;/code&gt; must be included for &lt;strong&gt;Test coverage parsing&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Set the &lt;strong&gt;Test coverage parsing&lt;/strong&gt; regular expression to grep the result in step 2.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;gitlab.com -&amp;gt; project settings -&amp;gt; CI/CD -&amp;gt; Expand the General pipelines Section&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;Test coverage parsing&lt;/strong&gt;, fill in &lt;code&gt;XCTEST_COVERAGE=(\d+.\d+%)&lt;/code&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Add the badge like pipeline status &lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;gitlab.com -&amp;gt; project settings -&amp;gt; General -&amp;gt; Expand the Badges Section&lt;/li&gt;
&lt;li&gt;Add Badges with following settings:

&lt;ul&gt;
&lt;li&gt;Name: &lt;code&gt;Code Coverage&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Link: &lt;code&gt;https://gitlab.com/%{project_path}/-/commits/%{default_branch}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Badge image URL: &lt;code&gt;https://gitlab.com/%{project_path}/badges/%{default_branch}/pipeline.svg&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Concepts
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.gitlab.com/ee/ci/pipelines/" rel="noopener noreferrer"&gt;https://docs.gitlab.com/ee/ci/pipelines/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Configurations
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.gitlab.com/ee/ci/variables/predefined_variables.html" rel="noopener noreferrer"&gt;https://docs.gitlab.com/ee/ci/variables/predefined_variables.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/41497356/code-coverage-for-swift-3-0-project-in-gitlab-ci" rel="noopener noreferrer"&gt;https://stackoverflow.com/questions/41497356/code-coverage-for-swift-3-0-project-in-gitlab-ci&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Caching dependencies between jobs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.gitlab.com/ee/ci/caching/" rel="noopener noreferrer"&gt;https://docs.gitlab.com/ee/ci/caching/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Badges
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.gitlab.com/ee/user/project/badges.html" rel="noopener noreferrer"&gt;https://docs.gitlab.com/ee/user/project/badges.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.gitlab.com/ee/ci/pipelines/settings.html#test-coverage-parsing" rel="noopener noreferrer"&gt;https://docs.gitlab.com/ee/ci/pipelines/settings.html#test-coverage-parsing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.gitlab.com/ee/ci/pipelines/settings.html#test-coverage-report-badge" rel="noopener noreferrer"&gt;https://docs.gitlab.com/ee/ci/pipelines/settings.html#test-coverage-report-badge&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://unix.stackexchange.com/questions/113515/how-to-modify-output-in-bash-command-pipeline" rel="noopener noreferrer"&gt;https://unix.stackexchange.com/questions/113515/how-to-modify-output-in-bash-command-pipeline&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://unix.stackexchange.com/questions/131013/formatting-numbers-using-awk-print" rel="noopener noreferrer"&gt;https://unix.stackexchange.com/questions/131013/formatting-numbers-using-awk-print&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/3272215/bash-how-to-perform-arithmetic-on-numbers-in-a-pipe" rel="noopener noreferrer"&gt;https://stackoverflow.com/questions/3272215/bash-how-to-perform-arithmetic-on-numbers-in-a-pipe&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Troubleshoot
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;ERROR: Build failed with: exit status 1

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://gitlab.com/gitlab-org/gitlab-runner/-/issues/114" rel="noopener noreferrer"&gt;https://gitlab.com/gitlab-org/gitlab-runner/-/issues/114&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://juejin.cn/post/6844903553970995207" rel="noopener noreferrer"&gt;https://juejin.cn/post/6844903553970995207&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/49444879/gitlab-ci-runner-job-failed-exit-status-1-when-changing-directory/54471745#54471745" rel="noopener noreferrer"&gt;https://stackoverflow.com/questions/49444879/gitlab-ci-runner-job-failed-exit-status-1-when-changing-directory/54471745#54471745&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

</description>
      <category>ios</category>
      <category>gitlab</category>
      <category>ci</category>
    </item>
    <item>
      <title>Using Cocoapods with Gemfile</title>
      <dc:creator>ryanzzff</dc:creator>
      <pubDate>Sun, 16 Feb 2020 12:17:55 +0000</pubDate>
      <link>https://forem.com/ryanzzff/using-cocoapods-with-gemfile-2577</link>
      <guid>https://forem.com/ryanzzff/using-cocoapods-with-gemfile-2577</guid>
      <description>&lt;p&gt;If you work in a team, it would be better if all team members have the same development environment. For instance, as an iOS developer, if we are using a different version of Cocoapods to install the 3rd party libraries, the generated &lt;code&gt;Podfile.lock&lt;/code&gt; or the &lt;code&gt;.xcworkspace&lt;/code&gt; file might be slightly different.&lt;/p&gt;

&lt;p&gt;We can use a Gemfile to sync it:&lt;/p&gt;

&lt;p&gt;Step 1. Create a file named &lt;code&gt;Gemfile&lt;/code&gt; in the same directory of the &lt;code&gt;Podfile&lt;/code&gt; and &lt;code&gt;.xcodeproj&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source 'https://rubygems.org'
gem 'cocoapods'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;you may also specify the version of the cocoapods:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source 'https://rubygems.org'
gem "cocoapods", "1.8.4"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Step 2. Install bundler with gem in user directory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gem install bundler --user-install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Step 3. Install cocoapods with the version specified for the project (into the local relative path &lt;code&gt;vendor/bundle&lt;/code&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bundle install --path vendor/bundle
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To verify the version installed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bundle exec pod --version
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Step 4. Instead of using &lt;code&gt;pod install&lt;/code&gt;, we now have to use a new command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bundle exec pod install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Bonus:&lt;br&gt;
We can open the &lt;code&gt;.xcworkspace&lt;/code&gt; file automatically with Xcode right after &lt;code&gt;pod install&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bundle exec pod install &amp;amp;&amp;amp; xed .
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>ios</category>
      <category>cocoapods</category>
      <category>gem</category>
    </item>
  </channel>
</rss>
