pod repo #查看本地索引库
pod repo add 索引库名称 索引库地址 #添加本地索引库
pod repo remove 索引库名称 #删除本地索引库
创建组件库及上传
pod lib create xxx(组件名) 例:pod lib create XNetwork
cd ../XNetwork #XNetwork.podspec上一级目录
git init (文件里已git 不需要)
git add . (添加改变的文件)
git commit -m "提交描述"
git branch -M master
git remote add origin 远程私有库SSH地址
git push --set-upstream origin master 或者 git push -u origin master
git tag '0.1.0'
git push --tags
#验证代码的正确性:
#pod lib lint 用于验证本地的代码
#pod spec lint 对本地和远程代码都验证
#<组件名>.podspec 如果在项目根目录下执行不需要添加此参数
#--verbose 显示详细错误原因
#--use-libraries 使用静态库或者是framework
#--allow-warnings 允许警告存在
#--skip-import-validation 跳过验证,这个是解上面问题的关键
#cd到项目根目录下
pod lib lint --use-libraries --allow-warnings
pod spec lint --use-libraries --allow-warnings
# pod trunk register 邮箱 '用户名' --description='描述'
pod trunk register 邮箱名 '描述'
pod trunk me #此时可以看到已注册信息
pod trunk push --use-libraries --allow-warnings 或者
arch -x86_64 pod trunk push xxx.podspec --allow-warnings
pod repo update
pod search xxx
项目引用
pod 库名, :git => '库地址'
三.组件化里swift和OC的相互使用
1.swift使用oc
在.podspec文件中必须有s.source_files = '库名/Classes/**/*'
在.podspec文件中加入s.public_header_files = '库名/Classes/public_header.h'
Pods组件库Classes目录下创建一个文件夹 xxx(可以直接在class文件夹下),在文件夹中新建一个xxx.modulemap文件,并把文件内容设置成
module xxx [system] {
header "xxxxx.h"
export*
}
执行一下pod install,就能在swift文件里使用OC了
2.oc中使用swift写法 需要使用的swift要公开出来
@objc public class xxx(类名) :xxx(继承的父类){
@objc public class xxx(方法名)(){
} #类方法
@objc public xxx(方法名)(){
} #对象方法
}
在oc需要使用的类中引用 #import <xxx(自己创建的库名)/xxx(自己创建的库名)-Swift.h>
四.其他问题
error build: In /Users/xuliangkun/Desktop/TestLib/TestLib/Classes/SocketTools/Snappy/libSnappyLib.a(snappy-stubs-internal.o), building for iOS Simulator, but linking in object file built for iOS, file '/Users/xuliangkun/Desktop/TestLib/TestLib/Classes/SocketTools/Snappy/libSnappyLib.a' for architecture arm64
具体解决办法:
在主项目和pod项目的PROJECT的Build Settings中,搜索Excluded Architecture ,添加 Any iOS Simulator SDK,value填入 arm64
s.name = "LivePods" #工程的名字
s.version = "0.0.1" #工程的版本
s.summary = "Live Pods's summary" #工程的摘要
s.description = "Live Pods's description" #工程的描述
s.homepage = "https://github.com/jifengs/LivePods" #工程的首页
s.license = "MIT" #工程的证书
s.author = { "xxx" => "xxx@126.com" } #工程的作者
s.ios.deployment_target = "10.0" #工程的编译版本
s.source = { :git => "https://github.com/jifengs/LivePods.git", :tag => "#{s.version}" } #工程的git地址
s.source_files = "Classes", "Classes/**/*.{h,m}" #工程需要引入的文件
s.exclude_files = "Classes/Exclude" #工程不需要引入的文件
s.public_header_files = "Classes/**/*.h" #工程需要暴露出来的头文件
s.resources = "Resources/*" #工程需要引入的资源文件(图片,xib等)
s.resource_bundles = {'Resources' => 'XXX.framework/Resources/XXX.bundle'} #工程需要引入的bundle
s.frameworks = "ImageIO" #工程依赖的framework
s.vendored_frameworks = [] #工程依赖的第三方framework
s.libraries = "iconv", "xml2" #工程依赖的library
s.vendored_libraries = [] #工程依赖第三方的library
s.requires_arc = true #工程是否用arc规则
rm ~/Library/Caches/CocoaPods/search_index.json
网友评论