博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
cocoaPods打包的静态库
阅读量:4542 次
发布时间:2019-06-08

本文共 5770 字,大约阅读时间需要 19 分钟。

cocoaPods管理自己的静态库供其它人下载使用(直接使用上一篇用cocoaPod打包的静态库)

(1) 创建github仓库

(2) 下载仓库到本地

(3) 将打包好的framework放到项目中

(4) 终端提交到github上

git add .git commit -m “install”git push origin master

(5) 打标签, 并提交到github上

git tag 1.0.0git push origin 1.0.0

二 (1) 在工程根目录初始化一个Podspec文件, 最好与项目同名

(2) 配置文件

## Be sure to run `pod spec lint XCLogLib.podspec' to ensure this is a# valid spec and to remove all comments including this before submitting the spec.## To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/#Pod::Spec.new do |s|# ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ### These will help people to find your library, and whilst it# can feel like a chore to fill in it's definitely to your advantage. The# summary should be tweet-length, and the description more in depth.#s.name = "XCLogLib"s.version = "1.0.0"s.summary = " XCLogLib test demo"# 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 = <<-DESCA Test XCLogLib Demo. where you can put your description.DESCs.homepage = "https://github.com/xiaocai33/XCLogLib"# s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"# ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ### Licensing your code is important. See http://choosealicense.com for more info.# CocoaPods will detect a license file if there is a named LICENSE*# Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.##s.license = "MIT (example)"s.license = { :type => "MIT"}# ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ### Specify the authors of the library, with email addresses. Email addresses# of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also# accepts just a name if you'd rather not provide an email address.## Specify a social_media_url where others can refer to, for example a twitter# profile URL.#s.author = { "Cai Tengyuan" => "tycai1@baidu.com" }# Or just: s.author = "Cai Tengyuan"# ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― ### If this Pod runs only on iOS or OS X, then specify the platform and# the deployment target. You can optionally include the target after the platform.## s.platform = :ioss.platform = :ios, "8.0"# When using multiple platforms# s.ios.deployment_target = "5.0"# s.osx.deployment_target = "10.7"# s.watchos.deployment_target = "2.0"# s.tvos.deployment_target = "9.0"# ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ### Specify the location from where the source should be retrieved.# Supports git, hg, bzr, svn and HTTP.#s.source = { :git => "https://github.com/xiaocai33/XCLogLib.git", :tag => "#{s.version}" }# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ### CocoaPods is smart about how it includes source code. For source files# giving a folder will include any swift, h, m, mm, c & cpp files.# For header files it will include any header in the folder.# Not including the public_header_files will make all headers public.#s.source_files = "XCLogLib", "XCLogLib/**/*.{h}"#s.exclude_files = "Classes/Exclude"s.vendored_libraries = "*/libXCLogStaticDemo.a"# framework is#s.vendored_frameworks = '*/XCLogStaticDemo.framework'# s.public_header_files = "Classes/**/*.h"# ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ### A list of resources included with the Pod. These are copied into the# target bundle with a build phase script. Anything else will be cleaned.# You can preserve files from being cleaned, please don't preserve# non-essential files like tests, examples and documentation.## s.resource = "icon.png"# s.resources = "Resources/*.png"# s.preserve_paths = "FilesToSave", "MoreFilesToSave"# ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ### Link your library with frameworks, or libraries. Libraries do not include# the lib prefix of their name.## s.framework = "SomeFramework"# s.frameworks = "SomeFramework", "AnotherFramework"# s.library = "iconv"# s.libraries = "iconv", "xml2"# ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ### If your library depends on compiler flags you can set them in the xcconfig hash# where they will only apply to your library. If you depend on other Podspecs# you can include multiple dependencies to ensure it works.s.requires_arc = true# s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }# s.dependency "JSONKit", "~> 1.4"end

(3) 创建账号(如果已经创建过, 省略)

pod trunk register 邮箱 联系人 --description="描述" --verbose

创建成功会收到邮件,进邮箱验证

pod trunk me 可查看trunk信息

(4) trunk push之前要先验证

pod spec lint XCLogLib.podspec

出现 XCLogLib.podspec passed validation表示通过了

如果只是waring通过

pod lib lint --allow-warnings #强制忽略

如何 想看错误详情

pod spec lint XCLogLib.podspec --verbose

如果有错, 看下配置文件哪里错了.

(5) pod trunk push 这个有点耐心, 需要会时间

(6) 成功后pod search XCLogLib

如果搜索不到, 请看上篇博客介绍.

(7) 在其它项目的 Podfile 中引用:

platform :ios, ‘8.0' 注意版本要大于静态库支持的最低版本pod ‘XCLogLib'或者 pod ‘XCLogLib’, '~> 1.0.0’

这样就可以在demo中引用头文件

#import “XCLog.h”

然后调用静态库的方法了.

如果是framework的框架, 则需要将配置文件的

s.vendored_libraries = “*/libXCLogStaticDemo.a"

改为 (注意路径)

s.vendored_frameworks = ‘*/XCLogStaticDemo.framework'

即可, 这里不再演示

三 xcode项目支持pod

终端: 

cd path #到项目目录pod init fileName.Podfile #创建 Podfile 文件

打开文件在其中添加需要依赖的库
例:

pod ‘XCLogLib’

例子:

转载于:https://www.cnblogs.com/xiaocai-ios/p/7852645.html

你可能感兴趣的文章
.net微信公众号开发——消息与事件
查看>>
如何处理高并发情况下的DB插入
查看>>
[Lua快速了解一下]Lua的model
查看>>
C#操作剪贴板实现复制粘贴
查看>>
模糊查询和聚合函数
查看>>
Beaglebone Black教程使用SSH通过USB和因特网连接Beaglebone Black
查看>>
centos 自带mysql卸载时出现无法卸载情况
查看>>
交通工具(并查集)
查看>>
Java里的集合:List/Set/Map
查看>>
linux内核情景分析之exit与Wait
查看>>
mybatis2入门程序
查看>>
解决html设置height:100%无效的问题
查看>>
ECMAScript 5 中的数组方法
查看>>
SpringBoot整合StringData JPA
查看>>
tensorflow conv2d
查看>>
课堂练习
查看>>
如何使VS2008 调试网站的根目录和IIS调试的一致?
查看>>
Apple 企业开发者账号&邓白氏码申请记录
查看>>
[bzoj5457]城市_dsu on tree
查看>>
[计蒜客T2237]魔法_树
查看>>