I have upgraded to Xcode 5.0. And when I run an app in debug mode and try to print an NSString
value in console, it gives me the below error. Any ideas?
我已经升级到Xcode 5.0。当我在调试模式下运行一个应用程序并尝试在控制台打印一个NSString值时,它会给我下面的错误。什么好主意吗?
error: warning: couldn't get cmd pointer (substituting NULL): Couldn't load '_cmd' because its value couldn't be evaluated
Couldn't materialize struct: the variable 'stringValue' has no location, it may have been optimized out
Errored out in Execute, couldn't PrepareToExecuteJITExpression
Here is the code:
这是代码:
NSString *stringValue = [[self.responseArray objectAtIndex:i] valueForKey:@"merchant_name"];
4 个解决方案
#1
78
The reason is stated in the error message: it may have been optimized out.. this means that you are compiling and running your code in an optimized manner.
原因在错误信息中说明:它可能已经被优化了。这意味着您正在以优化的方式编译和运行代码。
you gotta change your compiler optimization level from Fastest,Smallest
to none
:
您必须将编译器优化级别从最快的、最小的更改为无:
- go to your target build settings
- 转到目标构建设置
- search for optimization level
- 搜索优化级别
- change it to none (whatever mode you are in ie debugging, distribution or release)
- 将其更改为none(无论您在ie调试、发布或发布中的模式是什么)
- profit
- 利润
do the same for your project settings
对你的项目设置做同样的事情
#2
38
Make sure you are in debug mode. Go Edit Scheme > Build Configuration > Debug
确保处于调试模式。去编辑方案>构建配置>调试
#3
9
You might be trying to debug in the "release Scheme". Go to "Product/Scheme/Edit Scheme" and pick the "run" in the left panel. Then change the build configuration to "debug".
您可能正在“发布方案”中调试。转到“Product/Scheme/Edit Scheme”并在左侧面板中选择“run”。然后将构建配置更改为“debug”。
#4
3
One alternate answer: instead of fixing "it may have been optimized out" by removing the optimization, you can stop it from being optimized by using the variable.
另一种解决方案是:不要通过删除优化来修复“它可能已经被优化了”,您可以通过使用变量来阻止优化。
So, in your question, if you do something with stringValue
:
在你的问题中,如果你用stringValue做某事:
NSString *stringValue = [[self.responseArray objectAtIndex:i] valueForKey:@"merchant_name"];
NSLog(@"%@", stringValue);
stringValue
will no longer be optimized out because you're using it.
stringValue将不再被优化,因为你正在使用它。
If you want to see all instances of optimized-out variables in your project, Use Product -> Analyze to analyze your project. Any "Dead store" warnings (in which a value is stored, and never read) will be optimized out at compile time if you have compiler optimization turned on.
如果您想查看项目中所有优化的变量实例,请使用Product ->分析来分析您的项目。如果打开了编译器优化,那么任何“死存储”警告(其中存储了一个值,并且从未读取)都将在编译时进行优化。
#1
78
The reason is stated in the error message: it may have been optimized out.. this means that you are compiling and running your code in an optimized manner.
原因在错误信息中说明:它可能已经被优化了。这意味着您正在以优化的方式编译和运行代码。
you gotta change your compiler optimization level from Fastest,Smallest
to none
:
您必须将编译器优化级别从最快的、最小的更改为无:
- go to your target build settings
- 转到目标构建设置
- search for optimization level
- 搜索优化级别
- change it to none (whatever mode you are in ie debugging, distribution or release)
- 将其更改为none(无论您在ie调试、发布或发布中的模式是什么)
- profit
- 利润
do the same for your project settings
对你的项目设置做同样的事情
#2
38
Make sure you are in debug mode. Go Edit Scheme > Build Configuration > Debug
确保处于调试模式。去编辑方案>构建配置>调试
#3
9
You might be trying to debug in the "release Scheme". Go to "Product/Scheme/Edit Scheme" and pick the "run" in the left panel. Then change the build configuration to "debug".
您可能正在“发布方案”中调试。转到“Product/Scheme/Edit Scheme”并在左侧面板中选择“run”。然后将构建配置更改为“debug”。
#4
3
One alternate answer: instead of fixing "it may have been optimized out" by removing the optimization, you can stop it from being optimized by using the variable.
另一种解决方案是:不要通过删除优化来修复“它可能已经被优化了”,您可以通过使用变量来阻止优化。
So, in your question, if you do something with stringValue
:
在你的问题中,如果你用stringValue做某事:
NSString *stringValue = [[self.responseArray objectAtIndex:i] valueForKey:@"merchant_name"];
NSLog(@"%@", stringValue);
stringValue
will no longer be optimized out because you're using it.
stringValue将不再被优化,因为你正在使用它。
If you want to see all instances of optimized-out variables in your project, Use Product -> Analyze to analyze your project. Any "Dead store" warnings (in which a value is stored, and never read) will be optimized out at compile time if you have compiler optimization turned on.
如果您想查看项目中所有优化的变量实例,请使用Product ->分析来分析您的项目。如果打开了编译器优化,那么任何“死存储”警告(其中存储了一个值,并且从未读取)都将在编译时进行优化。