我正在开发一个使用开源跨平台库的项目。这个库是一个巨大的库,使用Makefile
系统(甚至Rakefile
)构建。我想建立一个podspec,以便能够使用CocoaPods
集成这个lib。但我找不到办法做到这一点。
我考虑过将一个运行脚本添加到pod install
阶段,或者(可能更好)将运行脚本阶段添加到Xcode目标,该目标将启动正确的make […]
命令以拥有此开源库为正确的平台打造。
有任何想法或指示吗?谢谢!
答案 0 :(得分:4)
请参阅prepare_command
文档:http://guides.cocoapods.org/syntax/podspec.html#prepare_command。
答案 1 :(得分:1)
感谢合金。这是一个例子。
Pod::Spec.new do |s|
s.prepare_command = <<-CMD
cd MySDK
sh ./build.sh debug # run shell or makefile to generate the mysdk.h and libmysdk.a
CMD
s.name = "MySDK"
s.version = "1.0.0"
s.source_files = "MySDK/output/debug/ios/arm/*.h"
s.vendored_libraries = "MySDK/output/debug/ios/arm/libmysdk.a",
# s.public_header_files = "MySDK/output/debug/ios/arm/mysdk.h"
s.authors = "xxxx"
s.homepage = "xx"
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.source = { :git => 'https://github.com/<GITHUB_USERNAME>/podTestLibrary.git', :tag => s.version.to_s }
s.summary = "my sdk"
end
之后我发现一个问题。如果安装一次后更新子项目源代码,则s.prepare_command
将无法执行并再次构建。因此,我必须使用pre_install。当我们更新子项目时,只需pod install
pre_install do |installer|
`cd ./MySDK; sh ./build.sh debug;`
end