我正在使用 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
升级前一切正常,我从未遇到过任何这些错误。
Podfile.lock 里面有这个:
- FlagPhoneNumber (0.7.6):
- FlagPhoneNumber/libPhoneNumberiOS (= 0.7.6)
- FlagPhoneNumber/libPhoneNumberiOS (0.7.6)
奇怪的是,该 pod 中还有其他几个文件也使用了 #import "NBPhoneNumberDesc.h"
模块,但它们都工作正常并且没有任何错误
我试过了 this answer但是 NBPhoneNumberDesc.h 已经在公共(public)部分:
我也试过this answer设置 SWIFT_OBJC_INTERFACE_HEADER_NAME 以匹配我的项目的桥接 header ,但什么都没有
在 NBRegExMatcher.m
文件中(发生错误的地方)我注释掉了 #import NBPhoneNumberDesc.h
以查看会发生什么,然后 NBPhoneNumberUtil.h 得到了同样的错误:
我注意到 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>
以下是每张图片:
在旁注中,我还必须添加 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/