让自己的项目或库文件支持cocoapods及相关问题

制作流程如下:

1.首先进入终端

2.执行命令行  'pod lib create MyLib' ,可参照官方文档

3.接下来会有三个选择项,请参照需要进行选择

4.进入example目录下,执行pod install 

5.完成之后打开workspace如下图:

6.可以在红点①下面的podspec编辑关于项目的一些信息

Pod::Spec.new do |spec|
  spec.name         = 'Reachability'
  spec.version      = '3.1.0'
  spec.license      = { :type => 'BSD' }
  spec.homepage     = 'https://github.com/tonymillion/Reachability'
  spec.authors      = { 'Tony Million' => '[email protected]' }
  spec.summary      = 'ARC and GCD Compatible Reachability Class for iOS and OS X.'
  spec.source       = { :git => 'https://github.com/tonymillion/Reachability.git', :tag => 'v3.1.0' }
  spec.source_files = 'Reachability.{h,m}'
  spec.framework    = 'SystemConfiguration'
end

Pod::Spec.new do |spec| spec.name = 'Reachability' spec.version = '3.1.0' spec.license = { :type => 'BSD' } spec.homepage = 'https://github.com/tonymillion/Reachability' spec.authors = { 'Tony Million' => '[email protected]' } spec.summary = 'ARC and GCD Compatible Reachability Class for iOS and OS X.' spec.source = { :git => 'https://github.com/tonymillion/Reachability.git', :tag => 'v3.1.0' } spec.module_name = 'Rich' spec.ios.deployment_target = '9.0' spec.osx.deployment_target = '10.10' spec.source_files = 'Reachability/common/*.swift' spec.ios.source_files = 'Reachability/ios/*.swift', 'Reachability/extensions/*.swift' spec.osx.source_files = 'Reachability/osx/*.swift' spec.framework = 'SystemConfiguration' spec.ios.framework = 'UIKit' spec.osx.framework = 'AppKit' spec.dependency 'SomeOtherPod' end



7.编辑完.podspec 文件之后,进入lib根目录,执行命令行 'pod lib lint xxx.podspec',确保没有警告和错误(警告后面会说到)

8.最后可以push 你的项目到github或git 服务器上了,执行以下命令:

git add

git commit -m “Initial Commit"

git remote add origin https://github.com/<GITHUB_USERNAME>/xxx.git//replace <GITHUB_USERNAME> with your github.com username

git push -u origin master

相关问题

1. error: include of non-modular header inside framework module 'xxx.xxx'

可以将第三方库文件导入形式 改为 import xxx;

并在build setting里面设置:allow non-modular includes in framework modules 设置为YES

在github 上也有相关解决方法:

https://github.com/CocoaPods/CocoaPods/issues/4420

2. 如果制作的pod 有警告则验证不通过,需要去除警告:

pod repo push xxxSpec xxx.podspec --allow-warnings

3. - ERROR | [iOS] unknown: Encountered an unknown error (The 'Pods-App' target has transitive dependencies that include static binaries:

由于依赖了静态库,所以报错,需使用命令:

--use-libraries

pod repo push xxxSpecs xxx.podspec --allow-warnings --use-libraries

4. 如何测试私有pod 库

注:需要在podfile 中添加对应仓库的spec, 并且执行者需要拥有对应仓库的权限

source 'https://github.com/CocoaPods/Specs.git'

source 'https://gitee.com/xxx/xxx.git' ,私有仓库地址

参考文献:

https://code.tutsplus.com/tutorials/creating-your-first-cocoapod--cms-24332

http://guides.cocoapods.org/syntax/podspec.html

猜你喜欢

转载自blog.csdn.net/a411360945/article/details/52900492