您如何使用一个子规格作为带有cocoapods的另一个子规格的依存关系?

时间:2018-11-15 07:22:49

标签: ios swift cocoapods

我正在尝试为vapor/core创建一个podspec。它已经有一个Swift Package Manager清单文件,因此我基于该文件的podspec。

Package.swift

// swift-tools-version:4.0
import PackageDescription

let package = Package(
    name: "Core",
    products: [
        .library(name: "Async", targets: ["Async"]),
        .library(name: "Bits", targets: ["Bits"]),
        .library(name: "Core", targets: ["Core"]),
        .library(name: "COperatingSystem", targets: ["COperatingSystem"]),
        .library(name: "Debugging", targets: ["Debugging"]),
    ],
    dependencies: [
        /// Event-driven network application framework for high performance protocol servers & clients, non-blocking.
        .package(url: "https://github.com/apple/swift-nio.git", from: "1.8.0"),
    ],
    targets: [
        .target(name: "Async", dependencies: ["NIO"]),
        .testTarget(name: "AsyncTests", dependencies: ["Async"]),
        .target(name: "Bits", dependencies: ["Debugging", "NIO"]),
        .testTarget(name: "BitsTests", dependencies: ["Bits", "NIO"]),
        .target(name: "Core", dependencies: ["Async", "Bits", "COperatingSystem", "Debugging", "NIOFoundationCompat"]),
        .testTarget(name: "CoreTests", dependencies: ["Core"]),
        .target(name: "COperatingSystem"),
        .target(name: "Debugging"),
        .testTarget(name: "DebuggingTests", dependencies: ["Debugging"]),
    ]
)

我认为我想为每个非测试目标创建一个subspec,尽管我不确定那是正确的,所以如果那是错误的,请更正我。这就是 Core.podspec:

的功能
Pod::Spec.new do |s|

  s.name         = "Core"
  s.version      = "3.4.4"
  s.summary      = " Utility package containing tools for byte manipulation, Codable, OS APIs, and debugging."

  s.description  = <<-DESC
    Utility package containing tools for byte manipulation, Codable, OS APIs, and debugging.
  DESC

  s.homepage     = "https://github.com/vapor/core"
  s.license      = { :type => "MIT", :file => "LICENSE.txt" }

  s.author             = { "Tanner Nelson" => "" }

  s.ios.deployment_target = "10.0"

  s.source       = { :git => "https://github.com/twof/core.git", :branch => "master" }

  s.source_files = "Sources/**/*.swift"
  s.exclude_files = [
    'Pods/**'
  ]
  s.module_name = "Core"

  s.swift_version = "4.2"

  s.dependency 'SwiftNIO'

  s.subspec 'Debugging' do |debug|
      debug.source_files = 'Sources/Debugging/**/*.swift'
  end

  s.subspec 'Async' do |async|
      async.dependency 'SwiftNIO'

      async.source_files = 'Sources/Async/**/*.swift'
  end

  s.subspec 'Bits' do |bits|
      bits.dependency 'SwiftNIO'
      bits.dependency 'Core/Debugging'

      bits.source_files = 'Sources/Bits/**/*.swift'
  end

  s.subspec 'COperatingSystem' do |os|
      os.source_files = 'Sources/COperatingSystem/**/*.swift'
  end

  s.subspec 'Core' do |core|
      core.source_files = "Sources/Core/**/*.swift"

      core.dependency 'Core/Debugging'
      core.dependency 'Core/Async'
      core.dependency 'Core/Bits'
      core.dependency 'Core/COperatingSystem'
      core.dependency 'SwiftNIOFoundationCompat'
  end
end

但是,以上内容无法掉毛并出现以下错误

 -> Core (3.4.4)
    - ERROR | [Core/Bits,Core/Core] xcodebuild: Returned an unsuccessful exit code.
    - ERROR | [Core/Bits,Core/Core] xcodebuild:  Core/Sources/Bits/BitsError.swift:1:8: error: no such module 'Debugging'

似乎Core/Debugging未被用作Core/BitsCore/Core的依赖项,我不知道为什么。如果有帮助,您可以找到pod spec lint Core.podspec --verbose here.

的完整输出

0 个答案:

没有答案