How to use CocoaPods and some pits encountered

Note: If the links starting with @"http" such as "http://ruby.taobao.org/" are not easy to use, please change @"http" to @"https" to meet the new features of ios9. Such as: @"https://ruby.taobao.org/"

one:

     1. First of all, CocoaPods is based on the Ruby environment, but since the Mac itself has a Ruby environment now, it can be used directly.

two:

     1. The installation of CocoaPods is very simple and convenient, first open the terminal on the computer and enter the following command (don't add the $ symbol):

         $  sudo gem install cocoapods

         $ pod setup (will be slower because CocoaPods downloads his information)

    2. Because ruby's software source uses Amazon's cloud service, it is blocked. Generally, we will replace it with the source of domestic Taobao:

         $ gem sources --remove https://rubygems.org/

         $ gem sources -a http://ruby.taobao.org/

         $ gem sources -l

    3. If the following conditions occur, it is proved to be successful:

         *** CURRENT SOURCES ***

         http://ruby.taobao.org/


3. Use of CocoaPods

    1. It is very simple to use, create a project for you, and then find the location of your project in the terminal:

        Command in terminal: cd "project directory"

        If the project directory is not found, it seems that you can directly drag the project to the terminal.

    2. Then create a new Podfile file in the project directory, and still enter in the terminal:

        $ vim Podfile

        In the Podfile file, you can write the third-party library format you need:

        

platform :ios, '9.2'

target 'Frame' do

under 'AFNetworking', '3.0.0'

under 'SBJson', '4.0.0'
end

 

The frame is the folder of your project. Don't change the project folder, otherwise there will be problems.

       You can add as much as you need (you can add it at any time)

       Finally remember to press Esc and enter:

       :wq (save and quit)

    3. Then enter the download command:

       $ pod install

   4. If you see something like:

      From now on use `CocoaPodsDemo.xcworkspace`.

      The feedback information is then completed. The meaning of this sentence is to tell you: open the project with the .xcworkspace file instead of the previous .xcodeproj file.

4. When you open the project, you may find that the header file under the previous vc cannot reference a third party, then you need to do the following:

    1. Set it in the Target of the project: search for include in Build Settings and look for the User Header Search Paths item, enter ${SRCROOT} and select recursive, then you can use it.

 

Five. Three points to note:

    1. The file opened in the future must be opened by the .xcworkspace file, not the previous .xcodeproj file.

2 commonly used commands 

View the current system Cocoapods version command:
pod --version

 

6. Problems

1. After upgrading the latest system of the computer, Podfile   where aaaaa refers to the project name

2.

The use of cocoapods, the solution to the warehouse version from pod search is lower than the github warehouse version http://my.oschina.net/u/1432769/blog/384398#OSC_h1_1

3.

 

 

Let’s write so much first, I forgot to record what errors were made in the various pits encountered.

 

There will be an error in os x10.11 in this step of sudo gem install cocoapods, please refer to the following method to solve

http://www.07net01.com/2015/09/931270.html

Summary  Resolving an issue with CocoaPods on OS X 10.11. 

    I recently upgraded the mac system to the 10.11 system, but when I used the pod install command, it prompted command not found. Later, I checked the Internet and found out that Cocoapods has changed on the 10.11 system.

    The explanation found on stackoverflow is this, This is happening because Apple has enabled rootless on the new install, which means that Apple has enabled rootless installation on the 10.11 system. In this case, if you use the following command:

1
sudo gem install cocoa pods -v

    This prompt will appear:

1
ERROR:  While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/pod。

 

    In order to solve the above-mentioned problems and the normal use of Cocoapods on OS X 10.11 system, we need to enter such a sentence on the command line,

1
sudo gem install -n /usr/local/bin cocoapods

 

    This will solve the problem with Cocoapods on 10.11 systems.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324626049&siteId=291194637