mysql组件化_组件化管理

通过cocopods来管理我们自己的组件,把开发好的组件上传到github,然后通过cocopods导入到我们的项目,类似其他的第三方库一样。

一、pod组件管理的灵魂:podspec文件

#

# Be sure to run `pod lib lint dbMule.podspec' to ensure this is a

# valid spec before submitting.

#

# Any lines starting with a # are optional, but their use is encouraged

# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html

#

Pod::Spec.new do |s|

s.name = 'dbMule'

s.version = '0.1.4'

s.summary = 'A short description of dbMule.'

# 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 = <

TODO: Add long description of the pod here.

DESC

s.homepage = 'https://github.com/wulang150/dbMule'

# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'

s.license = { :type => 'MIT', :file => 'LICENSE' }

s.author = { 'wulang150' => '475750165@qq.com' }

s.source = { :git => 'https://github.com/wulang150/dbMule.git', :tag => s.version.to_s }

# s.social_media_url = 'https://twitter.com/'

s.ios.deployment_target = '8.0'

s.source_files = 'dbMule/Classes/*'

# s.resource_bundles = {

# 'dbMule' => ['dbMule/Assets/*.png']

# }

# s.public_header_files = 'Pod/Classes/**/*.h'

# s.frameworks = 'UIKit', 'MapKit'

# s.dependency 'AFNetworking', '~> 2.3'

end

主要参数意思:

s.name = 'dbMule'

pod导入后,生成的组件的名字

s.source_files = 'dbMule/Classes/*'

其他项目pod导入这个组件后,只需要的文件。一般都是组件代码和测试项目代码一起提交到github的,别人要用我们库的时候,不可能把测试的工程也导过去。这个就是控制导入的文件。

s.source = { :git => 'https://github.com/wulang150/dbMule.git', :tag => s.version.to_s }

podspec和组件文件不需要在同一个地方,有podspec文件就可以了,它会在s.source路径下找到对应组件文件。所以你也可以这个podspec放到其他的git空间进行统一的管理:

执行: pod repo push 私有索引库名称 spec名称.podspec

pod repo push ZYHModule XXModule.podspec --allow-warnings

s.private_header_files = "#{mydir}*/.{h,hpp}"

私有头文件,不公开出来,别人看不到

s.resource = "#{mydir}/.plist","#{mydir}Resources/.lproj"

资源文件,导入后,统一在Resources文件夹中

s.frameworks = 'OpenAL', 'MobileCoreServices'

依赖的frameworks

s.libraries = 'bz2.1.0', 'bz2'

依赖的系统库

s.dependency 'ZXMQTT'

依赖其他组件

s.vendored_libraries = "#{mydir}AKVideoPlayer/AVBaseMedia/AVMedia/libAVBaseMedia.a"

一些组件使用的静态库

s.pod_target_xcconfig = {

'HEADER_SEARCH_PATHS' => "

math?formula=%7BPODS_ROOT%7D%2F..%2FBCMain%2Flibs%2Fbasestationlibs%2FOpenLib{PODS_ROOT}/../BCMain/libs/basestationlibs/home_security/inc"

}

对应的Xcode build settings配置项:

c356d8d575b8

截屏2021-01-21 下午9.01.49.png

其他的xcode配置项,也可以类似处理

二、有两种导入方式:

1、本地导入

我们的组件开发,总得有一个调试的工程对应。本地导入就是居于这种思路。

通过指令:pod lib create 组件名

自动会生成一个组件文件和对应的调试工程。对应的podfile如下:

use_frameworks!

platform :ios, '8.0'

target 'dbMule_Example' do

pod 'dbMule', :path => '../'

target 'dbMule_Tests' do

inherit! :search_paths

end

end

(1)重点:pod 'dbMule', :path => '../'

后面的path => '../'就是对于的podspec文件所在位置:

c356d8d575b8

截屏2021-01-21 下午8.40.09.png

如上,podfile目录的上一级就有podspec文件

(2)pod 'dbMule',:git => '../', :branch => 'myBranch'

也可以在其他分支导入,上面命令是从分支myBranch导入组件dbMule。这里引入一个工程管理方案:可以通过多分支管理多品线在同一个工程的项目,每个品线单独一个分支,独立开发,有相互关联的品线,就通过上面的指令引入其他品线内容。

2、远程导入(我们导入的其他第三方库就是这种)

pod 'dbMule', :git => 'https://github.com/wulang150/dbMule.git'

如上,pod后面对应一个git地址了,这个地址根目录下必须有对应的podspec文件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值