Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / September 2004



Tip: Looking for answers? Try searching our database.

#import questions with Cocoa/Cocoa.h and SMySql/SMySql.h

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Van Bagnol - 28 Sep 2004 06:02 GMT
I am still new to Xcode, having come from using CodeWarrior, and am
building the CocoaMySQL application from the source to get my feet wet.
I'm a little unfamiliar with the layout of the new IDE.

The build command in the project file is telling me it can't find the
file imported by "#import <SMySQL/SMySQL.h>" -- however, it _is_ able to
find "#import <Cocoa/Cocoa.h>". As far as I can tell, both files can be
found and viewed in the project, yet neither file is, technically, in
the subdirectory specified in the #import directive. E.g., I do have a
file named Cocoa.h which Xcode can display in its edit pane, but it's
not in any subdirectory named Cocoa, but rather resides in:
"/System/Library/Frameworks/Cocoa.framework/Versions/A/Headers/".
Similarly, I have a file named SMySQL.h but it's not in a subdirectory
named SMySQL but rather in "~/Development/CocoaMySQL source/
SMySQL.framework/Versions/A/Headers/".

What I don't understand is why Xcode's #import directive can find one of
the .h files but not the other. What's the deal with #imported filenames
that contain slashes, and are they literally subdirectories or are they
package/frameworks, and what's the convention for them? Where in the IDE
can I set the search path for included files and system included files?

Van
Signature

Van Bagnol / n p c o m p l e t e at bagnol dot com / c r l at bagnol dot com
...enjoys Theatre / Windsurfing / Skydiving / Mountain Biking
...feels "parang lumalakad ako soo loob ng panaginip"
...thinks "An Error is Not a Mistake ... Unless You Refuse to Correct It"

Sherm Pendley - 28 Sep 2004 06:34 GMT
> What I don't understand is why Xcode's #import directive can find one of
> the .h files but not the other. What's the deal with #imported filenames
> that contain slashes, and are they literally subdirectories or are they
> package/frameworks, and what's the convention for them?

They're frameworks. The first part of "#import <Cocoa/Cocoa.h>" - i.e.
the part before the slash - is the name of the framework without the
extension, and the second part tells it what file to look for in that
framework's Headers/ subdirectory.

> Where in the IDE
> can I set the search path for included files and system included files?

That's probably not what you want to do here.

Just add the CocoaMySQL framework to your project. Choose the
"Project/Add to Project ..." menu item, and add the CocoaMySQL.framework
directory, *not* the individual files inside that directory. That will
not only add the framework's Headers/ subdir to the preprocessor search
path, it will also link the dynamic library that's in the framework to
your app.

(If memory serves, older versions - I'm using Xcode 1.5 - had a slightly
different layout for the "Project" menu, with separate "Add framework
..." and "Add files ..." items. Same idea though... you want to add the
framework to your project as a unit, not the individual files inside of it.)

sherm--

Signature

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

Frédéric Testuz - 28 Sep 2004 06:42 GMT
> > What I don't understand is why Xcode's #import directive can find one of
> > the .h files but not the other. What's the deal with #imported filenames
[quoted text clipped - 22 lines]
> ..." and "Add files ..." items. Same idea though... you want to add the
> framework to your project as a unit, not the individual files inside of it.)

I want just add that depend on which version of SMySQL (dynamic, static,
...) you take perhaps you will have to change either the #import
<SMySQL/SMyQL.h> to #import <SMySQL_bundled/SMySQL.h> or edit the name of
the file. At least it was the case for the last time I used CocoaMySQL.

Signature

Frédéric Testuz

Van Bagnol - 28 Sep 2004 15:53 GMT
> > What I don't understand is why Xcode's #import directive can find one of
> > the .h files but not the other. What's the deal with #imported filenames
[quoted text clipped - 5 lines]
> extension, and the second part tells it what file to look for in that
> framework's Headers/ subdirectory.
[...]
> Just add the CocoaMySQL framework to your project. Choose the
> "Project/Add to Project ..." menu item, and add the CocoaMySQL.framework
> directory, *not* the individual files inside that directory. That will
> not only add the framework's Headers/ subdir to the preprocessor search
> path, it will also link the dynamic library that's in the framework to
> your app.

That's what's puzzling. In my project, in the folder marked
"CocoaMySQL->Frameworks->Linked Frameworks" of the "Groups & Files"
pane, both Cocoa.framework and SMySQL.framework are included. I can
clearly see both
"...Frameworks->Linked Frameworks->Cocoa.framework->Headers->Cocoa.h"
and
"...Frameworks->Linked Frameworks->SMySQL.framework->Headers->SMySQL.h"
listed in the pane. Clicking either one of the files displays the source
code in the .h file. Yet when I tried to compile a module containing
#import    <Cocoa/Cocoa.h>
#import    <SMySQL/SMySQL.h>
The compiler/preprocessor accepts the first #import but not the second.
Changing the line to
#import    "SMySQL/SMySQL.h"
doesn't seem to make a difference.

