锐英源软件
第一信赖

精通

英语

开源

擅长

开发

培训

胸怀四海 

第一信赖

当前位置:锐英源 / 开源技术 / ios开源技术 / error::1:1:error:use of unresolved identifier使用未解析标识符
服务方向
人工智能数据处理
人工智能培训
kaldi数据准备
小语种语音识别
语音识别标注
语音识别系统
语音识别转文字
kaldi开发技术服务
软件开发
运动控制卡上位机
机械加工软件
软件开发培训
Java 安卓移动开发
VC++
C#软件
汇编和破解
驱动开发
联系方式
固话:0371-63888850
手机:138-0381-0136
Q Q:396806883
微信:ryysoft

锐英源精品开源,禁止转载和任何形式的非法内容使用,违者必究


error::1:1:error:use of unresolved identifier使用未解析标识符


I have this problem with po in the console where trying to output a function works in itself, but outputting a variable or constant doesn't.我有这个问题,在控制台里的po,试图输出函数本身的工作结果,但没有输出变量或常量。

first result is for <code>po bar.boy()</code>, second says <code>unresolved</code>

As you can see here, although you'd think the var/let holds the content of bar.boy(), Swift somehow can't find it...正如你可以在这里看到,虽然你会觉得var/let保存有bar.boy()的结果,Swift不知何故无法找到它...

 

So it turns out there was probably a bug in the past that when you were adding a Swift file it would add/ask a Bridging header, but it wouldn't add that line to your project因此,事实证明过去可能存在一个错误,即当您添加Swift文件时,它会添加/询问桥接头,但不会将该行添加到您的项目中

SWIFT_OPTIMIZATION_LEVEL = "-Onone";  

which means you'd stay in this state这意味着您将保持这种状态

SWIFT_OPTIMIZATION_LEVEL fastest

resulting in error: <EXPR>:1:1: error: use of unresolved identifier!

I could only find that out because I moved around files in my project and when I added ObjC files to the project, it asked me about a Bridging header (although I had one already!) and luckily added that SWIFT_OPTIMIZATION_LEVEL. One could consider this is a bug to consider the default value is fastest, but then again I guess this was only a bug in the past and got fixed now.

Still, I fixed now it might be a bug the other way around, if it add none in the release build. I can't test this right now because for testing this I only had a Debug build. I'll leave that as an exercise :) for Apple's Engineers.

导致error: <EXPR>:1:1: error: use of unresolved identifier!

我只能找到原因,因为我在项目中四处移动文件,并且在向项目中添加ObjC文件时,它询问我有关桥接头的信息(尽管我已经有了一个),然后幸运地添加了它SWIFT_OPTIMIZATION_LEVEL。可以考虑将默认值设置为fastest,这是一个错误,但是我又想这只是过去的一个错误,现在已修复。

不过,我现在修复了它,如果它添加none到发行版本,则可能是另一种错误。我现在无法测试,因为测试时我只有一个Debug构建。我将其作为练习留给苹果工程师使用:)。

答2

I set Swift Complier to "-O"我将Swift Complier设置为“ -O”

SWIFT_OPTIMIZATION_LEVEL = "-O";  

and set it back to "-Onone".并将其设置回“ -Onone”。

SWIFT_OPTIMIZATION_LEVEL = "-Onone";  

Then it works.

答3

Fixed after setting:

Optimization Level = None[-Onone] under Swift Compiler - Code Generation

Note that setting Optimization Level under Apple LLVM 8.0 - Code Generation has no effect

设置完成后修正:

Optimization Level = None[-Onone]Swift编译器下的代码生成

请注意,在Apple LLVM 8.0-代码生成情况下Optimization Level下的设置无效

答4

I bet that bug is due to the fact that foo has been optimized out during compilation and it's symbol does not exist anymore in the compiled code (even if it shouldn't have in debug and it's still an LLDB bug)

Probably if you add some usage of foo in the next lines (even a println) its symbol will hopefully be kept in the IR and you'll be able to po foo

(I agree that that's still a bug but at least if it works you'll have a workaround and some sense of explanation)

我敢打赌,该错误是由于foo在编译过程中已对其进行了优化,并且其符号在编译后的代码中已不存在(即使它不应该在调试中使用,并且仍然是LLDB错误)。

如果您foo在下一行中添加一些用法(甚至是println),则其符号有望保留在IR中,并且您可以po foo

(我同意那仍然是一个错误,但是至少如果它起作用了,您将有一种解决方法和某种解释力)

答5

If your project is using Swift, there are two separate "Optimization Level" settings in the project/target configuration. Its not only "SWIFT_OPTIMIZATION_LEVEL". Check this link: https://stackoverflow.com/a/32984193/2060180

I'll leave it here in case it's useful to someone.

如果您的项目使用的是Swift,则在项目/目标配置中有两个单独的“优化级别”设置。它不仅是“ SWIFT_OPTIMIZATION_LEVEL”。检查此链接:https : //stackoverflow.com/a/32984193/2060180

如果对某人有用,我将其保留在此处。

友情链接
版权所有 Copyright(c)2004-2021 锐英源软件
公司注册号:410105000449586 豫ICP备08007559号 最佳分辨率 1024*768
地址:郑州大学北校区院(文化路97号院)内