Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

More on distinguishing Carbon from Cocoa System
There was a hint here (see the below section for the original text), but I have removed it due to the confusion it was likely to cause. Read the comments to this (and the article referenced below) for a lot of conversation on Cocoa vs. Carbon.

Personally, I don't pay much attention to the differentiation -- I just use what apps I need to use; if it does what I need it to do, I don't care if it was written in RealBasic ;-).

Sorry for the bum hint ... sometimes it happens!

-rob.

Original hint text - please ignore and read the comments...
It was interesting reading the back-and-forth arguments about whether Terminal was Carbon or Cocoa (and thus affected by the option-scrolling "feature"). There are a couple ways to tell if an app is Cocoa by using Get Info.

A Carbon app will have an check box in General Information to "Open this app in Classic environment." Also, only Cocoa apps have the "Language" option in Get Info.

Another way to check is to use a Control-click on an app. If it has an option to "See Package Contents," then it's a Cocoa app.
    •    
  • Currently 4.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[6,799 views]  

More on distinguishing Carbon from Cocoa | 27 comments | Create New Account
Click here to return to the 'More on distinguishing Carbon from Cocoa' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Are you sure?
Authored by: kyngchaos on Jul 05, '02 11:27:02AM

I've seen Carbon apps that don't have the "Open in Classic" option (tho I think there's a way to hack that option to be available). Illustrator 10 is an example here - it doesn't have the option, but I KNOW it's carbon.

And, I see many Carbon apps that have language options. Again Illustrator 10 is one, as well as Photoshop 7 (which DOES have a "Classic" option, also).

And, Show Package Contents? Same here. A Carbon app can be a Package.



[ Reply to This | # ]
Are you sure?
Authored by: Fraki on Jul 05, '02 01:40:12PM

Agreed - these rules don't seem to be hard and fast. Internet Explorer is a package, it has a 'Languages' section in Get Info, and it won't open in Classic - but I believe it's Carbon, since it's affected by Silk.



[ Reply to This | # ]
Are you sure?
Authored by: Brainstyle on Jul 05, '02 03:47:08PM

grep Terminal.app and you'll find files in there that refer to NSApplication - the Cocoa class for all apps. I can't think of a reason why this would be in a Carbon app.

Besides, Terminal's been around since the days of NeXTStep - way before Carbon ever existed. So why would they port it to Carbon?



[ Reply to This | # ]
Are you sure?
Authored by: marcwic on Jul 10, '02 04:29:11AM

Open process viewer, anything called LaunchCFMApp is a carbon app.

Then open top, and look at the process ID in process viewer, and look for it in top, to see the real name.



[ Reply to This | # ]
Services menu
Authored by: RichB on Jul 05, '02 11:27:02AM

Another quick check is to see if the Services menu under the Apple has items since they are only available in cocoa apps.



[ Reply to This | # ]
Services menu
Authored by: dierauer on Jul 05, '02 12:06:55PM

This one isn't foolproof, either. BBEdit, which is a Carbon app, shows services.



[ Reply to This | # ]
Services menu
Authored by: RichB on Jul 05, '02 01:10:54PM

BBEdit is a special app! I wonder if there are other exceptions?



[ Reply to This | # ]
Services menu
Authored by: Fraki on Jul 05, '02 01:33:13PM

Services are not exclusive to Cocoa apps.



[ Reply to This | # ]
Services menu
Authored by: sth on Jul 05, '02 03:16:18PM

Since 10.1 the service-API is accessible via Carbon.



[ Reply to This | # ]
Wrong!
Authored by: Arkham on Jul 05, '02 02:46:45PM
"A Carbon app will have an check box in General Information to "Open this app in Classic environment." Also, only Cocoa apps have the "Language" option in Get Info."

Not everytime. Just take a look at Internet Explorer or Roxio Toast.

"Another way to check is to use a Control-click on an app. If it has an option to 'See Package Contents,' then it's a Cocoa app."

Hey! You could make app packages even under Mac OS 9.

Yous should check your facts.

[ Reply to This | # ]
Test it with Silk
Authored by: mumkin on Jul 05, '02 03:03:34PM

Well, several things which I thought to be characteristic of cocoa apps seem to be disputed here. Bottom line, however, is that if you're using Silk you can just drag an app into Silk's pref pane and it will tell you if it's carbon or cocoa.<p>FWIW, according to Silk Terminal.app is cocoa.



[ Reply to This | # ]
Lay off the crack
Authored by: KrazyFool on Jul 05, '02 04:30:18PM

1. Nothing you said was correct
2. The only way I can think of to get a 99.9% correct answer is to use Silk.
3. Have a nice day.

KF



[ Reply to This | # ]
Actually....
Authored by: Rosyna on Jul 05, '02 04:49:15PM
Neither of these items will show you. If you want to *really* know if an application is cocoa or not, a Cocoa application will have something like the following in it's Info.plist file:
	<key>NSMainNibFile</key>
	<string>Fire-macintosh</string>
	<key>NSPrincipalClass</key>
	<string>NSApplication</string>
A Carbon Application will not have the NSMainNibFile entry and will not say "Classic Application" in the get info window. But then neither will a Java Application.

[ Reply to This | # ]
Actually....
Authored by: hjeff on Sep 07, '03 01:57:08PM

Here's a simple shell command contribution. Gives a thumbs-up or down on whether it finds an NS string anywhere in a application folder (Program.app). I made it return a 1 or a 0 so it could be used with other programs easily, but season to taste.

#!/bin/sh
fileIn=$1
cocoaCount=`grep -rIh 'NS' "$fileIn" | wc -l`
if [ $cocoaCount -ge 1 ]
then
    echo 1
else
    echo 0
fi


[ Reply to This | # ]
Actually....
Authored by: hjeff on Sep 10, '03 04:02:15PM
I can't figure out how to edit that old entry, but here's a better version of the above (the one above gave false positives) :
#!/bin/sh
filein=$1
cocoaCount=`grep -rIh 'NS' "$filein" | grep -v Java | wc -l`
javaCount=`grep -rIh 'Java' "$filein" | wc -l`
if [ $cocoaCount -ge 1 ]
then
        echo "cocoa"
elif [ $javaCount -ge 1 ]
then
        echo "java"
else
        echo "carbon"
fi


[ Reply to This | # ]
oTool
Authored by: bhines on Jul 05, '02 06:42:33PM
You can use "otool -L" to see what an app links against. Any app which links against AppKit+Cocoa.framework is Cocoa:
ben% otool -L /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal: /System/Library/PrivateFrameworks/AppSupport.framework/Versions/B/AppSupport (compatibility version 1.0.0, current version 52.0.0) /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 7.0.0) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 16.0.0) /System/Library/PrivateFrameworks/HIServices.framework/Versions/A/HIServices (compatibility version 1.0.0, current version 64.0.0) /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 217.0.0) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 226.0.0) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 619.0.0) /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 423.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 55.0.0)
If otool fails, like:
ben% otool -L /Applications/Internet Explorer.app/Contents/MacOS/Internet Explorer /Applications/Internet Explorer.app/Contents/MacOS/Internet Explorer: is not an object file
It is a CFM app and is obviously not Cocoa. A Carbon Mach-O app would look like:
ben% otool -L /Tex-Edit Plus.app/Contents/MacOS/Tex-Edit Plus /Applications/Applications/Tex-Edit Plus 4.2.4 ƒ/Tex-Edit Plus.app/Contents/MacOS/Tex-Edit Plus: /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 122.0.0) /System/Library/Frameworks/QuickTime.framework/Versions/A/QuickTime (compatibility version 1.0.0, current version 142.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 55.0.0)
Note that many Cocoa apps also link Carbon:
ben% otool -L /Applications/Applications/Watson.app/Contents/MacOS/Watson /Applications/Applications/Watson.app/Contents/MacOS/Watson: /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 7.0.0) /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 122.0.0) @executable_path/../Frameworks/GeneralTool.framework/Versions/A/GeneralTool (compatibility version 1.0.0, current version 1.0.0) /System/Library/Frameworks/Message.framework/Versions/B/Message (compatibility version 1.0.0, current version 482.0.0) /System/Library/Frameworks/ExceptionHandling.framework/Versions/A/ExceptionHandling (compatibility version 1.0.0, current version 4.7.0) @executable_path/../Frameworks/CURLHandle.framework/Versions/A/CURLHandle (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 55.0.0)
However, Carbon Apps *CAN* use Cocoa stuff, If they load a Cocoa bundle dynamically. It is kinda tricky, but it was demoed at WWDC 2002. Pretty cool stuff.

[ Reply to This | # ]
Re: oTool
Authored by: Rosyna on Jul 06, '02 12:23:12AM

Right, and if a Carbon app links to cocoa, you'd get the same thing ;)

I have a few "Tools" that link to both CoreServices (carbon) and Foundation (Cocoa) Using the method described, people would think they are Cocoa.



[ Reply to This | # ]
Moderation?
Authored by: Anonymous on Jul 05, '02 08:27:18PM

I was under the impression that hints were moderated before being posted to the site.

This one is so fantastically wrong that it should really be removed so as not to confuse people.



[ Reply to This | # ]
Yes, but I don't know everything...
Authored by: robg on Jul 06, '02 02:01:52AM

I test things out and hope they're right when the test agrees with the hint as submitted. Sometimes (like here, it appears), I screw up.

I'll edit the hint and change the body to refer to these comments, and then capture the original in the "remainder" section for original references...

Sorry, but I can't possibly be right 100% of the time ;-).

-rob.



[ Reply to This | # ]
A very simple test
Authored by: sabi on Jul 05, '02 10:35:09PM
Posted this last time the topic came up, but people seem to have no memories around here... :-) Hold down the mouse button in a dialog box or window with a default (blue, pulsating) button. If the button stops animating, then it's Carbon, otherwise it's Cocoa.

[ Reply to This | # ]
A very simple test
Authored by: Rosyna on Jul 06, '02 12:31:28AM
This is sadly right in every app I've tried. It's also true if you press the help key in Cocoa apps, the cursor changes to a question mark. If you can click an immediately drag text, it's a Carbon Application. If you have to click, hold, wait, then drag, it's a Cocoa application. If you can immediately drag a proxy icon, it's Cocoa and if not, it's Carbon (the opposite of text dragging)

When I say Cocoa and Carbon application, I mean the main event loop is NSRunApplication (the cocoa event loop) or WaitNextEvent or RunApplicationEventLoop for Carbon.

In the future applications may be able to mix these, in that case, you could probably only tell if a single window is carbon or cocoa.

[ Reply to This | # ]
A very simple test
Authored by: Anonymous on Jul 11, '02 11:39:44AM

Unfortunately, it's even worse than that. You can hold down the mouse on virtually any UI element anywhere in the operating system and the Aqua default button will stop pulsating in Carbon apps. Single-threaded crap or what!? :-)



[ Reply to This | # ]
Carbon vs Cocoa using file
Authored by: oeyvind on Jul 05, '02 10:58:11PM
Try this instead?


% file /Applications/Internet Explorer.app/Contents/MacOS/Internet Explorer
/Applications/Internet Explorer.app/Contents/MacOS/Internet Explorer: CFM binary
% file /Applications/Mail.app/Contents/MacOS/Mail
/Applications/Mail.app/Contents/MacOS/Mail: setgid Mach-O executable ppc

Cocoa App == Mach-o executable ppc
Carbon App == CFM binary

[ Reply to This | # ]
Carbon vs Cocoa using file
Authored by: Rosyna on Jul 06, '02 12:20:02AM
file /Applications/AppleScript/Script Editor.app/Contents/MacOS/Script Editor /Applications/AppleScript/Script Editor.app/Contents/MacOS/Script Editor: Mach-O executable ppc
Carbon apps can be Mach-O too ;)

[ Reply to This | # ]
Carbon vs Cocoa using file
Authored by: GaelicWizard on Jul 06, '02 04:16:58AM

Apple has a habit of doing things so wonderfully that it makes absolutely no sense at all. This is yet another example.



[ Reply to This | # ]
The best way...
Authored by: Magino on Jul 05, '02 11:11:12PM

... to distinguish between apps, IMHO is XRay.
Included with the app is a contextual menu plugin. Just cntr/right-click the application, and a menu pops up ... towards the bottom will be Xray <app name>. And, that's all there is to it. End of story. Simple. Fast. Accurate.



[ Reply to This | # ]
He meant this
Authored by: Frungi on Apr 06, '06 12:50:46AM