【问题标题】:.podspec error - source_files` pattern did not match any file.podspec 错误 - source_files` 模式与任何文件都不匹配
【发布时间】:2014-01-04 02:02:30
【问题描述】:

我正在将 one of my github repos(如果有帮助,请在此处提供完整代码)与 Cocopods 集成,当我运行 pod spec lint 时出现此错误。

 -> DropDownMenu (0.0.1)
  - ERROR | [iOS] The `source_files` pattern did not match any file.

这是我的.podspec 的相关代码,我认为这是导致问题的原因。

查看示例hereherehere,我尝试了以下方法

s.source_files  = 'Classes/*.{h,m}'
s.source_files  = 'Classes/DropDownMenu.{h,m}'
s.source_files  = 'Classes'
s.source_files  = 'Classes/**/*.{h,m}'

我的s.source_files 字段不正确吗?还是我对.podspec 做错了什么?我该怎么做才能解决这个问题?

我的问题类似于this question,但是该解决方案对我不起作用(我的代码已在 Github 上更新)。

【问题讨论】:

    标签: ios cocoapods


    【解决方案1】:

    问题是你的 podspec 引用了一个还没有 Classes 文件夹的提交,

    即此提交还没有 classes 文件夹https://github.com/kevinrandrup/DropDownMenu/tree/09c9b3d515b78550557eabc0a8542f9f6f2623cf

    您可以通过引用最新提交来解决此问题,即将您的 podspec 源更改为:

    s.source       = { :git => "https://github.com/kevinrandrup/DropDownMenu.git", :commit => "0d6761feefccff1f7d8b7c7788ceb8e9cd1314ea" }
    s.source_files  = 'Classes/*.{h,m}'
    

    【讨论】:

    • 我们默认生成了 s.resources = 'Pod/Assets/*.png' 并且有点忘记了它......
    • 有没有办法自动完成?如果您不需要指定最新提交,而是始终引用最新提交?
    • @naz 是的,您可以指定一个标签,并让它从您的 podspec 版本自动生成:{ :git => "https://github.com/kevinrandrup/DropDownMenu.git", :tag => s.version.to_s }
    • 嗨@Andy,如果你能找出任何原因,请检查我的一个问题,我收到同样的错误! stackoverflow.com/questions/43073261/…
    【解决方案2】:

    在 CocoaPods 使用 1.1.0 RC3 版本自动为我生成 podspec 文件后,我遇到了这个问题。

    Podspec 文件中的原始行是:

    s.source_files = 'Pod/Classes/**/*'
    

    我把它改成:

    s.source_files = 'NAME_OF_POD/Classes/**/*'
    

    【讨论】:

    • 这正是问题所在。感谢您分享此信息。
    • 当我的源代码引用 .zip 文件时,这对我有用!谢谢!
    【解决方案3】:

    我使用了 git 标签。对我来说效果很好。

    第一步:添加标签

    git tag 1.0.2 && git push origin --tags
    

    第 2 步:使用标签设置来源

    s.source       = { :git => "https://github.com/kevinrandrup/DropDownMenu.git", :tag => s.version }
    s.source_files  = 'Classes/*.{h,m,swift}'
    

    请注意,您的标签必须与您的 pod 规格版本相同。

    【讨论】:

    • s.source_files = 'Classes/*.{h,m,swift}' 完成了这项工作,谢谢!
    • "请注意,您的标签必须与您的 pod 规格版本相同。"你说的太对了!!!
    【解决方案4】:

    我遇到了同样的问题。我通过将该行修改为:

    spec.source_files = "POD NAME/**/*"

    【讨论】:

      【解决方案5】:

      我通过更改 pod 的版本号解决了我的问题。请在ERROR | [iOS] file patterns: The `source_files` pattern did not match any file查看我的回答

      【讨论】:

      • 这应该是评论,而不是答案。如果这是一个重复的问题,那么vote to close 和/或在您earn 足够reputation 后发表评论。如果问题不是重复的,则针对此特定问题定制答案。
      【解决方案6】:

      第一步:添加标签

      git tag 0.1.3 && git push --tags
      

      Step-2:使用上述标签指定源文件

      s.source           = { :git => 'https://github.com/harryzhang1005/HGCommonLibrary.git', :tag => s.version.to_s }
      s.source_files  = 'Classes/*.{h,m,swift}'
      

      第 3 步:验证规范

      pod spec lint HGCommonLibrary.podspec --allow-warnings
      

      第 4 步:推送到规范回购

      pod repo push harry-specs HGCommonLibrary.podspec --allow-warnings
      

      【讨论】:

        【解决方案7】:

        我遇到了这个问题。正确的配置应该是:

        s.source       = { :git => "https://github.com/kevinrandrup/DropDownMenu.git", :commit => "0d6761feefccff1f7d8b7c7788ceb8e9cd1314ea" }
        s.source_files  = 'Classes/**/*.{h,m}'
        

        【讨论】:

          【解决方案8】:

          两种解决方案: 指定 1. 源有效负载中的标签,2。在源负载中指定提交号。

          【讨论】:

            【解决方案9】:

            需要三个步骤才能使其发挥作用。

            1.确保source_files指定的路径正确。

            2. 确保源文件夹不为空。这意味着在执行pod lib lint之前必须将一些源文件放入其中@

            3. 在将 repo 推送到 Git 之前,请确保您已指定正确的标签并将源文件和 tag 推送到远程服务器。

            【讨论】:

              【解决方案10】:

              添加

              spec.source_files  = "YOUR_POD_NAME/**/*.{h,m,swift}"
              

              解决了我的问题

              【讨论】:

                【解决方案11】:

                我删除了我的资源文件夹并修复了错误,我必须从 Project.podspec 中删除它:

                #s.resource_bundles = {
                #  'Project' => ['Resources/**/*.{png}']
                #}
                

                【讨论】:

                  猜你喜欢
                  • 1970-01-01
                  • 1970-01-01
                  • 2016-05-14
                  • 2016-10-01
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  相关资源
                  最近更新 更多