安装pod后,Pod / Header为空

时间:2021-09-12 10:45:09

Issue

I used to have a functional set of Pods in my project (fully working project) until the latest pod install run, now I'm getting "file not found" errors for the headers mentioned in my bridging header (this is a Swift project with Obj-C includes). After doing some research, it seemed like there should be symlinks to the headers in Pods/Headers, that directory is empty for me. However, the pods themselves have been downloaded and all corresponding Pods/[Lib] directories exist.

我曾经在我的项目(完全工作的项目)中有一组功能性的Pod,直到最新的pod安装运行,现在我的桥接头中提到的标题出现“找不到文件”错误(这是一个Swift项目, Obj-C包括)。在做了一些研究之后,似乎应该对Pods / Headers中的标题进行符号链接,该目录对我来说是空的。但是,已经下载了pod本身并且存在所有相应的Pods / [Lib]目录。

Last Known Good State

What I've changed right before this error started occurring was specifying :git and :commit flags for one of the libraries I was pulling in. I then reran pod install and started seeing "file not found" errors. At the time I was using Cocoapods 0.39

我在这个错误开始发生之前就已经改变的是指定:git和:我正在拉入其中一个库的提交标志。然后我重新启动pod安装并开始看到“找不到文件”错误。那时我正在使用Cocoapods 0.39

Current State

I've tried a few solutions from other stack overflow threads, including adding User Header Search Paths, which had no effect (now back to original), and updating my cocoapods. My current version of cocoapods is now 1.0.0.beta.6. Aside from additional headaches I experienced such as having to rewrite parts of my Podfile to be compliant with new standards, I now seem to be back to the same state (with all libraries successfully downloading, but headers failing to be found).

我尝试了其他堆栈溢出线程的一些解决方案,包括添加用户头搜索路径,这些路径没有效果(现在回到原始版本),并更新了我的cocoapods。我目前的cocoapods版本现在是1.0.0.beta.6。除了我经历的额外头痛,例如必须重写我的Podfile的部分以符合新标准,我现在似乎回到了相同的状态(所有库成功下载,但标题未能找到)。

Here is an example of how I'm including my headers in the bridging header:

这是一个如何在桥接头中包含我的标题的示例:

// In this header, you should import all the public headers of your framework using statements like #import <MyKit/PublicHeader.h>
#import <CocoaLumberjack/CocoaLumberjack.h>

And here is what my Podfile looks like (I've tried to slim it down to avoid irrelevant content):

这就是我的Podfile的样子(我试图减少它以避免不相关的内容):

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

use_frameworks!
pod 'CocoaLumberjack', '2.0.0'
pod 'SwiftyJSON', '~> 2.3'
pod 'Classy', :git => 'https://github.com/ClassyKit/Classy.git', :commit => 'c319908f8bded62e268dfd48ee5d65329b819129'

workspace 'my.work-ios'
project 'mywork' # sdk
project 'Examples/example1' # sample project using sdk
project 'my.work-ios.xcodeproj' # placeholder for main project, not really in use

target 'UnitTests' do
  pod 'Specta'
  pod 'Expecta'
  pod 'OCMock'
  pod 'OHHTTPStubs'
end

# Copy acknowledgements to the Settings.bundle
post_install do | installer |
  require 'fileutils'

  pods_acknowledgements_path = 'Pods/Target Support Files/Pods/Pods-Acknowledgements.plist'
  settings_bundle_path = Dir.glob("**/*Settings.bundle*").first

  if File.file?(pods_acknowledgements_path)
    puts 'Copying acknowledgements to Settings.bundle'
    FileUtils.cp_r(pods_acknowledgements_path, "#{settings_bundle_path}/Acknowledgements.plist", :remove_destination => true)
  end

  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['OTHER_SWIFT_FLAGS'] = "-DLEGACY"
    end
  end
end

Update

After some more digging, I discovered that the culprit is use_frameworks! command, omitting it (and in turn removing Swift libraries, because it's required for them) causes Pods/Headers to be populated with Private and Public directories, along with symlinks for the relevant headers.

经过一番挖掘,我发现罪魁祸首是use_frameworks!命令,省略它(反过来删除Swift库,因为它们是必需的)导致Pods / Headers被填充私有和公共目录,以及相关标题的符号链接。

This was not the case in previous version of cocoapods, and I'm still trying to understand what's happening, because omitting that command is not a usable workaround for me (given the Swift libraries I use in my app).

在以前的cocoapods版本中并非如此,我仍然试图了解发生了什么,因为省略该命令对我来说不是一个可用的解决方法(考虑到我在我的应用程序中使用的Swift库)。

Update 2

This is already mentioned in the comments, but for convenience I'm putting this here as well. This seems to be caused by a bug reported in this thread: https://github.com/CocoaPods/CocoaPods/issues/4605#issuecomment-208822149. The thread also suggests a few workarounds that may be good enough for some. For me, they were not, so I went back to 0.39.

这已经在评论中提到了,但为方便起见我也把它放在这里。这似乎是由此线程中报告的错误引起的:https://github.com/CocoaPods/CocoaPods/issues/4605#issuecomment-208822149。该线程还提出了一些可能对某些人来说足够好的解决方法。对我来说,他们不是,所以我回到0.39。

1 个解决方案

#1


0  

Have you tried this settings?

你试过这个设置吗?

target 'TargetProject' do

    pod 'CocoaLumberjack', '2.0.0'
    pod 'SwiftyJSON', '~> 2.3'
    pod 'Classy', :git => 'https://github.com/ClassyKit/Classy.git', :commit     => 'c319908f8bded62e268dfd48ee5d65329b819129'

end

and have this '.swift-version' added? where it contains '3.0-GM-CANDIDATE'

并添加了'.swift-version'?它包含'3.0-GM-CANDIDATE'

I'm using this kind of settings for swift 3.0

我正在使用swift 3.0的这种设置

#1


0  

Have you tried this settings?

你试过这个设置吗?

target 'TargetProject' do

    pod 'CocoaLumberjack', '2.0.0'
    pod 'SwiftyJSON', '~> 2.3'
    pod 'Classy', :git => 'https://github.com/ClassyKit/Classy.git', :commit     => 'c319908f8bded62e268dfd48ee5d65329b819129'

end

and have this '.swift-version' added? where it contains '3.0-GM-CANDIDATE'

并添加了'.swift-version'?它包含'3.0-GM-CANDIDATE'

I'm using this kind of settings for swift 3.0

我正在使用swift 3.0的这种设置