I'm guessing that the only thing different is a search path somewhere
letting the compiler find the Cocoa framework in /System/Library but not
the SMySQL framework in ~/Development/..../<myproject>, despite the IDE
being able to find both files.

BTW, this is the exact set of project files unstuffed from the
CocoaMySQL source code download, so would think all the project
components are complete and in their correct relative locations.

Van
Signature

Van Bagnol / n p c o m p l e t e at bagnol dot com / c r l at bagnol dot com
...enjoys Theatre / Windsurfing / Skydiving / Mountain Biking
...feels "parang lumalakad ako soo loob ng panaginip"
...thinks "An Error is Not a Mistake ... Unless You Refuse to Correct It"

Glenn Andreas - 28 Sep 2004 17:55 GMT
> > > What I don't understand is why Xcode's #import directive can find one of
> > > the .h files but not the other. What's the deal with #imported filenames
[quoted text clipped - 37 lines]
> CocoaMySQL source code download, so would think all the project
> components are complete and in their correct relative locations.

When you "add library" it doesn't update the include search path (and,
in fact, if you've installed OS SDK support, it actually looks in
/Developer/(where ever the OS SDK live) rather than /System/Library for
frameworks as well).

Normally, libraries live somewhere that the default include search path
already covers, so there is no problem, but since you're using one that
isn't, you'll need to manually update it (somewhere in the build
settings panel).
Van Bagnol - 29 Sep 2004 00:14 GMT
> > > > What I don't understand is why Xcode's #import directive can
> > > > find one of the .h files but not the other. What's the deal
[quoted text clipped - 10 lines]
> > > "Project/Add to Project ..." menu item, and add the CocoaMySQL.framework
> > > directory, *not* the individual files inside that directory.
[snip]

> > That's what's puzzling. In my project, in the folder marked
> > "CocoaMySQL->Frameworks->Linked Frameworks" of the "Groups & Files"
[quoted text clipped - 3 lines]
> > and
> >  "...Frameworks->Linked Frameworks->SMySQL.framework->Headers->SMySQL.h"
[snip]
> > I'm guessing that the only thing different is a search path somewhere
> > letting the compiler find the Cocoa framework in /System/Library but not
[quoted text clipped - 14 lines]
> isn't, you'll need to manually update it (somewhere in the build
> settings panel).

Well, I manually added the SMySQL.framework to the project (so now
there's two of them) which finally got the app to compile, build (albeit
with some duplicate symbol warnings), and run.

However, it's warning me that certain directories don't exist, e.g.,
/Users/ide/developer (apparently from the original uploaded
configuration). I can't seem to find where those directories are
specified. I do seem to remember a instance when I was able to examine
the project's plists (I recall seeing the names of those nonexistent
directories listed somewhere) but I can't figure how to get back to it
again.

Van
Signature

Van Bagnol / n p c o m p l e t e at bagnol dot com / c r l at bagnol dot com
...enjoys Theatre / Windsurfing / Skydiving / Mountain Biking
...feels "parang lumalakad ako soo loob ng panaginip"
...thinks "An Error is Not a Mistake ... Unless You Refuse to Correct It"

Heath Raftery - 29 Sep 2004 01:22 GMT
>> > What I don't understand is why Xcode's #import directive can find one of
>> > the .h files but not the other. What's the deal with #imported filenames
[quoted text clipped - 12 lines]
>> path, it will also link the dynamic library that's in the framework to
>> your app.

> That's what's puzzling. In my project, in the folder marked
> "CocoaMySQL->Frameworks->Linked Frameworks" of the "Groups & Files"
[quoted text clipped - 11 lines]
>  #import    "SMySQL/SMySQL.h"
> doesn't seem to make a difference.

> I'm guessing that the only thing different is a search path somewhere
> letting the compiler find the Cocoa framework in /System/Library but not
> the SMySQL framework in ~/Development/..../<myproject>, despite the IDE
> being able to find both files.

This was mostly answered elsewhere, but I did want to reiterate a possible
source of frustration. I had almost the same problem as you over the last
couple of days, except the preprocessor was happy with
#import <Security/Authorization.h>
but not
#import <Security/AuthorizationDB.h>
#import <SecurityInterface/SFAuthorizationView.h>
the latter of which was the one I was actually after. This was despite the
fact that I had added all the frameworks, and could clearly see the
headers listed under the frameworks. In a moment of sudden clarity, I
realised this was because I was targetting the OS X 10.2.8 SDK, and the
headers I was after did not exist under
/Developer/SDKs/MacOSX10.2.8/System/Library/Frameworks/

So just a word of warning to all, which I hope saves someone some time -
make sure the frameworks you add are available in the OS you are
targetting!
Signature

*--------------------------------------------------------*

| ^Nothing is foolproof to a sufficiently talented fool^ |
|    Heath Raftery, HRSoftWorks          _\|/_           |
*______________________________________m_('.')_m_________*
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.