Instructions for creating a library with CocoaPods

Tram Ho

1. What is CocoaPods?

CocoaPods is a program that manages the libraries of the Mobile application for iOS. We can go to CocoaPods to search for libraries that the application needs to use. To be able to use, I need to install the CocoaPods toolkit to be able to link into our application. The CocoaPods contain libraries including Swift and Object-C.

Homepage: https://cocoapods.org

2. Install CocoaPods

CocoaPods are written in Ruby language. On OSX, you can just type the following command.

sudo gem install cocoapods

3. Create a library using the Command Line of CocoaPods

On OSX, open Terminal to do it. Please CD to the folder you want to contain Lib CocoaPods.

pod lib create {name library}

The pod will now perform the Cloning from the pod template from GIT to your folder.
Then there will be some questions that you have to answer.

  • What platform do you want to use?? [ iOS / macOS ]
    Which platform do you want to use for iOS or macOS
  • What language do you want to use?? [ Swift / ObjC ]
    Programming language in your library
  • Would you like to include a demo application with your library? [ Yes / No ]
    Want a demo available in the gallery?
  • Which testing frameworks will you use? [ Quick / None ]
    Is testing available in there?
  • Would you like to do view based testing? [ Yes / No ]
    Performing based testing?

After a few lines of code have been answered by you, the command line will continue running until the Xcode Project opens itself. So the basic creation process has ended.

4. Config PodSpec

You can open the PodSpec file to reconfigure the library’s settings. Find out more through https://guides.cocoapods.org/syntax/podspec.html

Source
https://guides.cocoapods.org/making/making-a-cocoapod.html

Share the news now

Source : Viblo