![](https://img.haomeiwen.com/i2449169/c93e5db58043ff4d.jpg)
思路:
把模块代码放到一个文件夹下,创建YJHomeKit.podspec文件
用pod的命令创建podspec文件,pod spec create YJHomeKit
会生成一个YJHomeKit.podspec文件我们只需要简单修改下相应的信息即可。
Pod::Spec.new do |s|
s.name = "YJHomeKit"
s.version = "0.0.3"
s.summary = "YJHomeKit 自己用的"
s.description = "用CocoaPods做iOS程序的依赖管理,测试"
#s.description = <<-DESC
#用CocoaPods做iOS程序的依赖管理,测试
#DESC
s.homepage = "https://github.com/qq756585379/YJHomeKit"
s.screenshots = "http://media.yangjunv5.top/wexin_receive.jpg", "http://media.yangjunv5.top/wexin_receive2.png"
# s.license = "MIT (example)"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "杨俊" => "756585379@qq.com" }
# Or just: s.author = "杨俊"
# s.authors = { "杨俊" => "756585379@qq.com" }
# s.social_media_url = "http://twitter.com/杨俊"
s.platform = :ios, "9.0"
# When using multiple platforms
s.ios.deployment_target = "9.0"
# s.osx.deployment_target = "10.7"
# s.watchos.deployment_target = "2.0"
# s.tvos.deployment_target = "9.0"
s.source = { :git => "https://github.com/qq756585379/YJHomeKit.git", :tag => "#{s.version}" }
# s.exclude_files = "Classes/Exclude"
s.public_header_files = 'YJHomeKit/*.{h}' , 'YJHomeKit/**/*.{h}'
s.source_files = 'YJHomeKit/*.{h,m}' , 'YJHomeKit/**/*.{h,m}'
s.resource = "YJHomeKit/**/*.bundle"
# s.subspec 'Core' do |ss|
# ss.source_files = 'YJHomeKit/Core/*.{h,m}'
# ss.public_header_files = 'YJHomeKit/Core/*.h'
# end
# s.subspec 'UIKit' do |ss|
# ss.ios.deployment_target = '9.0'
# ss.dependency 'YJHomeKit/Core'
# ss.source_files = 'YJHomeKit/UIKit/*.{h,m}'
# ss.public_header_files = 'YJHomeKit/UIKit/*.h'
# end
# s.subspec 'Category' do |ss|
# ss.ios.deployment_target = '9.0'
# ss.source_files = 'Category/**/*.{h,m}'
# ss.public_header_files = 'Category/**/*.h'
# # ss.subspec 'UIView' do |sss|
# # sss.source_files = 'YJHomeKit/Category/**/*.{h,m}'
# # sss.public_header_files = 'YJHomeKit/Category/**/*.h'
# # end
# end
# s.resource = "icon.png"
# s.resources = "Resources/*.png"
# s.preserve_paths = "FilesToSave", "MoreFilesToSave"
# s.framework = "UIKit"
s.frameworks = "UIKit", "Foundation"
# s.library = "iconv"
# s.libraries = "iconv", "xml2"
s.requires_arc = true
# s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
s.dependency "Masonry"
s.dependency "PureLayout"
s.dependency "ReactiveObjC"
s.dependency "MBProgressHUD"
end
然后,在你的项目工程的Podfile里添加相对路径
platform :ios, '9.0'
# 对于我们使用cocoapod引入的第三方,我们可以在podfile文件中 增加一句 inhibit_all_warnings! 来要pod的工程不显示任何警告
inhibit_all_warnings!
target 'Example' do
use_frameworks!
# 本地引入
pod 'YJHomeKit', :path=> '../'
#如果发布到CocoaPods直接这么引入
# pod 'YJHomeKit'
# 提示组件框架
pod 'SVProgressHUD'
pod 'MBProgressHUD'
# 自动布局
pod 'Masonry'
pod 'PureLayout'
# 响应函数式框架
pod 'ReactiveObjC'
# 网络请求框架
pod 'YTKNetwork'
end
就这样,很简单吧,多个模块可以都这么引入。
下面是小米米家CocoaPods工程化截图,仅供参考,如有侵权,请联系我删除。
![](https://img.haomeiwen.com/i2449169/e690ddde4d070393.png)
网友评论