ios - 更新到 Xcode 10.2、Swift 5 后 `' NBPhoneNumberDesc.h ' file not found`

标签 ios swift module cocoapods header-files

我正在使用 pod chronotruck/FlagPhoneNumber我刚刚从 High Sierra/Xcode 10.1/Swift 4.2/Cocoapoods v-1.5.3 更新到 Mojave 10.14.15/Xcode 10.2.1/Swift 5/Cocoapoods v-1.7.3 并且我无法构建,因为在 NBRegExMatcher.m 文件中出现错误

'NBPhoneNumberDesc.h' file not found

enter image description here

升级前一切正常,我从未遇到过任何这些错误。

Podfile.lock 里面有这个:

- FlagPhoneNumber (0.7.6):
- FlagPhoneNumber/libPhoneNumberiOS (= 0.7.6)
- FlagPhoneNumber/libPhoneNumberiOS (0.7.6)

奇怪的是,该 pod 中还有其他几个文件也使用了 #import "NBPhoneNumberDesc.h" 模块,但它们都工作正常并且没有任何错误

enter image description here

我试过了 this answer但是 NBPhoneNumberDesc.h 已经在公共(public)部分:

enter image description here

我也试过this answer设置 SWIFT_OBJC_INTERFACE_HEADER_NAME 以匹配我的项目的桥接 header ,但什么都没有

NBRegExMatcher.m 文件中(发生错误的地方)我注释掉了 #import NBPhoneNumberDesc.h 以查看会发生什么,然后 NBPhoneNumberUtil.h 得到了同样的错误:

enter image description here

我注意到 libPhoneNumber-iOS 捆绑在 FlagPhoneNumber pod 中,它的版本是 libPhoneNumberiOS (0.7.6)。然后我手动added the pod到我的项目看看会发生什么,但它也没有什么区别,错误仍然存​​在。我唯一注意到的是,当我手动添加 pod 时,Podfile.lock 版本是 - libPhoneNumber-iOS (0.9.15),其中 FlagPhoneNumber 使用的版本是 libPhoneNumberiOS (0.7. 6)

知道如何解决这个错误吗?

最佳答案

我尝试了一堆关于在 Build Settings > Header File 和/或 User Header files 中更改内容的答案,但没有一个有效。我关注了this answer它奏效了:)

我必须做的是改变 #import SomeFile.h#import <SomeFile.h>而是使用括号。

这是每个文件的代码

NBRegExMatcher.m里面我必须更改这两个模块的文件:

//#import "NBPhoneNumberDesc.h" // comment this out and add the brackets below
#import <NBPhoneNumberDesc.h>
//#import "NBPhoneNumberUtil.h" // comment this out and add the brackets below
#import <NBPhoneNumberUtil.h>

在我更改了这些之后,我在 NBPhoneNumberUtil.m 中也遇到了同样的错误并且必须在那里做同样的事情:

//#import "NBRegExMatcher.h" // comment this out and add the brackets below
#import <NBRegExMatcher.h>

以下是每张图片:

NBRegExMatcher.m文件 enter image description here

NBPhoneNumberUtil.m文件 enter image description here

在旁注中,我还必须添加 pod 'libPhoneNumber-iOS', '~> 0.8'到我的 Podfile,因为出现了一个不同的错误,因为我在 FlagPhoneNumber pod 之外使用了库

关于ios - 更新到 Xcode 10.2、Swift 5 后 `' NBPhoneNumberDesc.h ' file not found`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56876712/

相关文章:

ios - 翻转后 UIView 的框架发生变化

ios - 动态文本字段未在 TableView didSelectRowAt 方法中缓存

ruby - ruby 中 A::B 类名的含义是什么?

mysql - 与简单地将 mysql_auto_reconnect 设置为 1 相比,使用 DBIx::Connector 有什么优势?

ios - 如何在我的 iOS 应用程序中嵌入优酷或土 bean 视频?

ios - 没有 Storyboard的 UiSplitViewController App

ios - UISearchController - 搜索栏应该始终可见

你不懂 JS 的 javascript 模块模式

iphone - Bundle ID 应该如何用于多个 Apple 应用程序?

swift popToViewController