制作自己cocoapods库 出现Unable to find a pod with name, author, summary, or description matching解决方法 VIM退出命令 pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on 如何制作自己的CocoaPod库

https://www.cnblogs.com/czc-wjm/p/5958103.html

今天来讲一下cocoapods制作,网上教程很多,就不再讲理论,直接操作:

1、创建仓库:

制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库

2、将仓库克隆本地:

1
git clone https://github.com/2360219637/CZCTestCode.git

 3、创建.podspes文件,此处命名为CZCTestCode

1
$ pod spec create CZCTestCode

 4、在桌面CZCTestCode目录中创建工程(此处命名为CZCTestCode),创建共享的类

制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库

5、编辑podspec文件

制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库

Pod::Spec.new do |s|

s.name         = "CZCTestCode"

s.version      = "1.0.0"

s.summary      = "一个建立pod仓库的简单demo."

s.description  = <<-DESC

这只是一个建立pod仓库的简单demo,并没有实际的意思。教学使用。

DESC

s.homepage     = "https://github.com/2360219637/CZCTestCode"

s.license      = { :type => "MIT", :file => "LICENSE" }

s.author             = { "陈志超" => "2360219637@qq.com" }

s.platform     = :ios, "7.0"

s.source       = { :git => "https://github.com/2360219637/CZCTestCode.git", :tag => s.version }

s.source_files  = "Classes", "CZCTestCode/CZCTestCode/Classes/**/*.{h,m}"

s.requires_arc = true

end

制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库

6、上传git并打tag

1
2
3
4
$ git add -A && git commit -m "创建版本 1.0.0."
$ git tag '1.0.0'
$ git push --tags
$ git push origin master

 7、验证podspec

1
$ pod spec lint

 验证成功会出现以下提示:

制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库

8、pod主干注册

1
pod trunk register 2360219637@qq.com "czc"

 9、发布你的pod

1
pod trunk push CZCTestCode.podspec

 这个过程等待时间较长,成功截图:

制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库

如果失败  按提示 输入 

pod repo update --verbose

sudo gem install cocoapods --pre

10、完成,此时终端可搜索到自己创建的pod库

制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库

如需转载,请注明出处
 
 

pod search 库名

 版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/conglin1991/article/details/55096422


制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库

  1. 执行pod setup其实在你安装CocoaPods执行pod install时,系统会默认操作pod setup,然而由于中国强大的墙可能会pod setup不成功。这时就需要手动执行pod setup指令,如下: 
    终端输入:pod setup 
    会出现Setting up CocoaPods master repo,稍等几十秒,最底下会输出Setup completed。说明执行pod setup成功。 
    如果pod search操作还是搜索失败,如下: 
    终端输入:pod search AFNetworking

  2. 删除~/Library/Caches/CocoaPods目录下的search_index.json文件 
    pod setup成功后,依然不能pod search,是因为之前你执行pod search生成了search_index.json,此时需要删掉。 
    终端输入:rm ~/Library/Caches/CocoaPods/search_index.json 
    删除成功后,再执行pod search。 
    执行pod search 
    终端输入:pod search afnetworking(不区分大小写) 
    输出:Creating search index for spec repo ‘master’.. Done!,稍等片刻······就会出现所有带有afnetworking字段的类库。

VIM退出命令

 

注意:这些命令前面都有一个冒号:

当编辑完文档,准备退出Vi返回到shell时,能够使用以下几种方法之一。

在命令模式中,连按两次大写字母Z,若当前编辑的文档曾被修改过,则Vi保存该文档后退出,返回到shell;若当前编辑的文档没被修改过,则Vi直接退出, 返回到shell。

在末行模式下,输入命令

:w

Vi保存当前编辑文档,但并不退出,而是继续等待用户输入命令。在使用w命令时,能够再给编辑文档起一个新的文档名。

[例6]

:w newfile

此时Vi将把当前文档的内容保存到指定的newfile中,而原有文档保持不变。若newfile是个已存在的文档,则Vi在显示窗口的状态行给出提示信息:

File exists (use ! to override)

此时,若用户真的希望用文档的当前内容替换newfile中原有内容,可使用命令

:w! newfile

否则可选择另外的文档名来保存当前文档。

在末行模式下,输入命令

:q

系统退出Vi返回到shell。若在用此命令退出Vi时,编辑文档没有被保存,则Vi在显示窗口的最末行显示如下信息:

No write since last change (use ! to overrides)

提示用户该文档被修改后没有保存,然后Vi并不退出,继续等待用户命令。若用户就是不想保存被修改后的文档而要强行退出Vi时,可使用命令

:q!

Vi放弃所作修改而直接退到shell下。


在末行模式下,输入命令

:wq

Vi将先保存文档,然后退出Vi返回到shell。

在末行模式下,输入命令

:x

该命令的功能同命令模式下的ZZ命令功能相同。

 
 

pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on

制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库

 
 

如何制作自己的CocoaPod库

https://blog.csdn.net/qq_34047841/article/details/61195978

