【问题标题】:How can I declare dependency to subspec 'A' from subspec 'B' in the same podspec file?如何在同一个 podspec 文件中从子规范“B”声明对子规范“A”的依赖?
【发布时间】:2017-05-20 11:04:04
【问题描述】:

我正在尝试找到一种方法来在 podspec 中声明从 subspec 'B' 到 subspec 'A' 的依赖关系:'mypodspecfile.podspec',如下所示:

Pod::Spec.new do |s|
  s.name         = "MyLib-SDK"
  s.version      = "1.0"
  s.summary      = "My Library"
  s.homepage     = "http://myhomepage.com"

  s.ios.deployment_target = "8.0"
  s.ios.frameworks = "Foundation", "UIKit", "SystemConfiguration", "Security", "CoreTelephony", "WebKit"

  s.source       = { :git => "https://github.com/myhome/ios-project.git", :tag => "1.0" }

  s.subspec 'MyLibrary-A' do |libOne|
    libOne.source_files  = "Headers", "Headers/**/*.h"
    libOne.exclude_files = "Headers/Exclude"
    libOne.resources = "SharedAssets/*"

    libOne.libraries = "z","sqlite3" #Zlib for gzip, sqlite3 for event store
    libOne.vendored_library = "libMyLibrary_A.a"
  end

  s.subspec 'MyLibrary-B' do |libTwo|
    libTwo.source_files  = "Headers", "Headers/**/*.h"
    libTwo.exclude_files = "Headers/Exclude"
    libTwo.resources = "SharedAssets/*"
    libTwo.dependency 'MyLibrary-A'  <-- doesn't seem to be working here!!

    libTwo.libraries = "sqlite3" # sqlite3 for db
    libTwo.vendored_library = "libMyLibrary_B.a"
  end

 end

当我执行时:

$pod spec lint mypodspecfile.podspec --verbose

-ERROR | [iOS] unknown: Encountered an unknown error (Unable to find a specification for MyLibrary-A depended upon by MyLibrary-B

任何帮助将不胜感激。谢谢你!

【问题讨论】:

标签: cocoapods podspec cocoapods-1.1.1


【解决方案1】:

您应该始终写入 pod 依赖项的完整路径。该错误表明可可豆荚在 pod repo(s) 中找不到 MyLibrary-A.podspec 文件。要解决此问题,请指定完整路径 'MyLib-SDK/MyLibrary-A'

所以你的 podspec 文件应该是这样的:

Pod::Spec.new do |s|
  s.name         = "MyLib-SDK"
  s.version      = "1.0"
  s.summary      = "My Library"
  s.homepage     = "http://myhomepage.com"

  s.ios.deployment_target = "8.0"
  s.ios.frameworks = "Foundation", "UIKit", "SystemConfiguration", "Security", "CoreTelephony", "WebKit"

  s.source = { :git => "https://github.com/myhome/ios-project.git", :tag => "#{s.version}" }

  s.subspec 'MyLibrary-A' do |libOne|
    libOne.source_files  = "Headers", "Headers/**/*.h"
    libOne.exclude_files = "Headers/Exclude"
    libOne.resources = "SharedAssets/*"

    libOne.libraries = "z","sqlite3" #Zlib for gzip, sqlite3 for event store
    libOne.vendored_library = "libMyLibrary_A.a"
  end

  s.subspec 'MyLibrary-B' do |libTwo|
    libTwo.source_files  = "Headers", "Headers/**/*.h"
    libTwo.exclude_files = "Headers/Exclude"
    libTwo.resources = "SharedAssets/*"
    libTwo.dependency 'MyLib-SDK/MyLibrary-A'  # here is the change

    libTwo.libraries = "sqlite3" # sqlite3 for db
    libTwo.vendored_library = "libMyLibrary_B.a"
  end

 end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-20
    • 2023-04-04
    • 2011-01-02
    相关资源
    最近更新 更多