更新到Xcode 10.2和Swift 5后出现“找不到'NBPhoneNumberDesc.h'文件”错误

4
我正在使用chronotruck/FlagPhoneNumber pod,我刚刚从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'文件未找到

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

我尝试了这个答案,但NBPhoneNumberDesc.h已经在公共部分中了:

enter image description here

我也尝试了这个答案,将SWIFT_OBJC_INTERFACE_HEADER_NAME设置为与我的项目的桥接头文件匹配,但是没有效果。
在发生错误的文件NBRegExMatcher.m中,我注释掉了#import NBPhoneNumberDesc.h,以查看会发生什么,然后NBPhoneNumberUtil.h出现了相同的错误:

enter image description here

我注意到libPhoneNumber-iOS被打包在FlagPhoneNumber pod中,其版本为libPhoneNumberiOS (0.7.6)。然后我手动添加了这个pod到我的项目中,想看看会发生什么,但是没有任何改变,错误仍然存在。唯一的事情是我注意到当我手动添加pod时,Podfile.lock版本是- libPhoneNumber-iOS (0.9.15),而FlagPhoneNumber使用的版本是libPhoneNumberiOS (0.7.6)您有什么想法如何解决这个错误吗?
1个回答

5

我尝试了很多关于在构建设置(Build Settings) ->头文件(Header File)和/或用户头文件(User Header files)中更改东西的答案,但是它们都不起作用。我按照这个答案并且它起作用了 :)

我需要做的是通过使用尖括号而不是引号来更改#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 文件 在此输入图片描述

NBPhoneNumberUtil.m 文件 在此输入图片描述

另外一件事,我还需要将pod 'libPhoneNumber-iOS', '~> 0.8'添加到我的Podfile中,因为我在FlagPhoneNumber pod之外使用了该库以避免出现不同的错误。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接