简体   繁体   中英

Build error when using iOS6 If Statement in xCode 5 Project

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*

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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