创建私有podspec

作者: CoderLocus | 来源:发表于2016-06-28 11:11 被阅读341次

创建私有podspec

1.创建私有Spec Repo

cd ~/.cocoapods/repos
pod repo add UnfaeSpecs http://git.com/scm/ap/jql-ios-cocoaspecs.git

执行完上面步骤后,在~/.cocoapods/repos目录下会多出一个UnfaeSpecs目录,说明我们创建私有Spec Repo完成。

2.创建Pod项目工程文件

首先,cd到要创建项目的目录,然后执行

➜ ~ cd ~/developments/ios/unfae
➜ jingql pod lib create TestRepo

Cloning 'https://github.com/CocoaPods/pod-template.git' into 'TestRepo'.
Configuring TestRepo template.


To get you started we need to ask a few questions, this should only take a minute.
If this is your first time we recommend running through with the guide:

What language do you want to use?? [ ObjC / Swift ]

ObjC
Would you like to include a demo application with your library? [ Yes / No ]
Yes
Which testing frameworks will you use? [ Specta / Kiwi / None ]
Specta
Would you like to do view based testing? [ Yes / No ]
Yes
What is your class prefix?
JLS
Running pod install on your new library.
Updating local specs repositories
CocoaPods 1.0.0.beta.6 is available.
To update use: 'gem install cocoapods --pre'
[!] This is a test version we'd love you to try.
For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.

Analyzing dependencies
Fetching podspec for 'TestRepo' from '../'
Downloading dependencies
Installing Expecta (1.0.5)
Installing Expecta+Snapshots (2.0.0)
Installing FBSnapshotTestCase (2.0.7)
Installing Specta (1.0.5)
Installing TestRepo (0.1.0)
Generating Pods project
Integrating client project
[!] Please close any current Xcode sessions and use 'TestRepo.xcworkspace' for this project from now on.
Sending stats
Sending stats
Pod installation complete! There are 5 dependencies from the Podfile and 5 total pods installed.
Ace! you're ready to go!
We will start you off by opening your project in Xcode
open 'TestRepo/Example/TestRepo.xcworkspace'
To learn more about the template see 'https://github.com/CocoaPods/pod-template.git'.
To learn more about creating a new pod, see 'http://guides.cocoapods.org/making/making-a-cocoapod'.

3.添加库文件

执行完上面操作后

➜ unfae cd TestRepo
➜ TestRepo git:(master) ✗ tree -L 2
.
├── Example
│ ├── Podfile
│ ├── Podfile.lock
│ ├── Pods
│ ├── TestRepo

│ ├── TestRepo.xcodeproj
│ ├── TestRepo.xcworkspace
│ └── Tests
├── LICENSE
├── Pod
│ ├── Assets
│ └── Classes
├── README.md
├── TestRepo.podspec
└── _Pods.xcodeproj -> Example/Pods/Pods.xcodeproj
10 directories, 5 files

此时,用xcode打开TestRepo.xcworkspace文件,我们会看到刚添加的组件已经在Pods子工程下Development Pods/TestRepo中了,接下来我们要做的就是编辑Example工程,测试我们的组件是否OK。如果在测试的时候发现问题,那么我们每次向Pod中新添加了文件或更新了podspec版本,都要重新执行一遍pod update命令。
没问题后,我们将项目推送到远端,并打上tag

➜ Example git:(master) ✗ ..
➜ TestRepo git:(master) ✗ git add .
➜ TestRepo git:(master) ✗ git commit -m 'Initial Commit'
➜ TestRepo git:(master) git remote add origin http://git.ippjr-inc.com/scm/ap/jls-ios-testrepo.git
➜ TestRepo git:(master) git push origin master
➜ TestRepo git:(master) git tag -m "first releast" "0.1.0"
➜ TestRepo git:(master) git push --tags

4.编辑podspec文件

➜ TestRepo git:(master) vi TestRepo.podspec

Be sure to run `pod lib lint TestRepo.podspec' to ensure this is a

valid spec before submitting.

Any lines starting with a # are optional, but their use is encouraged

To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html

Pod::Spec.new do |s|
s.name = "TestRepo"
s.version = "0.1.0"
s.summary = "这里是简单介绍"

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 = <<-DESC
这里是项目描述
DESC
s.homepage = "http://git.com/projects/AP/repos/jql-ios-testrepo/browse"

s.screenshots = "www.example.com/screenshots_1", "www.example.com/screenshots_2"

s.license = 'MIT'
s.author = { "JingQL" => "JingQL_min@163com" }
s.source = { :git => "http://git.com/scm/ap/jql-ios-testrepo.git", :tag => "0.1.0" }

s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

s.platform = :ios, '7.0'
s.requires_arc = true
s.source_files = 'Pod/Classes//'
s.resource_bundles = {
'TestRepo' => ['Pod/Assets/
.png']
}

s.public_header_files = 'Pod/Classes/*/.h'

s.frameworks = 'UIKit', 'MapKit'

s.dependency 'AFNetworking', '~> 2.3'

end

接下来验证一下是否可用

➜ TestRepo git:(master) ✗ pod lib lint
-> TestRepo (0.1.0)
TestRepo passed validation.

5.向Spec Repo提交podspec

pod repo push JingQLSpecs TestRepo.podspec

其中,JingQLSpecs是我们的私有Spec Repo,上面命令执行成功后,这个组件就添加到我们的私有Spec Repo中了,同时远端仓库也添加了这个podspec

➜ JingQLSpecs git:(master) ll
total 0
drwxr-xr-x 3 xiaoz staff 102B 3 18 11:55 TestRepo

➜ ~ pod search TestRepo
-> TestRepo (0.1.0)
这里是简单介绍
pod 'TestRepo', '~> 0.1.0'

6.使用

在项目的Podfile里增加如下一行代码

pod 'TestRepo', '~> 0.1.0'

然后执行pod update

7.维护podspec

➜ git tag -a 0.1.1 -m '0.1.1'
➜ git push origin --tags
➜ vi JQLGesturesView.podspec

修改版本号s.version = '0.1.1',修改tag => '0.1.1'

➜ git add .
➜ git ci -m '..'
➜ git ps

接下来验证一下是否可用

➜ TestRepo git:(master) ✗ pod lib lint
-> TestRepo (0.1.1)
TestRepo passed validation.

就可以

➜ pod repo push JingQLSpecs JQLGesturesView.podspec

8.删除podspec

如果删掉整个私有Spec Repo

pod repo remove JingQLSpecs
但这只是本地删除,我们还可以找回
pod repo add JingQLSpecs http://git.com/scm/ap/jql-ios-cocoaspecs.git

删除某个Spec Repo

➜ ~ cd ~/.cocoapods/repos/JingQLSpecs
➜ JingQLSpecs git:(master) ll
total 0
drwxr-xr-x 3 xiaoz staff 102B 3 18 11:55 TestRepo

然后删掉库目录,之后将变动push到远程即可。

相关文章

网友评论

    本文标题:创建私有podspec

    本文链接:https://www.haomeiwen.com/subject/zwltjttx.html