搭建cocoapods本地测试

2016-10-28 10:26:46来源:oschina作者:fx911人点击



## 搭建cocoapods本地测试
### 为了项目组件化,我们会使用cocoapods进行相关的组件开发,为了调试方便,在这里我们可以考虑引入本地pod。
### 其他说明
1. 使用本地Pod时,s.source项并无卵用
2. 当一个本地Pod A依赖于本地Pod B时,需要在podspec文件中使用如下语句来描述:
```ruby
s.dependency "B"
```
同时在主工程中,添加:
```ruby
pod B :path => "PATH_TO_B"
```
### 步骤如下
1.将开发中的pod项目下载到本地,例子中我们checkout一个svn项目:test。
2.在项目目录中为项目配置本地的podspec文件,对于这个文件是从目前配置的FXPodspec中的podspec文件复制过来,改动了项目的source和dependence。
```
Pod::Spec.new do |s|
s.name= "Test"
s.version= "1.9.0"
s.summary= "test"
s.description= "test"
s.homepage = "http://svn.s.fx.com/Test/development/test/ios/"
# s.screenshots= "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"
# s.license= "MIT (example)"
# s.license= { :type => "MIT", :file => "FILE_LICENSE" }
s.author= { "fx" => "fx@fx.com" }
# Or just: s.author= "fx"
# s.authors = { "fx" => "fx@fx.com" }
# s.social_media_url = "http://twitter.com/fx"
# s.platform = :ios
s.platform = :ios, "5.0"
#When using multiple platforms
# s.ios.deployment_target = "5.0"
s.source= { :svn => "./" }
s.source_files= "*.{h,m}", "Test/*.{h,m}"
# s.exclude_files = "Classes/Exclude"
# s.public_header_files = "Classes/**/*.h"
s.public_header_files = "Test/Test.h"
# s.resource= "icon.png"
# s.resources = "Resources/*.png"
# s.preserve_paths = "FilesToSave", "MoreFilesToSave"
# s.framework= "SomeFramework"
s.frameworks = "SystemConfiguration", "UIKit", "CoreGraphics", "CoreTelephony", "Foundation"
s.weak_framework = "AdSupport"
s.library = "z"
# s.libraries = "iconv", "xml2"
s.requires_arc = true
s.prefix_header_file = 'Test/Test-Prefix.pch'
s.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-ObjC' }
# s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
end
```
3.在需要引入该pod的项目的podfile中,添加
```
pod 'Test', :path => '/Users/fx/Desktop/iOS/fx/Test/ios/trunk'
```
指向你的本地pod文件目录
4.如果有依赖,比如例子中需要
```
plugin 'cocoapods-repo-svn', :sources => [
'http://svn.s.fx.com/fx/development/lab/ios/FXSpecs/'
]
pod 'FXJSONSupport', '~> 1.0.0'
```
需要额外添加
5.最后,在项目执行
```
pod install --no-repo-update
```
进行pod更新
#### 随后,我们就可以看到pod项目被引入到一个Development Pods的组中,其中里面的文件是本地pod项目的软链接,这样在修改pod项目代码的同时,接入pod的项目也会随之更改pod源文件,就可以做到两个项目的联调。over

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台