tags:

views:

2274

answers:

4

Hi all,

I've upgraded the iOS SDK to the newly released 4.1 and now I have the following error while building my app:

/DeveloperBeta/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFContext.h:60:23     

/DeveloperBeta/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFContext.h:60:23: error: expected function body after function declarator

Looking at that line in the .h file I see the following:

CG_EXTERN void CGPDFContextAddDocumentMetadata(CGContextRef context, CFDataRef metadata) CG_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_0);

The really interesting thing is the define __MAC_10_7 which appears not to be defined anywhere. I get this error when pre-compiling the .pch file of my app.

What's curious is that a simple hello world app compiles.

Any idea what can I do?

Thanks in advance!

Stelian

A: 

Maybe you should be building with the latest Xcode 4, is this a requirement? The MAC_10_7 would be defined in the system headers shipped with the compiler I'm guessing could be in the SDK but I think not. I'm guessing this is when you build for the simulator.

Tony Lambert
+2  A: 

I have this problem when using the LLVM compiler. Try recompiling using GCC and the problem (for me) goes away.

I'll keep investigating to determine if it is a general toolchain issue or if it's specific to my configuration.

--update:

So it looks like an issue with CLANG. LLVM GCC 4.2 works fine.

I still think it is likely a problem with my configuration. Even an empty project will not compile under LLVM CLANG 1.5 for me.

--update 2:

So it seems that the minimum required version setting is not being honoured in the project info settings. I've manually set it via:

Other C Flags: -D__IPHONE_OS_VERSION_MIN_REQUIRED=031300

(for minimum of iOS 3.1, obviously - if you require a later version then you can use 040100 for version 4.0)

It does seem only to be a simulator problem with CLANG/LLVM. Compiling for the device directly seems to work just fine.

Grumpy Chuck
Compiling for device instead of simulator works.
toofah
Even with the min required flag set in 'Other C Flags', I can't get this to work for the simulator. :(
toofah
+29  A: 

This is a known bug with the iOS 4.1 SDK and building using LLVM for the iPhone Simulator. You can read all about it in this thread on Apple's Developer Forums.

The recommended solution is to add the following to Other C Flags in your project's build settings: -D__IPHONE_OS_VERSION_MIN_REQUIRED=040100 where you replace 040100 with your deployment target version (030000 for 3.0, for example).

Brad Larson
Fixed it for me - cheers.
Mark Beaton
Fixed it for me as well. Many thanks!
Stelian Iancu
Got errors when using eg 030100 (for 3.1), changed to 30100 which works fine!
avocade
A: 

Depressingly, none of this works.

You have to simply use crappy old GCC .......... and that's that.

Even with the "other C flag" solution, I was still able to exhibit the problem - the compiler would throw totally whacky errors on for example the ASI_HTTP library, bizarre things like "found two, expected three arguments".

Joe Blow
I still get this even with GCC, with the analyzer enabled :(
Kevlar