pod Spec管理配置


pod Spec 為自己的項目添加pod管理功能.
前言:
上一篇文章中提到,因為自己在操作的時候遇到很多坑,所在在此做一個記錄,同樣也希望可以幫到在這個操作上遇到坑的人。
本文將采用配圖和加文字的方式,以最直觀的方式呈現操作細節。如果文中有錯誤的地方,請大家指出以便即時做出調整。
一、首先在自己的github中添加新的管理目錄
1.進入github賬號管理中心,創建管理目錄。
以上過程請參考下圖:





2.上述創建目錄完成,接下來做上傳代碼至github倉庫。在此將按照空倉庫的方式,在終端進行上傳。操作的命令請參數github官網信息



> ``echo "# XLJSegScrollView" >> README.md``
> ``git init``
> ``git add README.md``
> ``git commit -m "first commit"``
> ``git remote add origin https://github.com/marlonxlj/XLJSegScrollView.git``
> ``git push -u origin master``

請參考下圖:
打開終端切換到本地工程的目錄下面;

二、創建pod Spec文件
根據上面的步驟操作完成,github倉庫中有了你上傳的代碼。接下來要做的就是創建pod spec 文件,同樣終端操作。pod 里面有一些命令,不在此做介紹,具體的使用方法:pod --help查看所有的命令。
>`` pod spec create XLJSegScrollView ``
>``其中XLJSegScrollView.podspec 這個命令可以自行定義``

三、配置spec文件
創建完成生會生成``XLJSegScrollView.podspec``這個文件。
可以使用vim 方式打開,或使用工具打開這個文件進行配置。

#
# Be sure to run `pod spec lint XLJSegScrollView.podspec' to ensure this is a
# valid spec and to remove all comments including this before submitting the spec.
#
# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
#

Pod::Spec.new do |s|

# ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# These will help people to find your library, and whilst it
# can feel like a chore to fill in it's definitely to your advantage. The
# summary should be tweet-length, and the description more in depth.
#

# ---- Spec 元數據-----------
s.name = "XLJSegScrollView" #這里的名字會跟pod search 中的名字一樣,和AFNetworking的名字一樣
s.version = "0.0.1" #版本號一定要和push tag的版本號一至
s.summary = "快速實現標題和下划線一起滾動的功能" #這里的描述不要和description描述相同,否則發報警告

# This description is 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 and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!

# 這個描述用來生成標簽和改善搜索結果
s.description = "標題內容滾動的封裝,可快速實現功能模塊。" #描述信息

# 主頁地址
s.homepage = "https://github.com/marlonxlj/XLJSegScrollView" #github倉庫的目錄
# s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"


# ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Licensing your code is important. See http://choosealicense.com for more info.
# CocoaPods will detect a license file if there is a named LICENSE*
# Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.
#

# s.license = "MIT (example)"
# s.license = { :type => "MIT", :file => "FILE_LICENSE" }
# -- Spec 授權協議----
s.license = { :type => "MIT", :file => "LICENSE" }


# ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Specify the authors of the library, with email addresses. Email addresses
# of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also
# accepts just a name if you'd rather not provide an email address.
#
# Specify a social_media_url where others can refer to, for example a twitter
# profile URL.
#

# 作者信息
s.author = { "marlonxlj" => "marlonxlj@163.com" }
# Or just: s.author = "marlonxlj"
# s.authors = { "marlonxlj" => "" }
# s.social_media_url = "http://twitter.com/marlonxlj"

# ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# If this Pod runs only on iOS or OS X, then specify the platform and
# the deployment target. You can optionally include the target after the platform.
#

# s.platform = :ios
# 平台信息
s.platform = :ios, "7.0"

# When using multiple platforms
# s.ios.deployment_target = "5.0"
# s.osx.deployment_target = "10.7"
# s.watchos.deployment_target = "2.0"
# s.tvos.deployment_target = "9.0"


# ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Specify the location from where the source should be retrieved.
# Supports git, hg, bzr, svn and HTTP.
#
# -- 資源在github的位置 ---
s.source = { :git => "https://github.com/marlonxlj/XLJSegScrollView.git", :tag => s.version }


# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# CocoaPods is smart about how it includes source code. For source files
# giving a folder will include any swift, h, m, mm, c & cpp files.
# For header files it will include any header in the folder.
# Not including the public_header_files will make all headers public.
#
# --源代碼位置---
s.source_files = "Classes", "XLJSegScrollView/Classes/XlJSegScrollviews/**/*.{h,m}"
# s.exclude_files = "Classes/Exclude"

# s.public_header_files = "Classes/**/*.h"


# ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# A list of resources included with the Pod. These are copied into the
# target bundle with a build phase script. Anything else will be cleaned.
# You can preserve files from being cleaned, please don't preserve
# non-essential files like tests, examples and documentation.
#
# -- 資源,一般較少用---
# s.resource = "icon.png"
# s.resources = "Resources/*.png"

# s.preserve_paths = "FilesToSave", "MoreFilesToSave"


# ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Link your library with frameworks, or libraries. Libraries do not include
# the lib prefix of their name.
#

# ---項目鏈接---
# 一般是framework和library等
# s.framework = "SomeFramework"
# s.frameworks = "SomeFramework", "AnotherFramework"

# s.library = "iconv"
# s.libraries = "iconv", "xml2"


# ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# If your library depends on compiler flags you can set them in the xcconfig hash
# where they will only apply to your library. If you depend on other Podspecs
# you can include multiple dependencies to ensure it works.

# ----項目依賴設置----
# 是否為ARC
s.requires_arc = true

# s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
# 項目依賴其它的第三方庫
# s.dependency "JSONKit", "~> 1.4"

end


四、上傳到pod服務器
上面的步驟做完了,在上傳到pod服務之前需要對配置文件進行驗證,也就是對本地的`XLJSegScrollView.podspec `進行正確性驗證。如下圖:

命令:`pod spec lint --verbose`

錯誤原因是沒有在pod服務器中添加版本號信息.
很重要
給pod添加tag信息,及版本號信息:

`git tag 0.0.1`

`git push --tag`

五、驗證pod功能添加是否成功
`pod search XLJSegScrollView`

`pod trunk push`

當出現下面這個錯誤的時候,心里就像出現了好多好多的馬,因為在`pod spec lint`的時候都是成功。在google了很多后,得到一個信息那就是等,耐心的等,為此我重復的等了40分鍾后成功上傳。
`[!]There was an error pushing a new version to trunk: getaddrinfo: nodename nor servname provided, or not known
`

網絡不好的情況下,請翻....,在不知重復了多少次后總算成功了。

 

 

Email:marlonxlj@163.com


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM