实话说真没做过SDK开发,最近也是在接触这块,从一开始啥也不会,现在好多了。也算是马马虎虎踩了一些坑。记录一下吧。
1、怎么解决开发SDK的调试问题:
我目前是使用development pod方式开发SDK的,开发完再把文件挪到SDK项目,打成framework给别人用。
2、别人怎么用我做的这个SDK:
第一种方法是直接把framework文件给别人放到项目使用了,但是估计我们用的项目组不得愿意,哈哈。
第二种是做成pod形式,别人直接修改Profile文件直接pod install即可。
我目前是采用的第二种方式。
这个最主要的是.podspec文件的处理。
Pod::Spec.new do |spec|
spec.name = "项目名"
spec.version = "0.1.1"
spec.platform = :ios, "10.0"
spec.summary = "SDK"
spec.homepage = "git地址"
spec.license = { :type => "MIT", :file => "LICENSE" }
spec.author = { "XX" => "XXX@qq.com" }
spec.source = { :git => "https://git地址.git", :tag => "#{spec.version}" }
spec.preserve_paths = 'XXX.framework'
spec.source_files = 'XXX.framework/Headers/*.h'
spec.public_header_files = 'XXX.framework/Headers/*.h'
spec.resource = ['XXX.framework/XXX.bundle']
spec.frameworks = "UIKit", "Foundation"
spec.requires_arc = true
spec.xcconfig = { "HEADER_SEARCH_PATHS" => "${PODS_ROOT}/c2-ios-wallet/XXX.framework/Headers/"}
spec.vendored_frameworks = 'XXX.framework'
spec.dependency "YYModel"
spec.dependency "YTKNetwork"
spec.dependency "SGQRCode", '3.5.1'
end
3、怎么处理SDK里图片资源bundle文件问题:
获取图片调用以下方法:
#import "NSBundle+Extension.h"
@implementation NSBundle (Extension)
+ (UIImage *)bundleImageWithName:(NSString *)imageName {
NSBundle *bundle = [NSBundle mainBundle];
NSURL *url = [bundle URLForResource:@"C2-iOS-Wallet" withExtension:@"bundle"];
NSBundle *imageBundle = [NSBundle bundleWithURL:url];
NSString *path = [imageBundle pathForResource:imageName ofType:@"png"];
return [UIImage imageWithContentsOfFile:path];
}
@end
注意.podspec文件对资源文件处理。
spec.resource = ['XXX.framework/XXX.bundle']
参考文档:
https://www.jianshu.com/p/a0249c0539fb
暂时就这些,后面有再记录~~~
网友评论