Cocoapods Development Packaging Static Library

Source: Internet
Author: User
Tags static class install cocoapods

Cocoapods, as a class library management tool for OS X and iOS development platforms, is already very sophisticated and powerful. Here we demonstrate how to create a static class library with Cocoapods and a packaging process. automatic creation based on Pod

Just enter the pod's LIB command to complete the initial project, the following detailed steps to Xclogstaticdemo as a project name demo.
1 cd to an empty folder
2 perform pod lib create Xclogstaticdemo
The issues identified during the period are:

What language do your want to use?? [SWIFT/OBJC]  
 > OBJC

Would to include a demo application with your library? [Yes/no]  
 > YES

Which testing frameworks to use? [Specta/kiwi/none] 
 > None

Would Do view based testing? [Yes/no]
 > NO

What is your class prefix? 
 > XC

(3) to open the creation of a good xclogstaticdemo.podspec content modified as follows

# being sure to run ' pod Lib Lint xclogstaticdemo.podspec ' to ensure this is a # valid spec before submitting. # no lines starting with a # are optional, but their the use is encouraged # to learn more about a Podspec
  s.cocoapods.org/syntax/podspec.html # pod::spec.new do |s| S.name = ' Xclogstaticdemo ' s.version = ' 1.0.0 ' s.summary = ' A short description of Xclog

Staticdemo. '
# This description are used to generate tags and improve search results. # * Think:what does it do? Why did you write it?
What is the focus?
# * Try to keep it short, snappy.
# * Write The description between the DESC delimiters below.

  # Finally, don ' t worry about the indent, cocoapods strips it!
                       S.description = <<-desc Todo:add Long description of the pod here. DESC s.homepage = ' Https://github.com/name/XCCocoaPodsStaticDemo ' # s.screenshots = ' Www.example.com/scre Enshots_1 ', ' www.eXample.com/screenshots_2 ' S.license = {: Type => ' MIT ',: File => ' license '} s.author = {' Yo Urname ' => ' youremail '} s.source = {: Git => ' https://github.com/name/XCCocoaPodsStaticDemo.git ': Tag => s.version.to_s} # s.social_media_url = ' https://twitter.com/<twitter_username> ' # Deployment of system Requirements S.ios.deploy Ment_target = ' 8.0 ' # source core source s.source_files = ' xclogstaticdemo/classes/**/* ' # Resource bundles resource File # S.resource_bundles = {# ' Xclogstaticdemo ' => [' Xclogstaticdemo/assets/*.png '] #} header File # S.public_h Eader_files = ' Pod/classes/**/*.h ' # dependency frameworks Dependent Library # S.frameworks = ' Uikit ', ' mapkit ' # s.dependency ' A Fnetworking ', ' ~> 2.3 ' end

Enter the example folder, perform pod install, have the project install dependent and configure Updates
(5) Add the required code to the Xclogstaticdemo/classes file: (Corresponds to Xclogstaticdemo.podspec Source_files directory)
(6) test in demo, print successfully
(7) Submit local code library to GitHub
git Add.
git commit-m "install Demo"
Git push Origin master
If you encounter a git error problem, refer to the refusing to merge unrelated histories, After uploading to GitHub, label
git tag 1.0.0 (corresponding to Xclogstaticdemo.podspec s.version)
Git push Origin 1.0.0
(9) Create account br> pod Trunk Register mailbox Contact –description= "description" –verbose
Create success will receive mail, mailbox verification
Pod Trunk me can view trunk information
(10) Validate class library
Pod Lib lint-allow-warnings (ignoring errors)

appears passed validation validation succeeded.
(11) then commits to the Pod server network: The contents of the red box indicate success,
Pod trunk push-allow-warnings
encounters a pit that has:

(1) [!] {"Name" =>["is already Taken"]}, indicating that a public library with the same name exists, recreating a public library, Cocoapods does not allow the existence of a public library with duplicate names.
(2) All the final verification has passed and uploaded successfully, and the results are still not searchable using pod search
Solution:
1, the implementation of POD Setup
If the setup completed is output at the bottom. Instructions for performing pod setup successfully.
2, if the pod search operation or search failed, delete the Search_index.json file in the ~/library/caches/cocoapods directory.

RM ~/library/caches/cocoapods/search_index.json

Then execute:

Pod Search Xclogstaticdemo

Packaging Class Library

You need to use a Cocoapods plug-in Cocoapods-packager to complete the packaging of your class library. Of course, you can compile the package manually, but the process will be quite cumbersome.
Installing packaged Plug-ins
The terminal executes the following command

sudo gem install Cocoapods-packager

Pod Search
packaged

command is simple, execute

Pod Package Xclogstaticdemo.podspec--force

Where –library specifies that the package is packaged as a. A file, which is packaged as a. framework file if not taken. –force is a mandatory overlay. The final directory structure is as follows
|____xclogstaticdemo.podspec
|____xclogstaticdemo-1.0.0
| |____ios
| | |_____xclogstaticdemo.framework

Pod Package Xclogstaticdemo.podspec–library–force
Or is:
|____xclogstaticdemo.podspec
|____xclogstaticdemo-1.0.0
| |____ios
| | |_____libxclogstaticdemo.a

Create a new project with a static library of your own packaging and introduce the packaged framework for successful execution

Project GitHub

Reference blog:
1. Develop and package static libraries using Cocoapods
2. Step by step teach you to use Cocoapods to package a static library
3. Chat cocoapods and Xcode project configuration
4. Use of iOS cocoapods create public warehouse trample on the pit

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.