構(gòu)建本地Pod庫(kù)流程網(wǎng)上一搜一大堆就不再重復(fù)了间驮。
主要的坑在是配置podspec文件躬厌。
Pod::Spec.new do |s|
s.name = "ProtocolBuffNetWorking"
s.version = "0.0.1"
s.summary = "Tool for networking, base on ProtocolBuff."
s.description = <<-DESC
Tool for networking, base on ProtocolBuff.
DESC
s.homepage = "http://ProtocolBuffNetWorking"
s.license = "MIT"
s.author = { "yyf" => "765936789@qq.com" }
s.platform = :ios, "9.0"
s.source = { :git => "http://ProtocolBuffNetWorking.git", :tag => "#{s.version}" }
s.source_files = "ProtocolBuffNetWorking/ProtocolBufferModels/*.{h,m}", "ProtocolBuffNetWorking/NetWorkManager/*.{h,m,mm}","ProtocolBuffNetWorking/ProtocolBuffRequest/*.{h,m}","ProtocolBuffNetWorking/StaticLib/*.h"
s.dependency 'Protobuf','~> 3.5.0'
s.requires_arc = true
s.vendored_libraries = 'ProtocolBuffNetWorking/StaticLib/*.a'
s.libraries = 'c++.1'
non_arc_files = "ProtocolBuffNetWorking/ProtocolBufferModels/*.{h,m}"
s.exclude_files = non_arc_files
s.subspec 'no-arc' do |sp|
sp.requires_arc = false
sp.source_files = non_arc_files
end
end
自己用,描述啊竞帽,網(wǎng)址那些可以隨便寫(xiě)扛施。
出現(xiàn)的問(wèn)題及解決
1、
'UIKit/UIKit.h' file not found
漏掉了下面這句
s.platform = :ios, "9.0"
未指定iOS系統(tǒng)屹篓,所以找不到UIKit疙渣。
2、依賴第三方庫(kù)Protobuf
s.dependency 'Protobuf','~> 3.5.0'
3堆巧、部分代碼需要支持MRC
non_arc_files = "ProtocolBuffNetWorking/ProtocolBufferModels/*.{h,m}"
s.exclude_files = non_arc_files
s.subspec 'no-arc' do |sp|
sp.requires_arc = false
sp.source_files = non_arc_files
end
4妄荔、引用自己的framework或.a文件
s.vendored_libraries = 'ProtocolBuffNetWorking/StaticLib/*.a'
s.vendored_frameworks = 'xxx/**/*.framework'
5泼菌、x86_64的錯(cuò)誤,使用了未定義的c++函數(shù)啦租。這是因?yàn)?a庫(kù)是c++寫(xiě)的灶轰,需要添加系統(tǒng)的依賴庫(kù)libc++.1.tdb。
s.libraries = 'c++.1'
6刷钢、圖片資源
s.resource_bundles = {
'LazyTableViewModel' => ['Assets/*.png']
}
如果直接使用
[UIImage imageNamed:@“圖片名"]
圖片無(wú)法顯示笋颤,這種方式默認(rèn)是從mainBundle中去加載圖片,會(huì)找不到圖片内地。
可以通過(guò)路徑來(lái)加載
NSBundle *bundle = [NSBundle bundleForClass:[LazyTableViewModel class]];
NSString *path = [bundle pathForResource:@"網(wǎng)絡(luò)錯(cuò)誤.png" ofType:nil inDirectory:@"LazyTableViewModel.bundle"];
UIImage *image = [UIImage imageWithContentsOfFile:path];
本地庫(kù)的使用
Podfile
target 'ProtocolBuffNetWorking' do
pod 'ProtocolBuffNetWorking', :path => '/路徑/'
end
cd 到工程目錄下
pod install