ios - 在 iOS 中本地或远程安装 pod 时看不到额外添加的 .swift 文件,swift

标签 ios swift cocoapods

我使用 pod lib create 'mypodname' 创建了一个 pod。下面是 Xcode 给出的默认结构。

enter image description here

  • 大多数教程,我可以在 MyFirtTestPod 文件夹中看到名为 Classes 的文件夹。但我们这里没有。
  • 另一方面,我可以添加新的 .swift 文件,但是在使用本地路径安装 pod 到另一个项目之后,或者在 truncated 远程安装之后只能看到ReplaceMe.swift.swift 文件。 我尝试删除 RepalceMe.swift 文件并添加新的 .swift 文件。但没有用。我唯一能做的就是重命名 ReplaceMe.swift。我可以在 github 中看到这些文件,但在安装的 pod 中看不到

这是我的.podspec 文件和文件结构

enter image description here

最佳答案

根据您的帖子标题,您在已安装的 pod 中看不到新的 .swift 文件,对吗?

在你新建的.podspec文件中,你可以看到Cocoapod对Source Code的注释:

  # ――― 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.
  #

我使用的 Cocoapod 中几乎所有(Bolts 除外)框架都没有文件夹。因此,当您浏览 Pods > AFramework 时,您已经可以看到它的类。

这里是源码和资源最简单的.podspec代码。尝试一下。如您所见,我从我的 pod 的根文件夹中为源代码部分提供了我的路径。 GPKit/**/*.{swift} 以及我的资源。过去我遇到过与您相同的问题,但资源(例如 .xib)而不是 .swift 文件。

 # ――― 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 = "GPKit", "GPKit/**/*.{swift}"


  # ――― 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.resources = "GPKit/**/*.{xib}"


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

  s.pod_target_xcconfig = { 'SWIFT_VERSION' => '3' }

关于ios - 在 iOS 中本地或远程安装 pod 时看不到额外添加的 .swift 文件,swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46193145/

相关文章:

ios - SwiftUI 与 rotation3DEffect 动画冲突

ios - 为什么我不能在模拟器中点击 uibutton,但可以在我的硬件 iPhone 上点击 uibutton?

swift - Grand Central Dispatch with Swift : Use of unresolved identifier GCD

reactjs - 未定义的架构符号, react 原生 cocoapod 问题

xcode - Cocoapods 不适用于新的 m1 mac Big Sur Xcode

android - 如何在 Flutter 中直接调用电话

ios - 类别上的 OCMock

ios 通过容器 View 调整 scrollview 的大小,里面有 tableview

ios - 后台获取不工作

ios - pod update --verbose & pod install --verbose 未完成,挂起