从 GitHub 生成的 CocoaPods podspec 不匹配任何 source_files

CocoaPods podspec generated from GitHub not matching any source_files

我正在开发一个 Swift 2 项目,其中包括许多可用的 CocoaPods,并且正在努力为来自 GitHub 的 OrderedDictionary class 创建一个 podspec 文件,因为作者没有创建 Podfile。我运行:

pod spec create "OrderedDictionary|https://github.com/lukaskubanek/OrderedDictionary"

在我的项目目录的根目录中创建了 OrderedDictionary.podspec

#
#  Be sure to run `pod spec lint OrderedDictionary.podspec' to ensure this is a
#  valid spec and to remove all comments including this before submitting the spec.
#
#  To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
#  To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
#

Pod::Spec.new do |s|

  # ―――  Spec Metadata  ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  These will help people to find your library, and whilst it
  #  can feel like a chore to fill in it's definitely to your advantage. The
  #  summary should be tweet-length, and the description more in depth.
  #

  s.name         = "OrderedDictionary"
  s.version      = "0.5"
  s.summary      = "An implementation of OrderedDictionary in Swift"

  # This description is used to generate tags and improve search results.
  #   * Think: What does it do? Why did you write it? What is the focus?
  #   * Try to keep it short, snappy and to the point.
  #   * Write the description between the DESC delimiters below.
  #   * Finally, don't worry about the indent, CocoaPods strips it!
  s.description  = "This is a lightweight implementation of an ordered dictionary data structure in Swift packed into a µframework."

  s.homepage     = "https://github.com/lukaskubanek/OrderedDictionary"
  # s.screenshots  = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"


  # ―――  Spec License  ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  Licensing your code is important. See http://choosealicense.com for more info.
  #  CocoaPods will detect a license file if there is a named LICENSE*
  #  Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.
  #

  s.license      = "MIT"
  # s.license      = { :type => "MIT", :file => "LICENSE.md" }


  # ――― Author Metadata  ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  Specify the authors of the library, with email addresses. Email addresses
  #  of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also
  #  accepts just a name if you'd rather not provide an email address.
  #
  #  Specify a social_media_url where others can refer to, for example a twitter
  #  profile URL.
  #

  s.author             = { "Lukas Kubanek" => "lukas.kubanek@me.com" }
  # Or just: s.author    = "Lukas Kubanek"
  # s.authors            = { "Lukas Kubanek" => "lukas.kubanek@me.com" }
  # s.social_media_url   = "http://twitter.com/Lukas Kubanek"

  # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  If this Pod runs only on iOS or OS X, then specify the platform and
  #  the deployment target. You can optionally include the target after the platform.
  #

  # s.platform     = :ios
  s.platform     = :ios, "8.0"

  #  When using multiple platforms
  s.ios.deployment_target = "8.0"
  # s.osx.deployment_target = "10.7"
  # s.watchos.deployment_target = "2.0"
  # s.tvos.deployment_target = "9.0"


  # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  Specify the location from where the source should be retrieved.
  #  Supports git, hg, bzr, svn and HTTP.
  #

  s.source       = { :git => "https://github.com/lukaskubanek/OrderedDictionary.git", :tag => "v0.5" }


  # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  CocoaPods is smart about how it includes source code. For source files
  #  giving a folder will include any swift, h, m, mm, c & cpp files.
  #  For header files it will include any header in the folder.
  #  Not including the public_header_files will make all headers public.
  #

  s.source_files  = "Sources"
#s.exclude_files = "Classes/Exclude"

  # s.public_header_files = "Classes/**/*.h"


  # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  A list of resources included with the Pod. These are copied into the
  #  target bundle with a build phase script. Anything else will be cleaned.
  #  You can preserve files from being cleaned, please don't preserve
  #  non-essential files like tests, examples and documentation.
  #

  # s.resource  = "icon.png"
  # s.resources = "Resources/*.png"

  # s.preserve_paths = "FilesToSave", "MoreFilesToSave"


  # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  Link your library with frameworks, or libraries. Libraries do not include
  #  the lib prefix of their name.
  #

  # s.framework  = "SomeFramework"
  # s.frameworks = "SomeFramework", "AnotherFramework"

  # s.library   = "iconv"
  # s.libraries = "iconv", "xml2"


  # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  If your library depends on compiler flags you can set them in the xcconfig hash
  #  where they will only apply to your library. If you depend on other Podspecs
  #  you can include multiple dependencies to ensure it works.

  # s.requires_arc = true

  # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
  # s.dependency "JSONKit", "~> 1.4"

end

在我的 Podfile 旁边:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'OrderedDictionary', :podspec => "OrderedDictionary.podspec"

我运行:

pod cache clean OrderedDictionary && pod install

Pods 项目下创建了一个 Pods/OrderedDictionary 组。

不幸的是该组是空的,因此项目无法构建在:

import OrderedDictionary

error: No such module 'OrderedDictionary'

Linting 通过:

pod spec lint OrderedDictionary.podspec --verbose

为了我的生活,我无法将 OrderedDictionary.swiftOrderedDictionary.h 复制到项目中的 pod 组中。

奇怪的是,我确实看到OrderedDictionary.h出现在小组中一次,但无法让它再次发生。我担心 CocoaPods 可能不是幂等的,但可能会忽略一些明显的东西。感谢您提供的任何帮助。

Xcode 7.2.1 (7C1002), OS X 10.10.5 (14F27), CocoaPods 0.39.0

根据. I tried my podspec in this IceCreamShop CocoaPods swift example回答我自己的问题然后在那里工作后,它在我原来的项目中工作。

复制步骤:

昨晚写完这个问题后,我硬着头皮下载了OrderedDictionary GitHub项目的zip,将其展开到我项目目录的根目录,将我的podspec移动到里面,并更改我的 Podfile 要说:

pod 'OrderedDictionary', :path => "OrderedDictionary"

这让我可以将它用作开发 pod,我看到 OrderedDictionary.swift 和 OrderedDictionary.h 被复制到 pod 的组中。

今天,在我让 IceCreamShop 开始工作后,我从我的项目目录中删除了 OrderedDictionary 目录,将我的 podspec 移回到我的项目目录的根级别,并将 Podfile 改回:

pod 'OrderedDictionary', :podspec => "OrderedDictionary.podspec"

pod 现在可以工作了,尽管我没有做任何更改。

我认为这可能是 CocoaPods 中的缓存问题,由于以下原因之一导致它不一致:

  • 不透明,子项目构建失败或进程终止等问题使缓存处于不一致状态,使我们能够通过故障检测缓存的存在。

  • 没有正确地失效,所以一旦它在我的项目目录中找到文件,它就会以某种方式记住它们并且能够在它们被删除后包含它们。

  • 加载和存储的行为因执行位置而异,允许副作用影响未来的加载和存储。

  • 存在加载和存储不确定的临时问题,因为超时优先于真实来源。

  • 一条来自遥远星系的宇宙射线在缓存中翻转了一下,导致我的波态崩溃到我花了几个小时追逐一个错误而不是一个我从来不知道这个错误存在的现实.

我喜欢 CocoaPods 并意识到这有点开玩笑,但缓存问题通常会对生产力产生不利影响,我建议所有项目都可以选择禁用缓存并拥有它 运行 每次使用时进行内部一致性检查。

以下是一些可能对遇到类似问题的人有帮助的命令:

sudo rm -rf ~/Library/Caches/CocoaPods/
sudo rm -rf ~/.cocoapods/repos/master/

sudo rm -rf Pods/
pod install