0

我似乎无法理解如何将静态库和公共标头作为 cocoapod 上传。我想要实现的是,通过安装这个 pod,它会拉取 .a 文件和一些标题并将其与我的 .xcodeproj 链接。

  1. 我为所有架构构建了一个 protobuf,并用 lipo 制作了一个通用库。
  2. 我将标题和 .a 文件放入文件夹,将其压缩并上传到存储中,并通过公共链接访问。

    Pod::Spec.new do |s|
      s.name         = "Protobuf"
      s.version      = "0.2.4"
      s.license      = { :type => "MIT" }
      s.homepage     = "https://github.com/Rostyk/Protobuf"
      s.author       = { "Ross" => "ros.aphex@gmail.com" }
      s.summary      = "Protobuf binary"
      s.source       = { :http => 
        'https://www.dropbox.com/s/gon6x99xjp6hh9g/protobuf.zip?dl=1', :tag => "v0.2.4" }
    end

当我这样做pod lib lint Protobuf.podspec --verbose时输出:

Protobuf did not pass validation, due to 2 errors and 1 warning.
[!] The validator for Swift projects uses Swift 3.0 by default, if you
are using a different version of swift you can use a 
`.swift-version` file to set the version for your Pod. For example to use Swift 2.3,
run: `echo "2.3" > .swift-version`.
You can use the `--no-clean` option to inspect any issue.

我浏览了这篇关于二元 cocoapods的文章

不幸的是,我对 pod 没有任何经验。也许有人会指出我正确的方向?

4

1 回答 1

0

我设法解决了这个问题。如果有人需要,那是有效的 podspec

Pod::Spec.new do |s|
  s.name     = 'DMProtobuf'
  s.version  = '1.0.1'
  s.license  = 'BSD'
  s.summary  = 'Protobuf for iOS'
  s.description  = 'Static library with protobuf utilities'
  s.homepage = 'https://homepage.sample.com'
  s.author       = 'Google'
  s.source   = { :git => 'https://github.com/YourAccount/Repo.git', :tag => s.version.to_s }
  s.preserve_paths = '*.a'
  s.libraries = 'protobuf'
  s.xcconfig     =  { 'LIBRARY_SEARCH_PATHS' => '$(inherited) "$(PODS_ROOT)/DMProtobuf"' }
  s.platform = :ios
end

也不要忘记用'1.0.1'标记你的分支

于 2017-04-15T20:12:07.940 回答