开始阅读本文前默认已安装CocoaPods环境
背景 为啥要学会创建私有库.png
-
在实际开发中可能会遇到在pod集成第三方库的时候,修改了源码,每一次pod 更新的时候都要小心翼翼的
-
封装的组件和模块需要在公司多个业务App里使用的时候,用pod管理会更容易维护和管理
-
一个较大的APP需要拆分出来两个或以上相互独立的APP时候,也可以用pod进行管理。
-
等等。。。。。
这些都是我在实际中遇到的迫切需要创建私有库的问题。
看之前可以了解一下CocoaPods原理,介绍文章挺多的 ,我就不啰嗦了
CocoaPods原理点这里
开始跟着我创建私有库吧
1.创建podspec文件
- 什么是podspec?文件夹打开
~/.cocoapods/repos
看到
specs存放的就是cocoapod官网库的
specification:说明书
,通过这个podspec文件里的信息,找到对应资源URL,然后clone到我们的pod中。可以理解为书的目录,我们查找第三方库的时候实际就是查找这个specs集合。所以我们创建私有库第一步就是创建我们的spec,目录。
- 开始创建私有库podspec,理解为pod私有库说明书
下面我会以我在实际开发中将修改过的网易云信的SDK放在私有库中过程进行一步步操作
在github上创建一个存放specification
的仓库,注意不是存放源码的库,一定不要搞错了
我建议先创建空的
repository
,为了区分命名最好以spec
为后缀,说明这是存说明书的库
然后将这个库添加到~/.cocoapods/repos
中,操作很简单,终端执行pod命令pod repo add TDNIMKitSpec git@github.com:strivever/TDNIMKitSpec.git
命令格式:
pod repo add 【specName】 【spec远程仓库地址】
第一步完成,GOGOGO
2.制作我们的pod库
-
cocoapods为我们提供了模板,cd 到你需要创建的文件夹里,然后
pod lib create.pngpod lib create TDNIMKit
( pod lib create 【你的pod库名】)命令,等待clone模板
等待一会....... templete.png
填写几个配置,很简单,根据实际需要选择即可。我选择的是iOS平台,object-C语言,创建demo,不需要测试框架等等。
配置完成之后,会自动打开拉取的模板工程。 - 以上都很简单,还是比较顺畅的,下边继续GO replaceMe.png
文件放的位置不一定必须在模板中的Classes中,只要后边路径填写正确即可。如图,我是直接放在了
TDNIMKit
下,Classes存放的是代码,NIMSDK存放的是SDK和.a文件,Resources是图片等资源文件。
- 文件导入成功之后,再回到我们的工程文件,打开
Podspec Metadata
文件夹下的TDNIMKit.podspec
文件,进行编辑,这是最重要也是最容易出错的一步。
看一下默认的podspec文件ruby代码:我简单的注释了一下
Pod::Spec.new do |s|
#pod私有库名称
s.name = 'TDNIMKit'
#pod私有库版本号
s.version = '0.1.0'
#pod私有库概要
s.summary = 'A short description of TDNIMKit.'
# 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
TODO: Add long description of the pod here.
DESC
#主要,最好能访问
s.homepage = 'https://github.com/458362366@qq.com/TDNIMKit'
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
#开源协议
s.license = { :type => 'MIT', :file => 'LICENSE' }
#开源作者
s.author = 'Striver'
#源码地址,clone时候就需要使用这个地址跟版本拉取
s.source = { :git => 'https://github.com/458362366@qq.com/TDNIMKit.git', :tag =>'0.1.0' }
#支持的系统版本
s.ios.deployment_target = '8.0'
#源码相对路径
s.source_files = 'TDNIMKit/Classes/**/*'
# s.resource_bundles = {
# 'TDNIMKit' => ['TDNIMKit/Assets/*.png']
# }
# s.public_header_files = 'Pod/Classes/**/*.h'
#需要使用的框架
# s.frameworks = 'UIKit', 'MapKit'
#依赖的其它第三方库
# s.dependency 'AFNetworking', '~> 2.3'
end
然后我来编辑一下这个podspec:
s.source_files
代码相对路径,这个最容易出错,我详细解释这个路径怎么去填:
所以我的s.source_files = 'TDNIMKit/Classes/**/*'
,意思匹配Classes目录下的所有文件和文件夹
当然如果你没有文件夹嵌套可以写 s.source_files = 'TDNIMKit/Classes/*.{h,m}'
,意思匹配Classes下的任意.h .m
文件
修改后
Pod::Spec.new do |s|
#pod私有库名称
s.name = 'TDNIMKit'
#pod私有库版本号
s.version = '0.1.0'
#pod私有库概要
s.summary = 'striver custom NIMUIKit'
#主要,最好能访问
s.homepage = 'https://github.com/458362366@qq.com/TDNIMKit'
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
#开源协议
s.license = { :type => 'MIT', :file => 'LICENSE' }
#开源作者
s.author = 'Striver'
#源码地址,clone时候就需要使用这个地址跟版本拉取
s.source = { :git => 'https://github.com/458362366@qq.com/TDNIMKit.git', :tag =>'0.1.0' }
#支持的系统版本
s.ios.deployment_target = '8.0'
#源码相对路径
s.source_files = 'TDNIMKit/Classes/**/*'
end
然后打开工程podfile文件
use_frameworks!
platform :ios, '8.0'
target 'TDNIMKit_Example' do
pod 'TDNIMKit', :path => '../'
target 'TDNIMKit_Tests' do
inherit! :search_paths
end
end
写入TDNIMKit.podspec路径 如下
use_frameworks!
platform :ios, '8.0'
target 'TDNIMKit_Example' do
pod 'TDNIMKit', :path => '../TDNIMKit.podspec'
target 'TDNIMKit_Tests' do
inherit! :search_paths
end
end
尝试去执行以下pod install
pod install
再看工程发送了什么变化: 工程已经导入了源码
不要高兴太早,你会发现我们的NIMSDK呢,我们资源路径怎么加载呢????
其实也是跟加载s.source_files
一样的:看一下framework文件夹下文件,framework 和.a文件
继续回去编辑TDNIMKit.podspec
增加如下代码
#资源文件加载
s.resources = 'TDNIMKit/Resources/*.*'
#framework文件加载
s.vendored_frameworks = '**/NIMSDK.framework'
#.a静态库加载
s.vendored_libraries = 'TDNIMKit/NIMSDK/Libs/*.a'
在pod install,完成后发现都导入了哈哈
资源文件,源码,framework都导入了
- 然后可以进行本地验证podspec文件是否正确了(一步步采坑指南);
cd 到TDNIMKit.podspec
目录:执行pod lib lint
,焦急的等待和期待!!!!!
果然会校验不通过,赶紧查看错误,经过一阵分析
-> TDNIMKit (0.1.0)
- WARN | url: The URL (https://github.com/458362366@qq.com/TDNIMKit) is not reachable.
- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
- NOTE | xcodebuild: note: Using new build system
- NOTE | [iOS] xcodebuild: note: Planning build
- NOTE | [iOS] xcodebuild: note: Constructing build description
- NOTE | [iOS] xcodebuild: warning: Skipping code signing because the target does not have an Info.plist file and one is not being generated automatically. (in target 'App' from project 'App')
- WARN | [iOS] xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/NIMSDK/NIMSDK.framework/Headers/NIMChatManagerProtocol.h:200:12: warning: parameter 'NIMMessage' not found in the function declaration [-Wdocumentation]
- NOTE | [iOS] xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/NIMSDK/NIMSDK.framework/Headers/NIMChatManagerProtocol.h:200:12: note: did you mean 'messages'?
- WARN | [iOS] xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/NIMSDK/NIMSDK.framework/Headers/NIMChatManagerProtocol.h:210:12: warning: parameter 'NIMMessage' not found in the function declaration [-Wdocumentation]
- NOTE | [iOS] xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/NIMSDK/NIMSDK.framework/Headers/NIMChatManagerProtocol.h:210:12: note: did you mean 'message'?
- WARN | [iOS] xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/NIMSDK/NIMSDK.framework/Headers/NIMConversationManagerProtocol.h:263:12: warning: parameter 'session' not found in the function declaration [-Wdocumentation]
- NOTE | [iOS] xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/NIMSDK/NIMSDK.framework/Headers/NIMConversationManagerProtocol.h:263:12: note: did you mean 'notify'?
- NOTE | [iOS] xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Global/NIMKitDependency.h:16:9: fatal error: 'M80AttributedLabel.h' file not found
[!] TDNIMKit did not pass validation, due to 1 error and 4 warnings.
You can use the `--no-clean` option to inspect any issue.
哦,原来是依赖了第三方库啊,我现在就去添加依赖。。继续编辑TDNIMKit.podspec
增加
#依赖的系统library
s.libraries = 'sqlite3.0', 'z', 'c++'
#依赖的第三方库
s.dependency 'M80AttributedLabel', '~> 1.9.9'
s.dependency 'FLAnimatedImage', '~> 1.0.12'
s.dependency 'SDWebImage', '~> 4.2.2'
s.dependency 'Toast', '~> 3.0'
s.dependency 'TZImagePickerController', '~> 3.2.1'
再pod install
Example [master●●] % pod install
Analyzing dependencies
Downloading dependencies
Installing FLAnimatedImage (1.0.12)
Installing M80AttributedLabel (1.9.9)
Installing SDWebImage (4.2.3)
Installing TDNIMKit 0.1.0
Installing TZImagePickerController (3.2.7)
Installing Toast (3.1.0)
Generating Pods project
Integrating client project
Pod installation complete! There is 1 dependency from the Podfile and 6 total pods installed.
离成功又进了一步啊
高兴.jpg
继续验证podspec,很激动,这会肯定能验证通过
-> TDNIMKit (0.1.0)
- WARN | url: The URL (https://github.com/458362366@qq.com/TDNIMKit) is not reachable.
- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
- NOTE | xcodebuild: note: Using new build system
- NOTE | [iOS] xcodebuild: note: Planning build
- NOTE | [iOS] xcodebuild: note: Constructing build description
- NOTE | [iOS] xcodebuild: warning: Skipping code signing because the target does not have an Info.plist file and one is not being generated automatically. (in target 'App' from project 'App')
- WARN | [iOS] xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/NIMSDK/NIMSDK.framework/Headers/NIMChatManagerProtocol.h:200:12: warning: parameter 'NIMMessage' not found in the function declaration [-Wdocumentation]
- NOTE | [iOS] xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/NIMSDK/NIMSDK.framework/Headers/NIMChatManagerProtocol.h:200:12: note: did you mean 'messages'?
- WARN | [iOS] xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/NIMSDK/NIMSDK.framework/Headers/NIMChatManagerProtocol.h:210:12: warning: parameter 'NIMMessage' not found in the function declaration [-Wdocumentation]
- NOTE | [iOS] xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/NIMSDK/NIMSDK.framework/Headers/NIMChatManagerProtocol.h:210:12: note: did you mean 'message'?
- WARN | [iOS] xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/NIMSDK/NIMSDK.framework/Headers/NIMConversationManagerProtocol.h:263:12: warning: parameter 'session' not found in the function declaration [-Wdocumentation]
- NOTE | [iOS] xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/NIMSDK/NIMSDK.framework/Headers/NIMConversationManagerProtocol.h:263:12: note: did you mean 'notify'?
- NOTE | [iOS] xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Global/NIMKitDependency.h:16:9: fatal error: 'M80AttributedLabel.h' file not found
[!] TDNIMKit did not pass validation, due to 1 error and 4 warnings.
You can use the `--no-clean` option to inspect any issue.
TDNIMKit [master●●] % cd Example
Example [master●●] % pod install
Analyzing dependencies
Downloading dependencies
Installing FLAnimatedImage (1.0.12)
Installing M80AttributedLabel (1.9.9)
Installing SDWebImage (4.2.3)
Installing TDNIMKit 0.1.0
Installing TZImagePickerController (3.2.7)
Installing Toast (3.1.0)
Generating Pods project
Integrating client project
Pod installation complete! There is 1 dependency from the Podfile and 6 total pods installed.
Example [master●●] % cd ..
TDNIMKit [master●●] % pod lib lint
-> TDNIMKit (0.1.0)
- WARN | url: The URL (https://github.com/458362366@qq.com/TDNIMKit) is not reachable.
- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
- NOTE | xcodebuild: note: Using new build system
- NOTE | [iOS] xcodebuild: note: Planning build
- NOTE | [iOS] xcodebuild: note: Constructing build description
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Team/NIMTeamMemberCardViewController.m:183:17: warning: block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior [-Wimplicit-retain-self]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Team/NIMTeamMemberCardViewController.m:184:18: warning: block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior [-Wimplicit-retain-self]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Team/NIMTeamMemberCardViewController.m:200:17: warning: block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior [-Wimplicit-retain-self]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Team/NIMTeamMemberCardViewController.m:201:18: warning: block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior [-Wimplicit-retain-self]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Team/NIMTeamMemberCardViewController.m:218:25: warning: block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior [-Wimplicit-retain-self]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Team/NIMTeamMemberCardViewController.m:219:26: warning: block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior [-Wimplicit-retain-self]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Team/NIMTeamMemberCardViewController.m:237:29: warning: block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior [-Wimplicit-retain-self]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Team/NIMTeamMemberCardViewController.m:238:30: warning: block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior [-Wimplicit-retain-self]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Session/Object/NIMSessionMsgDatasource.m:82:100: warning: block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior [-Wimplicit-retain-self]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Session/Object/NIMSessionMsgDatasource.m:124:71: warning: incompatible pointer types sending 'NIMMessage *' to parameter of type 'NSString * _Nonnull' [-Wincompatible-pointer-types]
- NOTE | xcodebuild: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSString.h:147:37: note: passing argument to parameter 'aString' here
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Session/Object/NIMSessionMsgDatasource.m:151:104: warning: block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior [-Wimplicit-retain-self]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Session/Object/NIMSessionMsgDatasource.m:293:19: warning: unused variable 'index' [-Wunused-variable]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Session/Object/NIMSessionMsgDatasource.m:308:100: warning: block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior [-Wimplicit-retain-self]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Session/Object/NIMSessionMsgDatasource.m:347:15: warning: unused variable 'index' [-Wunused-variable]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Session/Object/NIMSessionMsgDatasource.m:370:96: warning: block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior [-Wimplicit-retain-self]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Session/Object/NIMSessionInteractorImpl.m:373:46: warning: undeclared selector 'sendImageMessage:' [-Wundeclared-selector]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Session/Object/NIMSessionInteractorImpl.m:375:46: warning: undeclared selector 'sendImageMessage:' [-Wundeclared-selector]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Session/Object/NIMSessionInteractorImpl.m:396:46: warning: undeclared selector 'sendImageMessage:' [-Wundeclared-selector]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Session/Object/NIMSessionInteractorImpl.m:398:46: warning: undeclared selector 'sendImageMessage:' [-Wundeclared-selector]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Session/Object/NIMSessionInteractorImpl.m:381:33: warning: unused variable 'message' [-Wunused-variable]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Session/Object/NIMSessionInteractorImpl.m:365:25: warning: unused variable 'weakSelf' [-Wunused-variable]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Session/Object/NIMSessionInteractorImpl.m:424:38: warning: undeclared selector 'sendImageMessage:' [-Wundeclared-selector]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Session/Object/NIMSessionInteractorImpl.m:427:38: warning: undeclared selector 'sendImageMessage:' [-Wundeclared-selector]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Session/Object/NIMSessionInteractorImpl.m:421:21: warning: unused variable 'message' [-Wunused-variable]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Session/Object/NIMSessionInteractorImpl.m:419:25: warning: unused variable 'weakSelf' [-Wunused-variable]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Session/View/SessionContentView/NIMSessionFileTransContentView.m:71:63: warning: format specifies type 'ssize_t' (aka 'long') but the argument has type 'long long' [-Wformat]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Common/NIMKitMediaFetcher.m:95:41: warning: block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior [-Wimplicit-retain-self]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Session/Object/NIMKitAudioCenter.m:65:13: warning: code will never be executed [-Wunreachable-code]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Input/NIMInputView.m:313:18: warning: block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior [-Wimplicit-retain-self]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Contact/NIMContactSelectViewController.m:140:13: warning: block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior [-Wimplicit-retain-self]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Contact/NIMContactSelectViewController.m:141:14: warning: block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior [-Wimplicit-retain-self]
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/Classes/Sections/Team/NIMAdvancedTeamCardViewController.m:1096:1: warning: implementing deprecated method [-Wdeprecated-implementations]
- NOTE | xcodebuild: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIViewController.h:316:1: note: method 'didRotateFromInterfaceOrientation:' declared here
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/NIMSDK/NIMSDK.framework/Headers/NIMChatManagerProtocol.h:200:12: warning: parameter 'NIMMessage' not found in the function declaration [-Wdocumentation]
- NOTE | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/NIMSDK/NIMSDK.framework/Headers/NIMChatManagerProtocol.h:200:12: note: did you mean 'messages'?
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/NIMSDK/NIMSDK.framework/Headers/NIMChatManagerProtocol.h:210:12: warning: parameter 'NIMMessage' not found in the function declaration [-Wdocumentation]
- NOTE | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/NIMSDK/NIMSDK.framework/Headers/NIMChatManagerProtocol.h:210:12: note: did you mean 'message'?
- WARN | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/NIMSDK/NIMSDK.framework/Headers/NIMConversationManagerProtocol.h:263:12: warning: parameter 'session' not found in the function declaration [-Wdocumentation]
- NOTE | xcodebuild: /Users/wangjiji/Desktop/podLibs/TDNIMKit/TDNIMKit/NIMSDK/NIMSDK.framework/Headers/NIMConversationManagerProtocol.h:263:12: note: did you mean 'notify'?
- NOTE | [iOS] xcodebuild: ld: warning: instance method 'nim_drawImageWithSize:' in category from /Users/wangjiji/Library/Developer/Xcode/DerivedData/App-gjkqwvanivaxhccdvgxqguipgjmq/Build/Intermediates.noindex/Pods.build/Release-iphonesimulator/TDNIMKit.build/Objects-normal/x86_64/UIImage+NIMKit.o conflicts with same method from another category
- NOTE | [iOS] xcodebuild: ld: warning: instance method 'nim_drawImageWithSize:' in category from /Users/wangjiji/Library/Developer/Xcode/DerivedData/App-gjkqwvanivaxhccdvgxqguipgjmq/Build/Intermediates.noindex/Pods.build/Release-iphonesimulator/TDNIMKit.build/Objects-normal/i386/UIImage+NIMKit.o conflicts with same method from another category
- ERROR | xcodebuild: /Users/wangjiji/Library/Developer/Xcode/DerivedData/App-gjkqwvanivaxhccdvgxqguipgjmq/Build/Products/Release-iphonesimulator/TDNIMKit/TDNIMKit.framework/Headers/NIMKitDependency.h:22:9: error: include of non-modular header inside framework module 'TDNIMKit.NIMKitDependency': '/Users/wangjiji/Library/Developer/Xcode/DerivedData/App-gjkqwvanivaxhccdvgxqguipgjmq/Build/Products/Release-iphonesimulator/SDWebImage/SDWebImage.framework/Headers/SDWebImageCompat.h' [-Werror,-Wnon-modular-include-in-framework-module]
- ERROR | xcodebuild: /Users/wangjiji/Library/Developer/Xcode/DerivedData/App-gjkqwvanivaxhccdvgxqguipgjmq/Build/Products/Release-iphonesimulator/TDNIMKit/TDNIMKit.framework/Headers/NIMKitDependency.h:29:9: error: include of non-modular header inside framework module 'TDNIMKit.NIMKitDependency': '/Users/wangjiji/Library/Developer/Xcode/DerivedData/App-gjkqwvanivaxhccdvgxqguipgjmq/Build/Products/Release-iphonesimulator/SDWebImage/SDWebImage.framework/Headers/SDWebImageManager.h' [-Werror,-Wnon-modular-include-in-framework-module]
- ERROR | xcodebuild: /Users/wangjiji/Library/Developer/Xcode/DerivedData/App-gjkqwvanivaxhccdvgxqguipgjmq/Build/Products/Release-iphonesimulator/TDNIMKit/TDNIMKit.framework/Headers/NIMKitDependency.h:30:9: error: include of non-modular header inside framework module 'TDNIMKit.NIMKitDependency': '/Users/wangjiji/Library/Developer/Xcode/DerivedData/App-gjkqwvanivaxhccdvgxqguipgjmq/Build/Products/Release-iphonesimulator/SDWebImage/SDWebImage.framework/Headers/UIView+WebCacheOperation.h' [-Werror,-Wnon-modular-include-in-framework-module]
- ERROR | xcodebuild: /Users/wangjiji/Library/Developer/Xcode/DerivedData/App-gjkqwvanivaxhccdvgxqguipgjmq/Build/Products/Release-iphonesimulator/TDNIMKit/TDNIMKit.framework/Headers/NIMKitDependency.h:31:9: error: include of non-modular header inside framework module 'TDNIMKit.NIMKitDependency': '/Users/wangjiji/Library/Developer/Xcode/DerivedData/App-gjkqwvanivaxhccdvgxqguipgjmq/Build/Products/Release-iphonesimulator/SDWebImage/SDWebImage.framework/Headers/UIView+WebCache.h' [-Werror,-Wnon-modular-include-in-framework-module]
- ERROR | xcodebuild: /Users/wangjiji/Library/Developer/Xcode/DerivedData/App-gjkqwvanivaxhccdvgxqguipgjmq/Build/Products/Release-iphonesimulator/TDNIMKit/TDNIMKit.framework/Headers/NIMKitDependency.h:38:9: error: include of non-modular header inside framework module 'TDNIMKit.NIMKitDependency': '/Users/wangjiji/Library/Developer/Xcode/DerivedData/App-gjkqwvanivaxhccdvgxqguipgjmq/Build/Products/Release-iphonesimulator/Toast/Toast.framework/Headers/UIView+Toast.h' [-Werror,-Wnon-modular-include-in-framework-module]
- ERROR | xcodebuild: /Users/wangjiji/Library/Developer/Xcode/DerivedData/App-gjkqwvanivaxhccdvgxqguipgjmq/Build/Products/Release-iphonesimulator/TDNIMKit/TDNIMKit.framework/Headers/NIMKitKeyboardInfo.h:11:1: error: duplicate interface definition for class 'NIMKitKeyboardInfo'
- NOTE | xcodebuild: /Users/wangjiji/Library/Developer/Xcode/DerivedData/App-gjkqwvanivaxhccdvgxqguipgjmq/Build/Products/Release-iphonesimulator/TDNIMKit/TDNIMKit.framework/Headers/NIMKitKeyboard.h:11:12: note: previous definition is here
- ERROR | xcodebuild: /Users/wangjiji/Library/Developer/Xcode/DerivedData/App-gjkqwvanivaxhccdvgxqguipgjmq/Build/Products/Release-iphonesimulator/TDNIMKit/TDNIMKit.framework/Headers/NIMKitKeyboardInfo.h:14:47: error: property has a previous declaration
- NOTE | xcodebuild: /Users/wangjiji/Library/Developer/Xcode/DerivedData/App-gjkqwvanivaxhccdvgxqguipgjmq/Build/Products/Release-iphonesimulator/TDNIMKit/TDNIMKit.framework/Headers/NIMKitKeyboard.h:14:47: note: property declared here
- ERROR | xcodebuild: /Users/wangjiji/Library/Developer/Xcode/DerivedData/App-gjkqwvanivaxhccdvgxqguipgjmq/Build/Products/Release-iphonesimulator/TDNIMKit/TDNIMKit.framework/Headers/NIMKitKeyboardInfo.h:17:47: error: property has a previous declaration
- NOTE | xcodebuild: /Users/wangjiji/Library/Developer/Xcode/DerivedData/App-gjkqwvanivaxhccdvgxqguipgjmq/Build/Products/Release-iphonesimulator/TDNIMKit/TDNIMKit.framework/Headers/NIMKitKeyboard.h:17:47: note: property declared here
- NOTE | xcodebuild: /var/folders/sj/46yckf194p37wvdhmfh0j2_m0000gn/T/CocoaPods-Lint-20191119-1941-1d76rqs-TDNIMKit/App/main.m:3:9: fatal error: could not build module 'TDNIMKit'
- NOTE | [iOS] xcodebuild: warning: Skipping code signing because the target does not have an Info.plist file and one is not being generated automatically. (in target 'App' from project 'App')
[!] TDNIMKit did not pass validation, due to 9 errors and 36 warnings.
You can use the `--no-clean` option to inspect any issue.
卧槽,无情
咋肥事??错误更多了!我配置好证书,build工程居然是可以的。那就是我验证文件的姿势有问题!原来是我们依赖了.a文件,不影响使用但是验证需要指明。验证时候需要
--use-libraries
,并且忽略警告pod lib lint --use-libraries --allow-warnings
嘿嘿嘿,
TDNIMKit passed validation.
这次果然ok了。这只是说明我们本地的podspec是校验通过了的,还需要验证远程podsepec校验。
- 将修改好的模板工程上传到github托管
- 先创建空仓库
*然后代码提交到仓库
echo "# TDNIMKit" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:strivever/TDNIMKit.git
git push -u origin master
-
打上tag,需要跟podspec文件中指定的tag一致 默认这里没有问题。将podsepec中的 source填入仓库地址
上传到仓库记得看一下远程仓库资源是否被同步上去了,不然一会校验会出现资源匹配不到。 -
远程仓库验证
pod spec lint --use-libraries --allow-warnings
验证可能很漫长,可以增加 --verbose查看日志
居然有报错RPC failed; curl 18 transfer closed with outstanding read data remaining
solution.1 将source换成ssh地址试一下
solution.2 git config http.postBuffer 524288000
然后校验通过了 GOOD!
4. 发布私有库,关联到 TDNIMKitSpec文件
pod repo push TDNIMKitSpec TDNIMKit.podspec --use-libraries --allow-warnings --verbose
推送成功
pod命令 pod repo push 【本地spec文件夹名称】【需要发布的.podspec文件】--use-libraries --allow-warnings --verbose
发生错误:
$ /usr/local/bin/git -C /Users/wangjiji/.cocoapods/repos/TDNIMKitSpec pull
Your configuration specifies to merge with the ref 'refs/heads/master'
from the remote, but no such ref was fetched.
[!] /usr/local/bin/git -C /Users/wangjiji/.cocoapods/repos/TDNIMKitSpec pull
Your configuration specifies to merge with the ref 'refs/heads/master'
from the remote, but no such ref was fetched.
solution:因为我们的spec索引库为空的,是不允许我们提交的,此时添加
README.md
文件,并提交到仓库。也可以创建索引库时候勾上自动创建README.md
文件
touch README.md
git add README.md
git commit -m 'first commit'
git push origin master
然后再回到模板工程推一遍即可,此时成功啦!
发布私有库成功
查看一下本地和远程应该都有了podspec
5.测试一下
打开一个cocoapods管理的项目,添加该私有库
source 'https://github.com/CocoaPods/Specs.git'
source 'git@github.com:strivever/TDNIMKitSpec.git'
platform :ios,'8.0'
workspace 'BOOK'
abstract_target 'CommonPods' do
pod 'YYKit', '~> 1.0.9'
pod 'TDNIMKit', '0.1.0'
target 'GCYSColledge' do
project 'GCYSColledge/GCYSColledge.xcodeproj'
end
target 'BOOK' do
project 'BOOK.xcodeproj'
end
end
跟其它三方没啥区别,只是需要指定私有Spec源,pod install --repo-update --verbose
等待安装:
StriVever@StrivEver ~ ±master⚡ » cd /Users/wangjiji/Desktop/BOOK 1 ↵
StriVever@StrivEver ~/Desktop/BOOK ±master⚡ » pod install --repo-update --verbose
Preparing
Updating local specs repositories
CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local
because checking is only perfomed in repo update
Updating spec repo `master`
$ /usr/local/bin/git -C /Users/wangjiji/.cocoapods/repos/master fetch origin
--progress
6.我们发现pod install 私有库之后,所有的源码文件全部在一个文件夹里。如果需要文件夹嵌套需要使用 subspec方式实现子文件夹嵌套:效果如下图:
文件夹嵌套如下这种形式,注意当子文件夹里需要依赖其他文件夹,需要指明 dependency 不然会报错,找不到.h文件。这个路径也是相对路径,路径到依赖文件所在文件夹即可,说明你需要依赖其中一个子模块。我的理解subspec其实是独立功能的子模块,不是单单为了放入文件夹中管理,这些子模块也可以被独立集成进项目中,所以需要指明依赖
cacheHelper.dependency 'TDNetworkKit/TDNetworkConfiguration'
s.subspec 'TDCacheHelper'do |cacheHelper|
cacheHelper.source_files = 'TDNetworkKit/Classes/TDCacheHelper/*.{h,m}'
cacheHelper.public_header_files = "TDNetworkKit/Classes/TDCacheHelper/*.h"
cacheHelper.dependency 'TDNetworkKit/TDNetworkConfiguration'
end
7.编辑我们的README.md小尾巴
如下图: README小尾巴对应代码,#代表跳转链接,这个链接只能是该仓库内部链接,我没有写
# TDNetworkKit
[![CI Status](https://img.shields.io/badge/build-pass-orange.svg)](#)
[![Version](https://img.shields.io/badge/Version-0.1.0-blue.svg)](#)
[![License](https://img.shields.io/badge/License-MIT-yellow.svg)](#)
[![Platform](https://img.shields.io/badge/Platform-iOS8.0-red.svg)](#)
图标文字和颜色格式都是可以设置的:
https://img.shields.io/badge/build-pass-orange.svg
https://img.shields.io/badge/【前半部分文字】-【后半部分文字】-【颜色,英文,16进制都行】.svg
网友评论