Re: New Target > Cocoa Framework can't handle .c files. (DO try this at home! -- Easy)
Re: New Target > Cocoa Framework can't handle .c files. (DO try this at home! -- Easy)
- Subject: Re: New Target > Cocoa Framework can't handle .c files. (DO try this at home! -- Easy)
- From: Chris Espinosa <email@hidden>
- Date: Sat, 14 Mar 2009 19:46:17 -0700
The good target uses a prefix file that conditionally #includes
AppKit.h only when building Objective-C code.
The bad target unconditionally uses AppKit.h as its prefix file.
It's a performance vs. flexibility tradeoff. Using AppKit.h as the
prefix file increases the odds of reusing an already-built pch file.
But it limits you to .m or .mm files, or as you discovered, C files
declared to be Objective-C.
Chris
On Mar 14, 2009, at 6:44 PM, Jerry Krinock <email@hidden> wrote:
Easily reproducible:
1. In Xcode 3.1.1, begin a New Project using template Framework >
Cocoa Framework.
2. Add a single, empty .c file to the target.
3. Build. Result: No errors.
4. Add a new Target using template Cocoa > Framework.
5. Set active target to the new target.
6. Build. Result: No errors.
7. Expose the Target Membership checkbox.
8. Add the empty .c file as a member to the new target.
9. Build. Result: 1495+ errors, implying that Objective-C language
support has been turned off. See details below [1].
Comparing the Build Settings for these two targets, I found two
differences, in Precompiled Headers and in Other Linker Flags.
However, when I copied the settings from the bad target to the good
target, cleaned-with-precompiled both targets, and rebuilt both,
still the good target is good and the bad target is bad.
In both targets' Build Settings, GCC_INPUT_FILETYPE is set to
'automatic' ("According to file type"). Seems like that should work.
Of course, the reason why I'm writing this is that, in real life, I
have a Objective-C project with many .m files and one .c files. I
attempted to factor out a framework target, added all files, and,
three hours later, I've isolated the problem as explained above.
And then I found a workaround. Get Info on the empty .c file. Its
File Type is sourcecode.c.c. Change it to sourcecode.c.objc and now
it will compile in either target. Obj-C is a superset of C, so this
should work. But it doesn't make sense.
What is going on here? What could be different between these two
targets??
Jerry Krinock
[1] Beginning of Build Transcript of bad build:
Building target “BadTarget” of project “MyFramework” with
configuration “Debug”
Checking Dependencies
SymLink /Users/jk/Documents/Programming/Builds/Debug/
BadTarget.framework/Versions/Current A
mkdir /Users/jk/Documents/Programming/Builds/Debug/
BadTarget.framework/Versions
cd /Users/jk/Documents/Programming/Projects/MyFramework
/bin/ln -sf A /Users/jk/Documents/Programming/Builds/Debug/
BadTarget.framework/Versions/Current
SymLink /Users/jk/Documents/Programming/Builds/Debug/
BadTarget.framework/Resources Versions/Current/Resources
cd /Users/jk/Documents/Programming/Projects/MyFramework
/bin/ln -sf Versions/Current/Resources /Users/jk/Documents/
Programming/Builds/Debug/BadTarget.framework/Resources
SymLink /Users/jk/Documents/Programming/Builds/Debug/
BadTarget.framework/BadTarget Versions/Current/BadTarget
cd /Users/jk/Documents/Programming/Projects/MyFramework
/bin/ln -sf Versions/Current/BadTarget /Users/jk/Documents/
Programming/Builds/Debug/BadTarget.framework/BadTarget
Processing /Users/jk/Documents/Programming/Builds/Debug/
BadTarget.framework/Versions/A/Resources/Info.plist BadTarget-
Info.plist
mkdir /Users/jk/Documents/Programming/Builds/Debug/
BadTarget.framework/Versions/A/Resources
cd /Users/jk/Documents/Programming/Projects/MyFramework
<com.apple.tools.info-plist-utility> BadTarget-Info.plist -
expandbuildsettings -o /Users/jk/Documents/Programming/Builds/Debug/
BadTarget.framework/Versions/A/Resources/Info.plist
ProcessPCH /var/folders/PR/PRtZlutkFa82jPnfdYcUUk+++TI/-Caches-/
com.apple.Xcode.501/SharedPrecompiledHeaders/AppKit-
eoalerwxvykaylafwennbjjbdmct/AppKit.h.gch /Developer/SDKs/
MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Headers/
AppKit.h normal i386 c com.apple.compilers.gcc.4_0
cd /Users/jk/Documents/Programming/Projects/MyFramework
/Developer/usr/bin/gcc-4.0 -x c-header -arch i386 -fmessage-
length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks
-O0 -Wreturn-type -Wunused-variable -isysroot /Developer/SDKs/
MacOSX10.5.sdk -mfix-and-continue -mmacosx-version-min=10.5 -
gdwarf-2 -iquote "/Users/jk/Library/Application Support/Xcode/
IntermediateBuildFiles/MyFramework.build/Debug/BadTarget.build/
BadTarget-generated-files.hmap" "-I/Users/jk/Library/Application
Support/Xcode/IntermediateBuildFiles/MyFramework.build/Debug/
BadTarget.build/BadTarget-own-target-headers.hmap" "-I/Users/jk/
Library/Application Support/Xcode/IntermediateBuildFiles/
MyFramework.build/Debug/BadTarget.build/BadTarget-all-target-
headers.hmap" -iquote "/Users/jk/Library/Application Support/Xcode/
IntermediateBuildFiles/MyFramework.build/Debug/BadTarget.build/
BadTarget-project-headers.hmap" -F/Users/jk/Documents/Programming/
Builds/Debug -I/Users/jk/Documents/Programming/Builds/Debug/include
"-I/Users/jk/Library/Application Support/Xcode/
IntermediateBuildFiles/MyFramework.build/Debug/BadTarget.build/
DerivedSources" -c /Developer/SDKs/MacOSX10.5.sdk/System/Library/
Frameworks/AppKit.framework/Headers/AppKit.h -o /var/folders/PR/
PRtZlutkFa82jPnfdYcUUk+++TI/-Caches-/com.apple.Xcode.501/
SharedPrecompiledHeaders/AppKit-eoalerwxvykaylafwennbjjbdmct/
AppKit.h.gch
In file included from /Developer/SDKs/MacOSX10.5.sdk/System/Library/
Frameworks/Foundation.framework/Headers/Foundation.h:12,
from /Developer/SDKs/MacOSX10.5.sdk/System/Library/
Frameworks/AppKit.framework/Headers/AppKit.h:10:
/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/
Foundation.framework/Headers/NSObjCRuntime.h:124: error: syntax
error before '@' token
/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/
Foundation.framework/Headers/NSObjCRuntime.h:126: error: syntax
error before '*' token
<snip>
/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/
AppKit.framework/Headers/AppKit.h:180: confused by earlier errors,
bailing out
*****************************************
Build failed (1495 errors)
The first of the 1495 errors is at this line in AppKit.h:
@class NSString, Protocol;
Perusing some others, it's apparent that the compiler doesn't
understand any Objective-C.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden