Cocoapods and version control tips

Source: Internet
Author: User
Tags using git install cocoapods

Cocoaspods: Powerful third-party library management plug-in

Directly synthesized into the project, through the Simple pod command, realizes the download of the three-party resource library and the new iteration management.

There are many articles on the installation and use of Cocoaspods, here is a connection to cocoaspod and installation using here is


Objective-c.gitignore: In the Code development process version control, when using Git, there are actually some files are not necessary every time you upload version control,

Githubgitignore is a. Gitignore collection template, which is a simple introduction to its use.


First, cocoaspods installation use data collation

"First step": View your computer's Ruby environment

Terminal input gem sources

1. If it is already Taobao mirror "https://ruby.taobao.org/" directly into the "second step"

2. Image processing, A. If not, you need to remove the current mirror: Gem sources--remove https://ruby.taobao.org/

B. Immediately after using Taobao Image: Gem sources-a https://ruby.taobao.org/

"Step Two": Install Cocoaspods

1. Download: sudo gem install cocoapods (here wait until terminal appears **gems installed, indicating download complete)

2. Setup: Pod Setup (This step waits for setup completed, which means the settings are complete, then we can use it)

3. Check the progress, a. If you need to see the progress of the settings (many downloads, can be viewed) see the following methods:

B. Create a new terminal (COMMAND + N) and go to Cocoaspods (CD ~/cocoapods) to see the progress: Du-sh *

"Step three": Using Cocoaspods

1. Find the three-party library file: Pod search + third-party library name (supports tacit matching)

2. There may be a bunch of listings that you can choose to have the latest version of the library, for example: Pod ' Mbprogresshud ', ~> 0.8

3. If the project needs to be used, can enter the project directory (no project can be created xwcndict for example): CD + Engineering Path

4. Configure Podfile

A. Create the Podfile file (Vim podfile), enter the Podfile (enter the letter I into the edit state), edit the contents of the Podfile as follows: [ESC exits edit reload after input, shift+: Let input wq save edit and Exit]. -----------

Platform:ios, ' 9.0 '

Target "Xwcndict" do

Pod ' FMDB ', ' ~> 2.6 '

End

B. Save the Podfile settings, then do the library download or update: Pod install (pod update). After the first successful download, terminal will be prompted to open the project with a file with the. xcworkspace extension.

"Exception Analysis": Exceptions may occur during use

1. Terminal may error: the dependency FMDB (~>2.6) is not used in any concrete target

The reason is that in Cocoaspods advanced versions, the contents of the Podfile file must clearly indicate the targename of the third-party library used (target "targetName" do)

Low version:

Platform:ios, ' 9.0 '

Pod ' FMDB ', ' ~> 2.6 '

High version:

Platform:ios, ' 9.0 '

Target "Xwcndict" do

Pod ' FMDB ', ' ~> 2.6 '

End

2. If you use Cocoaspods now, the following methods are recommended:

A. In the current project directory, execute the command $ pod init to generate a Podfile file with initialization text in it.

B. Add the three-party repository you want to add to the appropriate location in the Podfile (the position before the last end)

C. Install command can use pod install--repo-update, can be faster, (pod install--help view command explanation)

Note that the existing framework is not updated after--repo-update, so it is fast and cannot be added with this parameter if the framework is upgraded.

D. This method initializes the text to look at the following: note the role of ' # ' here has a annotated meaning,

# Platform:ios, ' 9.0 '

# use_frameworks!

Removing the previous # symbol means that the three-party library will allow the requirements behind the permission, such as the support Platform ios,9 support user framework here.

Note that Swift does the development and integrates the cocoaspods, so you need to open the frame Use_frameworks (remove the # number)

The next big Guy (RAC) also needs to get rid of the # in front of Use_frameworks, because the RAC itself is also supported by Swift. Reactivecocoa Click to open link RAC here is
The following is how the Pod init method generates podfile text content

---------------

# Uncomment this line to define a global platform for your project
# Platform:ios, ' 9.0 '

Target ' Sinofont ' do
# Uncomment this line if you ' re using Swift or would as-use dynamic frameworks
# use_frameworks!

# Pods for Sinofont

End

Target ' sinotest ' do
# Uncomment this line if you ' re using Swift or would as-use dynamic frameworks
# use_frameworks!


# Pods for Sinotest

Target ' sinotesttests ' do
inherit! : search_paths
# Pods for testing
End

End

---------------


Ii. using the Github/.gitignore template file in OC

"How to use"

1. Go to GitHub to talk about. gitignore file collection download down (https://github.com/github/gitignore)

2. Open the Gitignore-master folder, where there are many. gitignore files, locate the Objective-c.gitignore file, and put it in the project directory.

3. Change the Objective-c.gitignore file name. Gitignore (keep the extension as good).

Note that there is no open file display, the above in the Finder directly renamed operation can not be completed, then you will know:

In terminal with the command to modify: $ mv Objective-c.gitignore. Gitignore the. gitignore file in the Finder is not visible.

You can use the $ ls-lag/(ls-al) command to view all the files in the Finder.

Add:

Defaults write Com.apple.finder appleshowallfiles-booleanfalse; Sets the visibility of the finder to hidden files, and then executes the following sentence to make the settings effective.

Killall finder;//Restart Finder


"Pods File Processing"

1. For the version management of project engineering using to Cocoaspods, we do not need to upload the pods file each time (consume server space, and upload also takes time), can do the processing mask pods each commit (adjust. gitignore file).

2. Workaround: Open the. gitignore file with a # symbol inside it, but unlike in podfile, it means that its corresponding items are all backed up to a git server.

3. Find the # Cocoapods, at the bottom there is a # Pods, will be in front of the # removed, indicating that Gitignore,pods will no longer be submitted.

4. If 3 is made, then the project on the server will not have the pods directory and need to install itself in the local pod.


The following is the text content in the. Gitignore

----------

# Xcode

#

# Gitignore Contributors:remember to update Global/xcode.gitignore, Objective-c.gitignore & Swift.gitignore


# # Build Generated

build/

deriveddata/


# # Various Settings

*.pbxuser

!default.pbxuser

*.mode1v3

!default.mode1v3

*.mode2v3

!default.mode2v3

*.perspectivev3

!default.perspectivev3

xcuserdata/


# # Other

*.moved-aside

*.xcuserstate


# # Obj-c/swift Specific

*.hmap

*.ipa

*.dsym.zip

*.dsym


# CocoaPods

#

# We recommend against adding the Pods directory to your. Gitignore. However

# Should judge for yourself, the pros and cons is mentioned at:

# Https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control

#

# pods/


# Carthage

#

# ADD This line if you want to avoid checking on source code from Carthage dependencies.

# carthage/checkouts


Carthage/build


# Fastlane

#

# It's recommended to not store the screenshots in the Git repo. Instead, use Fastlane to re-generate the

# screenshots whenever they is needed.

# For more information about the recommended setup visit:

# HTTPS://GITHUB.COM/FASTLANE/FASTLANE/BLOB/MASTER/FASTLANE/DOCS/GITIGNORE.MD


Fastlane/report.xml

Fastlane/screenshots


#Code Injection

#

# After new code injection tools there ' s a generated folder/iosinjectionproject

# Https://github.com/johnno1962/injectionforxcode


iosinjectionproject/



Add:

In addition to Cocoapods, after Swift in 14, another handy tool called Carthage

How to manage iOS dependent libraries using Carthage


Reference Document, Http://www.jianshu.com/p/5ccde5f22a17
Https://github.com/Carthage/Carthage/releases

------------




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.