Build error when using iOS6 If Statement in xCode 5 Project

烈酒焚心 提交于 2019-12-25 02:18:48

问题


I am building a project in XCode 5 with Deployment Target 6.1 and SDK 7.0 but I am getting an error on this line:

 if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {

The error says *Use of undeclared identifier 'NSFoundationVersionNumber_iOS_6_1*


回答1:


Your code should work in iOS7. Please cross check your Base SDK version once again.

Project Target -->Build Settings -->Base SDk

Its a part of Foundation.framework NSObjCRuntime.h class. So make sure you have the Foundation.framework under Project Target -->Build Phases -->Link Binary With Libraries section.

If it's not availabe, click on the + button and add the Foundation.framework in to your project.

Note:

This can happen when you try to run code built for iOS 7 Base SDK on Xcode 4.x, or if you compile against an older Base SDK in Xcode 5.

The solution is to define what isn’t defined manually using a Macro. Add this to every class that’s complaining and you should be fine.

#ifndef NSFoundationVersionNumber_iOS_6_1
#define NSFoundationVersionNumber_iOS_6_1 993.00
#endif

This tells the compiler to define the value if it’s not there, so it has no reason to complain.



来源:https://stackoverflow.com/questions/21247319/build-error-when-using-ios6-if-statement-in-xcode-5-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!