美文网首页iOS Development
创建私有Private Pods 笔记

创建私有Private Pods 笔记

作者: Larry萝卜 | 来源:发表于2018-02-28 23:08 被阅读12次

创建私有Private Pods 笔记

  1. 创建私有 spec repo:
    pod add repo ‘MySpecs’ ‘specs repo url’

  2. 创建私有库,并创建 pod 同名 .spec 文件
    执行 pod lib lint 本地验证,pod spec lint 远程验证

  3. 添加私有库到私有 specs
    pod repo push MySpecs 私有库.podspec
    Eg: pod repo push Specs BTCacheKit.podspec

  4. 私有库依赖私有库
    在 podfile 顶部添加 source
    source ‘MySpecs url link’
    source 'https://github.com/CocoaPods/Specs.git'
    之后 podfile 以及 s.dependency 中都是正常引用就可以

  5. 校验当前私有库;本地校验执行的 pod lib lint 需要添加sources 如:pod lib lint —sources=‘MySpecs url link’如果,sources 是多个,中间用逗号隔开即可;出现警告:--allow-warnings 进行排除;(pod lib lint --sources="私有库链接,https://github.com/CocoaPods/Specs.git")

  6. 远程校验 pod spec lint --allow-warnings

出现警告

[!] The repo Specs at ../../../../../.cocoapods/repos/Specs is not clean

cd ../../../../../.cocoapods/repos/Specs
git clean -f

问题:

pod repo中明明存在的podspec 却search 不到

指定--sources: pod lib lint --sources="自己私有的pod,https://github.com/CocoaPods/Specs.git"

私有库中添加图片/音频资源

第一种

spec.resources = ["Images/.png", "Sounds/"]

但是这些资源会在打包的时候直接拷贝的app的Bundle中,这样说不定会和其它资源产生命名冲突

第二种

spec.resource = "Resources/MYLibrary.bundle"

把资源都放在bundle中,然后打包时候这个bundle会直接拷贝进app的mainBundle中。使用的时候在mainBundle中查找这个bundle然后再搜索具体资源

NSURL *bundleURL = [[NSBundle mainBundle] URLForResource:@"JZShare" withExtension:@"bundle"]; NSBundle *bundle = [NSBundle bundleWithURL:bundleURL]; UIImage *img = [UIImage imageNamed:icon inBundle:bundle compatibleWithTraitCollection:nil];

第三种

spec.resource_bundles = {
'MyLibrary' => ['Resources/.png'],
'OtherResources' => ['OtherResources/
.png']
}

这种方法利用 framework 的命名空间,有效防止了资源冲突。
使用方法是先拿到最外面的 bundle,然后再去找下面指定名字 的 bundle 对象,再搜索具体资源

NSBundle *bundle = [NSBundle bundleForClass:[MYSomeClass class]]; NSURL *bundleURL = [bundle URLForResource:@"MyLibrary" withExtension:@"bundle"]; NSBundle *resourceBundle = [NSBundle bundleWithURL: bundleURL]; UIImage *img = [UIImage imageNamed:icon inBundle:bundle compatibleWithTraitCollection:nil];

问题:include of non-modular header inside framework module”

spec.user_target_xcconfig = { 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES' }

拉取远程的分支:
git remote add origin xxxxx
出现冲突的话
git pull origin master --allow-unrelated-histories

官方文档
https://guides.cocoapods.org/making/private-cocoapods.html
https://guides.cocoapods.org/syntax/podspec.html

相关文章

  • 创建私有Private Pods 笔记

    创建私有Private Pods 笔记 创建私有 spec repo:pod add repo ‘MySpecs’...

  • cocoaPods私有库的创建与使用

    一,创建私有pods 创建私有Spec Repo(也就是所有私有pod的仓库) spec repo 是pods的一...

  • 创建Private Pods记录

    在GitHub上创建一个私有仓库(不一定是GitHub的仓库) 打开终端,切换到准备生成项目的目录,执行 打开终端...

  • 创建私有pods

    1.创建一个spec repo,作为私有化Spec Repo的远端地址什么是Spec Repo?它是所有的Pods...

  • 创建私有Pods

    在平常iOS项目中,都会使用CocoaPods来对第三方库进行导入和管理,比如AFNetworking、MJRfr...

  • [Cocoapods] 如何发布一个私有Pod

    发布私有CocoaPod Spec 创建private pod主要步骤 创建私有Spec Repo 1、创建git...

  • 进阶-私有库创建

    4.私有库创建 创建私有 Spec Repo Spec Repo介绍 Spec Repo是所有的Pods的一个索引...

  • ios 创建私有库pod,codspec

    创建pod模版项目 使用pod命令创建私有库模板项目pod lib create 私有库名,如创建一个名为Pods...

  • CocoaPod 制作私有库(Private Pods)

    前言 官网关于这个知识点已有详细的介绍,但是对我来说:1.知识点比较凌乱 2.英文描述,很多时候不能很好理解其含义...

  • 创建私有Pods库

    首先找一个可以创建私有仓库的平台,比如coding.net 首先创建一个远程索引仓库 创建好后添加到本地 可以在本...

网友评论

    本文标题:创建私有Private Pods 笔记

    本文链接:https://www.haomeiwen.com/subject/wkbixftx.html