iOS development--create a podspec file to add pod support to your project
Source: Internet
Author: User
<span id="Label3"></p>The opening is Nonsense.<p><p>As an iOS developer, you must have used cocoapods, didn't you? point here to Wall.</p></p><p><p>Cocoapods as an iOS development package manager, to our development has brought great convenience, and more and more Third-party library support pod, can be integrated into their own project by Pod fool, then the problem, I also have a series of small tool classes, How to make it also support pod integration and make it easier for other friends to use?</p></p><p><p>just, The recent project is not tight, I try to get a bit, here to record the process of the attempt, a memo, and secondly share ...</p></p><p><p>In fact, this article on the Internet is numerous, but not necessarily is suitable for their own, such as the next thing I wrote that I think is applicable to me, but may not be suitable for you are reading this text, or there is a content below to help you, if so, I am also very happy</p></p><p><p>This article has a lot of imperfect places, the time is sufficient to gradually improve it</p></p><p><p>It's hard to write, brick, Mercy.</p></p>Let's go<p><p><code>我这里拿一个小demo做示例,目的是把工程中的一些category提取出来支持 pod</code></p></p>1. Upload the project source code<p><p>Upload the project source to GitHub repository and clone to local (take ios_category as an example-source here), if the project is in the GitHub warehouse, directly clone to local can</p></p>2. Create a Project's podspec file <ul> <ul> <li>Use the terminal command CD to the local project directory and execute the following command:</li> </ul> </ul><pre class="hljs sql"><pre class="hljs sql"><code class="sql"><span class="hljs-operator"><span class="hljs-keyword">create iOS_Category</span></span></code></pre></pre><p><p>A Ios_category.podspec file is generated locally</p></p> <ul> <ul> <li>Open The. Podspec file with the editor (i use sublime Text myself)</li> </ul> </ul><p><p>Delete Unnecessary comments (here is a simple introduction to basic usage, so use only one part of the field to have more fields please go to HTTP://GUIDES.COCOAPODS.ORG/SYNTAX/PODSPEC.HTML)</p></p><pre class="hljs sql"><code class="sql">Pod::spec.new<span class="hljs-operator"><span class="hljs-keyword">Do |s| S.<span class="hljs-keyword">Name =<span class="hljs-string">"ios_category" S.<span class="hljs-keyword">Version =<span class="hljs-string">"0.0.1" s.summary =<span class="hljs-string">"all kinds of categories for IOS develop" s.description = <<-<span class="hljs-keyword">DESC this<span class="hljs-keyword">Project provide all kinds<span class="hljs-keyword">of categories<span class="hljs-keyword">For IOS Developer<span class="hljs-keyword">DESC S.homepage =<span class="hljs-string">"https://github.com/yongqianvip/iOS_Category" S.license =<span class="hljs-string">"MIT" S.license = {:<span class="hljs-keyword">Type =<span class="hljs-string">"MIT",:<span class="hljs-keyword"><span class="hljs-keyword">file = <span class="hljs-string"> "LICENSE"} s.author = {<span class="hljs-string"> " YONGQIANVIP "= <span class=" hljs-string ">" [email protected]***.com "} s.platform =: iOS s.<span class=" Hljs-keyword ">source = {: git = <span class=" hljs-string ">" https://github.com/yongqianvip/iOS_Category.git ",: Tag = <span class="hljs-string"> "0.0.1"} s.source_files = <span class="hljs-string"> "Classes", <span class=" Hljs-string ">" ios_category/classes/**/*. {h,m} "s.exclude_files = <span class=" hljs-string ">" classes/exclude "s.public_header_files = <span class="hljs-string"> "ios_category/classes/uikit/ui_categories.h", <span class="hljs-string"> "iOS_Category /classes/foundation/foundation_category.h ", <span class=" hljs-string ">" ios_category/classes/**/*.h "s.requires_ Arc = <span class="hljs-literal">true<span class="hljs-keyword">end </span> </span> </span> </span> </span> </span> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre> <ul> <ul> <li>Verifying the Podspec file</li> </ul> </ul><p><p>After you finish editing the Podspec file, you need to verify that the file is available Podspec file does not allow any <code>Warning</code> or<code>Error</code><br>Execute command</p></p><pre class="hljs ruby"><pre class="hljs ruby"><code class="ruby"><span class="hljs-variable">$ pod lib lint</span></code></pre></pre><p><p>If it appears</p></p><pre class="hljs cpp"><pre class="hljs cpp"><code class="cpp">-> iOS_Category (<span class="hljs-number">0.0<span class="hljs-number">.1)iOS_Category passed validation.</span></span></code></pre></pre><p><p>Then the validation passes, otherwise, modify the Podspec file as prompted to verify it again until the validation passes</p></p><p><p>By the way, Xcode allows warnings to exist, so you can mask the warnings by command</p></p><pre class="hljs sql"><pre class="hljs sql"><code class="sql"><span class="hljs-comment">--allow-warnings</span></code></pre></pre><p><p>If error occurs but insufficient information is available, you can add it <code>--verbose</code> to get more error messages</p></p><pre class="hljs sql"><pre class="hljs sql"><code class="sql"><span class="hljs-comment">--verbose</span></code></pre></pre>3. Tag Upload Podspec<p><p>Podspec files need to specify the tag, complete the above operation to the project tag</p></p><pre class="hljs ruby"><pre class="hljs ruby"><code class="ruby"><span class="hljs-variable">$ git tag -m<span class="hljs-string">"first release iOS_Category with podspec" <span class="hljs-string">"0.0.1"<span class="hljs-variable">$ git push --tags</span></span></span></span></code></pre></pre><p><p>finally, Use the <code>pod trunk</code> command to push the Podspec file to the Cocoapod official library</p></p><p><p><code>pod trunk</code>Need to register specific practices here no longer repeat please visit Cocoapod official website</p></p><p><p><code>pod trunk</code>Execute command after Setup is complete</p></p><pre class="hljs perl"><pre class="hljs perl"><code class="perl"><span class="hljs-keyword">push iOS_Category.podspec</span></code></pre></pre><p><p>This process can be time-consuming, for reasons you know</p></p>4. finally<p><p>If all goes well</p></p><pre class="hljs undefined"><pre class="hljs undefined"><code>pod search iOS_Category</code></pre></pre><p><p>You can find the project and there are installation commands < pod ' ios_category ', ' ~>0.0.1 ' ></p></p><p><p><br><br></p></p>Wen/yin _ Passers-by (jane book Author)<br>Original Link: HTTP://WWW.JIANSHU.COM/P/D7D1942DD3F1<br>Copyright belongs to the author, please contact the author to obtain authorization, and Mark "book author".<p><p>iOS development--create a podspec file to add pod support to your project</p></p></span>
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