简体   繁体   English

“名称”不可用:在 iOS - XCode11 上不可用

[英]'name' is unavailable: not available on iOS - XCode11

After upgrading from XCode 10.0 to 11从 XCode 10.0 升级到 11 后

I am getting the error 'name' is unavailable: not available on iOS我收到错误“名称”不可用:在 iOS 上不可用

This is during Build for Swift 4.2 on XCode 11.0 and 11.1, I can still build using XCode 10这是在 XCode 11.0 和 11.1 上为Swift 4.2构建期间,我仍然可以使用 XCode 10 构建

This is happening in the code of one of the Objective C external libraries we have been using through Cocopods.这发生在我们一直通过 Cocopods 使用的Objective C外部库之一的代码中。

return [(NSNumber *)[table[state] objectForKey:[rule name]] unsignedIntegerValue];

I can work around the issue by renaming the variable name to ruleName , but I would rather not do this.我可以通过将变量名称重命名为ruleName来解决此问题,但我宁愿不这样做。

Why is Xcode objecting to a variable name of name?为什么 Xcode 反对 name 的变量名称? Is this an Xcode but or is it something I can fix in the build settings这是 Xcode 还是我可以在构建设置中修复的东西

Edit编辑

The specific pod is NUI 0.5.5具体的 pod 是NUI 0.5.5

In module NUIPShiftReduceGotoTable.m在模块 NUIPShiftReduceGotoTable.m

- (NSUInteger)gotoForState:(NSUInteger)state rule:(NUIPRule *)rule
{
    return [(NSNumber *)[table[state] objectForKey:[rule name]] unsignedIntegerValue];
}

Apple made a change that can break previously compiling code in Xcode 11.0/11.1. Apple 所做的更改可能会破坏 Xcode 11.0/11.1 中先前编译的代码。 Previously the compiler would be fine with passing the 'name' message to an object that it didn't know the type of.以前,编译器可以将“名称”消息传递给它不知道类型的 object。 This can happen for many reasons in the weakly typed Objective-C world.在弱类型 Objective-C 世界中,由于多种原因可能会发生这种情况。

Currently in Xcode 11.1 you can do.目前在 Xcode 11.1 你可以做到。

id x = nil;
[x name];

And this will compile, no problem.这将编译,没问题。 But:但:

NSObject *x = nil
[x name];

won't compile due to the compiler identifying the most likely selector being the API_UNAVAILABLE one in NSLayoutAnchor.h (maybe).由于编译器识别出最可能的选择器是 NSLayoutAnchor.h 中的 API_UNAVAILABLE (可能),因此无法编译。

If the compiler had more information it can map the correct selector.如果编译器有更多信息,它可以 map 正确的选择器。 This might be as simple as including the header for whatever has name property in the.m file that is failing.这可能就像包含 header 一样简单,因为 .m 文件中有 name 属性失败。

My guess is something like in NUIPShiftReduceGotoTable.m you add a line #import"NUIPRule.h"我的猜测类似于在 NUIPShiftReduceGotoTable.m 中添加一行 #import"NUIPRule.h"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM