iOS Local project Dependencies (cocoapods manage local libraries)

Source: Internet
Author: User

iOS doing local dependencies is actually cumbersome, do static libraries. A and. Framework, but when you use static libraries to access static libraries, your program will error, and version management trouble.

Then we thought of using cocoapods as a dependency library, because it was the company's code that could not be put on GitHub, so we had to build a local dependency library.

First, we're going to install Git and cocoapods.

Git install and use just read this article http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

Cocoapods the use of installation just read this article http://code4app.com/article/cocoapods-install-usage

Concrete how to build this environment will not elaborate.

Next, apply for a GitHub account and find the upper right corner of the page New repository


Create complete we use git clone to local


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

Here we're going to use version management for license and GIT.

Cocoapods enforces that all pods dependent libraries must have license files, otherwise the validation will not pass. There are many types of license, please refer to website tl;dr Legal for details. When I created the GitHub repository, I had chosen the MIT type of license.

And then we're going to create the . podspec file under this directory

This file is a Pods dependent library profile, and each pods dependent library must have only one description file. The file name is consistent with the name of the dependent library that we want to create, and the file name for my podtest dependent library is podtest.podspec.

Podspec's File contents

Pod::spec.new do |s|
S.name = "podtest"
S.version = "1.0.0"
S.summary = "A marquee view used on IOS."
S.description = <<-desc
It's 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 = {"Shakoje" = "[email protected]"}
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-parsing:

 name: directory name after importing POD version: Current version number deployment_target: Configured target prefix_header_file: Precompiled header file path, inserting the contents of the file into the pod's PCH file Source: The specific path to the source, whether it is an HTTP link or a local path REQUIRES_ARC: If Arc source_files is required: Specify which files are included in the directory Other optional parameters include: dependency: Specifies the dependency, if the dependent library does not exist or depends on the version of the library does not meet the requirements will be an error libraries: Specify the imported library, such as Sqlite3 frameworks: Specify the imported framework Weak_ Frameworks: Weak links, such as a project that is compatible with both IOS6 and iOS7, but one framework is only available on iOS7, and if strong links are used, then running on iOS7 crash, using Weak_ Frameworks 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 that represents the entire Podspec imported file. Each subspec to end of the middle is a subdirectory, and pods creates a logical directory for each subspec, which corresponds to the group concept of Xcode. |**| is the name of Subspec and can be named casually, but the names used later must be the same.

Wildcard description

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

*. {H,M,MM} represents all the. h. M. mm files
class/**/*. {H,m} represents all. H. m files under the class directory


Configure this we need to use GIT to tag, and then cocoapods a tag to the last copy to the Pod local library


git tag 1.0.0

Set the new tag to 1.0.0


Pod Lib Lint

Then put Podfile in the project you want to rely on, and the content is

Pod ' podtest ',:p odspec = '/users/xiakejie/cocoapods/podtest/podtest.podspec '

In the end we just need a simple pod install

If you encounter this middle

/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> '

Well, then read this article.

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


Our dependent projects are made to completion

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



iOS Local project Dependencies (cocoapods manage local libraries)

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.