IOS local project dependencies (CocoaPods local database management), ioscocoapods

Source: Internet
Author: User

IOS local project dependencies (CocoaPods local database management), ioscocoapods

IOS local dependencies are actually troublesome, and static libraries are used. a and. framework, but when you use a static library to access the static library, your program will report an error, and version management is troublesome.

Then we thought of using cocoapods as the dependency library. Because it is the company's code, it cannot be put on github, so we need to build a local dependency library.

First, install git and cocoapods

Git installation and use let's look at this article http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

The use of cocoapods installation to see the article http://code4app.com/article/cocoapods-install-usage

I will not elaborate on how to build this environment.

Apply for a github account and find New repository in the upper-right corner of the page.


After the creation is complete, we use git to clone to the local device.


git clone https://github.com/codesourse/podtest.git

Here we will use LICENSE and git Version Management

CocoaPods requires that all Pods dependent libraries must have license files; otherwise, the verification will not pass. There are many types of license. For details, refer to the website tl; dr Legal. When creating a github repository, I have selected a license of the MIT type.

Then we will create the. podspec file in this directory.

This file is the description file of the Pods dependent database. Each Pods dependent database must have only one description file. The file name must be consistent with the name of the dependent database we want to create. The name of the dependency library for my podtest is podtest. podspec.

Podspec File Content

Pod: Spec. new do | s. name = "podtest" s. version = "1.0.0" s. summary = "A marquee view used on iOS. "s. description = <-DESC It is a marquee view used on iOS, which implement by Objective-C. DESC s. homepage = "https://github.com/wangzz/WZMarqueeView" # s. screenshots = "www.example.com/screenshots_1", "www.example.com/screenshots_2" s. license = 'mit's. author = {"xia kejie" => "codesourse@gmail.com"} s. source = {: git => '/Users/xiakejie/cocoapods/podtest',: tag => "1.0.0"} # s. social_media_url = 'https: // twitter.com/NAME' s. platform =: ios, '4. 3' # s. ios. deployment_target = '5. 1' # s. osx. deployment_target = '10. 7's. requires_arc = true s. source_files = 'podtest /**/*. {h, m} '# s. resources = 'assets' # s. ios. exclude_files = 'classes/osx' # s. osx. exclude_files = 'classes/ios '# s. public_header_files = 'classes /**/*. h's. frameworks = 'Foundation ', 'coregraphics', 'uikit' end



Self-Resolution:

Name: directory name after pod import version: current version number deployment_target: configured target prefix_header_file: Pre-compiled header file path, insert the content of this file into the pch file of the Pod source: the specific path of the source, whether it is an http link or a local path requires_arc: whether arc source_files is required: Specify the files contained in the directory. Other optional parameters include: dependency: specifying dependencies, if the dependent library does not exist or the dependent library version does not meet the requirements, the following error occurs: libraries: Specifies the imported library, for example, sqlite3 frameworks: Specifies the imported framework weak_frameworks: weak link, for example, a project is compatible with both iOS6 and iOS7, but a framework is only available on iOS7. If a strong link is used, running on iOS7 will crash and weak_fr will be used. Ameworks can avoid this situation.

The entire podspec syntax is a nested structure from Pod: Spec. new do | s | to the last end is the largest loop, indicating the entire file imported by podspec. The end of each subspec is a sub-directory. Pods creates a logical directory for each subspec, which is equivalent to the group concept of Xcode. | ** | The name of subspec is in the middle. You can name it as needed, but the names used later must be consistent.

Wildcard description

A {bb, bc} def. {h, m} indicates four files: abbdef. h abbdef. m abcdef. h abcdef. m

*. {H, m, mm} indicates all. h. m. mm files.
Class/**/*. {h, m} indicates all. h. m files in the Class directory.


After this configuration, we need to use git to create a tag, and then cocoapods to make a tag and finally copy it to the local pod library.


git tag 1.0.0


 git add -A && git commit -m "Release 1.0.0"

set the new tag to 1.0.0


pod lib lint

Then put the podfile in the project you want to depend on. The content is

Pod 'podtest',: podspec => '/Users/xiakejie/cocoapods/podtest. podspec'

Finally, we only need to make a simple pod install

If

/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.35.0/lib/cocoapods/user_interface/error_report.rb: 13: in 'report': incompatible character encodings: UTF-8 and ASCII-8BIT (Encoding :: compatibilityError)
From/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.35.0/lib/cocoapods/command. rb: 58: in 'report _ error'
From/Library/Ruby/Gems/2.0.0/gems/claide-0.7.0/lib/claide/command. rb: 300: in 'handle _ exception'
From/Library/Ruby/Gems/2.0.0/gems/claide-0.7.0/lib/claide/command. rb: 274: in 'rescue in run'
From/Library/Ruby/Gems/2.0.0/gems/claide-0.7.0/lib/claide/command. rb: 264: in 'run'
From/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.35.0/lib/cocoapods/command. rb: 45: in 'run'
From/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.35.0/bin/pod: 43: in '<top (required)>'
From/usr/bin/pod: 23: in 'load'
From/usr/bin/pod: 23: in '<main>'

Read this article.

Http://www.tuicool.com/articles/iaqU3im


Our dependent projects are created.

Reference

Http://blog.csdn.net/djl4104804/article/details/25408395

Http://www.iwangke.me/2013/04/18/advanced-cocoapods/

Http://guides.cocoapods.org/using/the-podfile.html



Related Article

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.