更新到 Xcode 8.3 后桥接头中出现“文件“File.h”的不可移植路径;指定的路径与磁盘上的文件名不同”警告

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43067017/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 09:51:37  来源:igfitidea点击:

"Non-portable path to file "File.h"; specified path differs in case from file name on disk" warning in bridging header after updating to Xcode 8.3

iosobjective-cswiftxcodebridging-header

提问by Tamás Sengel

I updated to Xcode 8.3 and Swift 3.1 and got this warning in my bridging header file, referencing to an Objective-C header file:

我更新到 Xcode 8.3 和 Swift 3.1 并在我的桥接头文件中收到此警告,引用了一个 Objective-C 头文件:

Non-portable path to file "File.h"; specified path differs in case from file name on disk

文件“File.h”的不可移植路径;指定的路径与磁盘上的文件名不同

How can I resolve this?

我该如何解决这个问题?

回答by Tamás Sengel

It turned out that I misspelled the file's name, the correct name was "FILE.h" instead of "File.h". The warning appeared because of the soon coming APFS to macOS.

结果是我拼错了文件名,正确的名字是“FILE.h”而不是“File.h”。出现警告是因为 macOS 即将推出 APFS。

回答by Den

In my case, the !!project folder name!!isn't match the bridging header path.

就我而言, !!项目文件夹名称!!与桥接头路径不匹配。

I changed

我变了

"project/project-Bridging-Header.h"

项目/project-Bridging-Header.h”

to

"Project/project-Bridging-Header.h"

项目/project-Bridging-Header.h”

Tested on Xcode 9.3

在 Xcode 9.3 上测试

回答by Joel Murphy

One additional cause, that I experienced, was that a library project was importing itself incorrectly. For example, given projects Mainand Library, Main would import Library with:

我遇到的另一个原因是库项目自身导入不正确。例如,给定项目MainLibrary, Main 将导入 Library :

#import "Library/Library.h"

If Library attempts to use the same import, the Non-portable pathwarning will appear. Removing the path portion is the easy fix:

如果库尝试使用相同的导入,则会出现不可移植路径警告。删除路径部分很容易解决:

#import "Library.h"

The better fix is to import the specific components that Library needs from itself:

更好的解决方法是导入库自身需要的特定组件:

#import "Widget.h"
#import "NSString+Library.h"