About installing Cocoapods

Introduction

This month, I got a MacBook Pro early 2015 at a store for 10,000 yen. (The battery was inflated, so I repaired it for 20,000 yen. The keyboard, trackpad, and battery are new.)

I love Apple so I was impressed with it.

So I started learning Swift, which I wanted to study when I got a Mac someday. I left it here because I stumbled a little while installing Cocoapods for learning.

environment

What are Cocoapods?

CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. It has over 79 thousand libraries and is used in over 3 million apps. CocoaPods can help you scale your projects elegantly. Cocoapods Official Website

When translated

CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. It has over 79,000 libraries and is used by over 3 million apps. CocoaPods help you scale your project elegantly.

In other words, it's a library management tool for iOS. If you don't use Cocoapods, you'll have to get and install all the libraries yourself.

Installation procedure

Cocoapods are installed using gems. (Mac comes with Ruby from the beginning)

Cocoapods installation sudo gem install cocoa pods

Cocoapods setup pod setup

However, I got an error like this during the installation.

ERROR:  Error installing cocoapods:
ERROR: Failed to build gem native extension.

Apparently, the reason is that the version of Ruby that comes with the Mac from the beginning does not support Cocoapods. The Ruby version of Catalina was 2.6.3.

There are two solutions (maybe) ・ Raise the version of Ruby ・ Lower the installed version of Cocoapods

This time, it was supported by raising the version of Rubu.

Ruby version upgrade

After investigating, it seems that Ruby is upgraded by using a version control tool called rbenv.

We have upgraded the version by referring to this article. How to upgrade Ruby on Mac terminal

After that, install and set up according to the flow introduced in the installation procedure, and you're done.

Summary

This time, I introduced the Cocoapods installation procedure and the Ruby version upgrade method required for it.

Currently, I am studying Swift using books and Udemy as a hobby. I can make Apple Watch, iPad, and Mac apps as well as iOS apps, so I would like to continue studying.

that's all

Recommended Posts

About installing Cocoapods
About installing cmake
About =
About method.invoke
About Kotlin
About attr_accessor
About Hinemos
About inheritance
About params
About Docker
About form_for
About Spring ③
About polymorphism
About Optional
About hashes
About JitPack
About Dockerfile
About this ()
About devise
About encapsulation
About Docker
About JAVA_HOME
About active_hash
About static
About exceptions
About scope
[Maven] About Maven
[Swift] Beginners stumbled upon installing CocoaPods & installation procedure