Nice to meet you, I've been learning swift for a little over two weeks. I have a library I want to use, and when I tried to install CocoaPods for package management, there were some clogging points, so make a note of it. The installation procedure is also posted while eliminating the error. Sorry to trouble you if you make any mistakes, but please leave a comment.
macOS Catalina 10.15.6 xcode 11.1
Start the terminal and install cocoapods with the following command.
sudo gem install cocoapods
However, I immediately got the following error here.
ERROR: Loading command: install (LoadError)
dlopen(×××××××××/.rbenv/versions/2.5.0/lib/ruby/2.5.0/x86_64-darwin16/openssl.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: ×××××××××/.rbenv/versions/2.5.0/lib/ruby/2.5.0/x86_64-darwin16/openssl.bundle
Reason: image not found - ×××××××××/.rbenv/versions/2.5.0/lib/ruby/2.5.0/x86_64-darwin16/openssl.bundle ERundefined method `invoke_with_build_ar
A solution to this error can be found in this article,
$ rbenv uninstall 2.5.0
$ rbenv install 2.5.0
I was able to solve it by doing.
Replace the version with the one in your environment in the error content.
In my case, the error content was 2.5.0
, so I specified it.
Then run the installation again.
sudo gem install cocoapods
This time it was successful.
Set up library information.
pod setup
Then move to the project.
I am here
What level is the project?
It seems that it refers to the hierarchy with project name.xcodeproj
.
I made a mistake and went to the lower level sweat
When you execute the following command, a file called Podfile
will be created in the current hierarchy (project).
pod init
It is as follows in the initial state.
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'UIMenuItem' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for UIMenuItem
end
This time I wanted to use a library called FloatingPanel, so edit it as follows.
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'UIMenuItem' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for UIMenuItem
pod 'FloatingPanel' #Postscript
end
Added pod'FloatingPanel'
When you're done editing, save and close the file.
By executing the following command, the library will be installed according to the description in the Podfile.
pod install
I made a slight mistake here and got stuck.
So far
Project name.xcodeproj
I opened the file and worked on it, but the library could not be used there.
After investigating, after the introduction of CocoaPods,
You will be working on a file called project name.xcworkspace
.
Since it is made in the same hierarchy, please open this without making a mistake.
Import the library.
ViewController
import UIKit
import FloatingPanel //Import library
class ViewController: UIViewController {
//Abbreviation
Many articles ended here, but in my case
No such module 'FloatingPanel'
I got the error. The solution to this error is here (https://stackoverflow.com/questions/31065447/no-such-module-when-i-use-cocoapods). It's a fairly old question on stackoverflow, but when I tried it as it was, the error disappeared.
I will write the procedure.
First, find and click Manage Schemes ...
by referring to the image below.
Check the library name in the menu below. This will eliminate the error.
that's all.