制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库
流程图

1.将代码托管在github上

1.1本地代码

制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库
Snip20161228_7.png

在github上创建 并上传



制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库
Snip20161228_3.png

切换到本地项目cd xxx路径后 用git命令行 (记不住命令行 git help) 步骤如下:

$ git init

$ git add /Users/kevin/Desktop/xxx //直接拖拉项目文件夹

$ git commit -m 'frsit commit' //推到本地仓库

$ git remote add origin https://github.com/xxx/xxx.git //本地仓库关联github

$ git push -u origin master //推到远程github

给项目branches打上指定的tag



    • # tag


    • git tag -m "New Tag" '1.0'


    • # tag推到远程仓库


    • git push --tags

拉取github代码到pods管理本地目录中(本地文件夹:~/.cocoapods/repos )



  • # pod repo add [私有项目名(repo库)] [github地址]


  • $ pod repo add  KKSWiftHUD  https://github.com/xxx/xxx.git

执行后可以cmd+shift +G 输入~/.cocoapods/repos 查看文件的存在

ok ,接下来开始创建pod的一个关键文件(类似项目中Podfile文件)

还是回到项目文件中来(查看ls

、创建podspec文件



  • # 创建podspec文件


  • $ pod spec create KKSwiftHUD

这时项目中会生成一个KKSwiftHUD.podspec文件 用XCode 打开

把这个粘贴覆盖过去 ( 系统生成很多,这些参数够用了)



  • Pod::Spec.new do |s|


  •  


  • s.name         = "KKSwiftHUD"


  • s.version      = "1.0"


  • s.summary      = "Notification HUD for ios."


  • s.homepage     = "https://github.com/one-tea/KKSwiftHUD.git"


  • s.license          = { :type => "MIT", :file => "LICENSE" }


  • s.author       = { "Zhang KK" => "zhangkkwy@163.com" }


  • s.platform     = :ios, "8.0"


  • s.source       = { :git => "https://github.com/one-tea/KKSwiftHUD.git", :tag => "1.0" }


  • s.source_files = "KKSwiftHUDLib/*"


  • s.framework       = "UIKit"


  • s.requires_arc = true


  •  


  • # s.frameworks = "SomeFramework", "AnotherFramework"


  •  


  • end

根据自己的信息,进行编辑xxx.podspec文件



  • s.name         = "xxx" //pod名字


  • s.version      = "1.0"//版本号


  • s.summary      = "Notification HUD for ios."//简介


  • s.homepage     = "https://github.com/xxx.git"// 托管地址


  • s.license      = "MIT"


  • s.author       = { "Zhang KK" => "zhangkkwy@163.com" }// 个人信息


  • s.platform     = :ios, "8.0"


  • s.source       = { :git => "https://github.com/one-tea/KKSwiftHUD.git", :tag => "1.0" }// github上地址和tag


  • s.source_files = "KKSwiftHUDLib/*"  //相对于``KKSwiftHUD.podspec``的路径地址,/**:表示在``KKSwiftHUDLib``下所有文件,如果是OC语言也可以用正则语法``KKSwiftHUDLib/**/*.{h,m} ``


  • s.framework       = "UIKit" //依赖库


  • s.requires_arc = true


  • s.resources = "KKSwiftHUD/*.png" 图片资源

参数的注释:



  •  name: 导入pod后的目录名


  •  version: 当前版本号


  •  deployment_target: 配置的target


  •  prefix_header_file: 预编译头文件路径,将该文件的内容插入到Pod的pch文件内


  •  source: 来源的具体路径,是http链接还是本地路径 requires_arc: 是否需要arc


  •  source_files: 指定该目录下包含哪些文件 其他可选参数还包括: dependency: 指定依赖,如果依赖的库不存在或者依赖库的版本不符合要求将会报错


  •  libraries: 指定导入的库,比如sqlite3


  •  frameworks: 指定导入的framework


  •  weak_frameworks: 弱链接,比如说一个项目同时兼容iOS6和iOS7,但某一个framework只在iOS7上有,这时候如果用强链接,那么在iOS7上运行就会crash,使用weak_frameworks可以避免这种情况。

通配符说明:



  • a{bb,bc}def.{h,m}表示四个文件abbdef.h abbdef.m abcdef.h abcdef.m


  • *.{h,m,mm}表示所有的.h .m .mm文件Class/**/*.{h,m}表示Class目录下的所有.h .m文件

二、测试下podspec配置文件是否有错误



  • $ pod lib lint  // 验证是否有合格


  • $ pod spec lint  // 这个也可以验证

注:如果出现WARN 可以加入--allow-warnings忽略

需要花些时间,最后没有error提示则成功

三、提交podspec到私有库



  • # pod repo push [repo仓名] [podspec文件名]


  •  


  • $ pod repo push  xxx  xxx.podspec

完成之后这个私有库就添加到我们的私有Spec Repo中,可以进入到~/.cocoapods/repos目录下查看

接下来推送到远端CocoaPod, 这样别人就可通过 pod search xxx来搜到并使用

四、创建一个trunk账号(用于上传到公共库Cocoapods



  • $ sudo gem install cocoapods // 先更新下Cocoapods版本


  • $ pod trunk register 邮箱 '昵称' --verbose // 填写账号信息,注册完要去邮箱点一个验证邮件(邮箱最好和git的邮箱保持一致)


  • $ pod trunk me // 验证完成后可以查看账号信息

填写账号信息,注册完要去邮箱点一个验证邮件(邮箱最好和git的邮箱保持一致)

运行结果,成功

制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库
Snip20161229_11.png

最后一步 trunk提交就可以了



  • # 提交podspec文件到trunkpod trunk push NNATree.podspec


  •   pod trunk push --allow-warnings

需要一会时间

制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库

图片.png
    1. 成功了!

      pod search xxx 可能需要等一会才能搜到 或者运行 pod setup试试

      最后:

      • 删除一个私有库
      • $ pod repo remove xxx
      • 这样就从本地删除了当然我们还可以通过下面的代码添加回来
      • $ pod repo add NNASpec http:// github.com/xxx.git
      • CocoPod管理命令

      制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库

      远程库管理
      制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库
      图片.png
 
 
 
 
 
 
 
 
 

今天来讲一下cocoapods制作,网上教程很多,就不再讲理论,直接操作:

1、创建仓库:

制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库

2、将仓库克隆本地:

1
git clone https://github.com/2360219637/CZCTestCode.git

 3、创建.podspes文件,此处命名为CZCTestCode

1
$ pod spec create CZCTestCode

 4、在桌面CZCTestCode目录中创建工程(此处命名为CZCTestCode),创建共享的类

制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库

5、编辑podspec文件

制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库

Pod::Spec.new do |s|

s.name         = "CZCTestCode"

s.version      = "1.0.0"

s.summary      = "一个建立pod仓库的简单demo."

s.description  = <<-DESC

这只是一个建立pod仓库的简单demo,并没有实际的意思。教学使用。

DESC

s.homepage     = "https://github.com/2360219637/CZCTestCode"

s.license      = { :type => "MIT", :file => "LICENSE" }

s.author             = { "陈志超" => "2360219637@qq.com" }

s.platform     = :ios, "7.0"

s.source       = { :git => "https://github.com/2360219637/CZCTestCode.git", :tag => s.version }

s.source_files  = "Classes", "CZCTestCode/CZCTestCode/Classes/**/*.{h,m}"

s.requires_arc = true

end

制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库

6、上传git并打tag

1
2
3
4
$ git add -A && git commit -m "创建版本 1.0.0."
$ git tag '1.0.0'
$ git push --tags
$ git push origin master

 7、验证podspec

1
$ pod spec lint

 验证成功会出现以下提示:

制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库

8、pod主干注册

1
pod trunk register 2360219637@qq.com "czc"

 9、发布你的pod

1
pod trunk push CZCTestCode.podspec

 这个过程等待时间较长,成功截图:

制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库

如果失败  按提示 输入 

pod repo update --verbose

sudo gem install cocoapods --pre

10、完成,此时终端可搜索到自己创建的pod库

制作自己cocoapods库
出现Unable to find a pod with name, author, summary, or description matching解决方法
VIM退出命令
pod 组件验证时报错,Could not find a `ios` simulator, Ensure that Xcode -> Window -> Devices has at least on
如何制作自己的CocoaPod库

注意:这些命令前面都有一个冒号:

当编辑完文档,准备退出Vi返回到shell时,能够使用以下几种方法之一。

在命令模式中,连按两次大写字母Z,若当前编辑的文档曾被修改过,则Vi保存该文档后退出,返回到shell;若当前编辑的文档没被修改过,则Vi直接退出, 返回到shell。

在末行模式下,输入命令

:w

Vi保存当前编辑文档,但并不退出,而是继续等待用户输入命令。在使用w命令时,能够再给编辑文档起一个新的文档名。

[例6]

:w newfile

此时Vi将把当前文档的内容保存到指定的newfile中,而原有文档保持不变。若newfile是个已存在的文档,则Vi在显示窗口的状态行给出提示信息:

File exists (use ! to override)

此时,若用户真的希望用文档的当前内容替换newfile中原有内容,可使用命令

:w! newfile

否则可选择另外的文档名来保存当前文档。

在末行模式下,输入命令

:q

系统退出Vi返回到shell。若在用此命令退出Vi时,编辑文档没有被保存,则Vi在显示窗口的最末行显示如下信息:

No write since last change (use ! to overrides)

提示用户该文档被修改后没有保存,然后Vi并不退出,继续等待用户命令。若用户就是不想保存被修改后的文档而要强行退出Vi时,可使用命令

:q!

Vi放弃所作修改而直接退到shell下。


在末行模式下,输入命令

:wq

Vi将先保存文档,然后退出Vi返回到shell。

在末行模式下,输入命令

:x

该命令的功能同命令模式下的ZZ命令功能相同。