Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 20, 2006, 12:03 PM   #1
Soulstorm
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
Problem with xCode please help!

I am programming on carbon framework with xcode 2.2. I am a total beginner in this.

And I want to include an image in a simple window. No buttons, no other stuff

So, I make a resource file from this image uusing graphic converter. I go to my project, and I add the .rsrc file in the "Resources" folder.

I open my .nib file with Interface Builder and I include the image in the main window. I click "Test interface" from the menu of interface builder and everything seems normal.

But when I compile my entire program with XCode, the image does not appear in the window!!

I went to the package contents of my newly built application and saw my .rsrc file in there, only it had 0kbytes size!

What can I do? Am I doing something wrong?

EDIT: Repaired perimissions, updated prebindings, rotated logs and still the same problem...
EDIT2: I tested the same method into another machine and I had the same problem. Is it a bug, or I am making something wrong?

Last edited by Soulstorm; Feb 20, 2006 at 12:40 PM.
Soulstorm is offline   0 Reply With Quote
Old Feb 20, 2006, 12:52 PM   #2
iSee
macrumors 68030
 
iSee's Avatar
 
Join Date: Oct 2004
Just an idea...

Your .rsrc file could be losing its resource fork when it is copied as part of the build process. That would explain its size (0) and the fact that it isn't displayed (.rsrc files have all their content in the resource fork).

You could:
1. Use a different image format that stores the image data in the data fork (png, jpeg)--whatever will work with xcode & interface builder.
2. Find the build step that copies your .rsrc into the package and make sure it preserves resouce forks. I've never poked around in xcode's build process, so I have no help to offer you here.
iSee is offline   0 Reply With Quote
Old Feb 20, 2006, 12:57 PM   #3
Soulstorm
Thread Starter
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
Quote:
Originally Posted by iSee
Your .rsrc file could be losing its resource fork when it is copied as part of the build process. That would explain its size (0) and the fact that it isn't displayed (.rsrc files have all their content in the resource fork).

You could:
1. Use a different image format that stores the image data in the data fork (png, jpeg)--whatever will work with xcode & interface builder.
2. Find the build step that copies your .rsrc into the package and make sure it preserves resouce forks. I've never poked around in xcode's build process, so I have no help to offer you here.
every time that I save a file with an .rsrc extension, it is a PICT resource file. How can I make a resource file that contains .png? Can you show me a program that will help me?

EDIT: Maybe I should rephrase it:
How do I add images into my carbon application? What type must me those images, how do I create them, and what steps do I need to follow in Interface builder?

Last edited by Soulstorm; Feb 20, 2006 at 01:07 PM.
Soulstorm is offline   0 Reply With Quote
Old Feb 20, 2006, 01:06 PM   #4
GeeYouEye
macrumors 68000
 
GeeYouEye's Avatar
 
Join Date: Dec 2001
Location: State of Denial
Send a message via AIM to GeeYouEye Send a message via Yahoo to GeeYouEye
Don't save it as a resource file, simple as that. Save/export it as a PNG.
__________________
I bring order to chaos. You are in chaos Windows, you are the contradiction, a bug wishing to be an OS.
Visit Softyards Software
NEW DEFINITION OF GEEK
Like politics, free speech, computers, entertainment, and more? Join us at Wordforge.net
GeeYouEye is offline   0 Reply With Quote
Old Feb 20, 2006, 01:12 PM   #5
Soulstorm
Thread Starter
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
Quote:
Originally Posted by GeeYouEye
Don't save it as a resource file, simple as that. Save/export it as a PNG.
Excuse my ignorance, but as you can see I am a total noob, and my book ("Mac OS X programming by Dan Parks Sydow") only explains what I must do with resources, and doesn't say anything for any other file types.

I tried what you said too. After that, what do i need to do?

I go to my project, and I with right-click, I add the .png file to my project, in the "resources" folder. But when I open Interface builder, it doesn't show me the image I want to use. How do I use this .png file?

Can you explain me exactly what must I do? And why the expected result is shown in the interface builder when I test my interface, but not in the final program????

Last edited by Soulstorm; Feb 20, 2006 at 01:20 PM.
Soulstorm is offline   0 Reply With Quote
Old Feb 20, 2006, 01:27 PM   #6
Soulstorm
Thread Starter
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
OK now I'm really worried. I did the same thing with a resource file that came directly from apple's example files. It didn't work. It showed the expected result in the Interface Builder, but the final program was missing the resource file...

Help.
Soulstorm is offline   0 Reply With Quote
Old Feb 20, 2006, 01:49 PM   #7
iSee
macrumors 68030
 
iSee's Avatar
 
Join Date: Oct 2004
Quote:
Originally Posted by Soulstorm
every time that I save a file with an .rsrc extension, it is a PICT resource file. How can I make a resource file that contains .png? Can you show me a program that will help me?

EDIT: Maybe I should rephrase it:
How do I add images into my carbon application? What type must me those images, how do I create them, and what steps do I need to follow in Interface builder?
Hmm... I was working with a .nib for a cocoa app, where I could just drag-and-drop a .png file into the images tab of image builder. But this doesn't seem to work the same way for Carbon .nib files. I can't see how to add a .png to a carbon .nib. According to Interface Builder help:
Quote:
Generally, the images are not stored in the nib file itself. Instead, the Images pane displays images that are in the same Project Builder target as the nib file is in. If the nib file is in multiple targets, Interface Builder includes only those images that are in all those targets
This doesn't seem to be the whole story though. I added a .png (and a PICT) to the one-and-only target in a test carbon project. It does not show up in the images tab. Sorry, I don't see how this is supposed to work...
iSee is offline   0 Reply With Quote
Old Feb 20, 2006, 01:57 PM   #8
Soulstorm
Thread Starter
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
Quote:
Originally Posted by iSee
Hmm... I was working with a .nib for a cocoa app, where I could just drag-and-drop a .png file into the images tab of image builder. But this doesn't seem to work the same way for Carbon .nib files. I can't see how to add a .png to a carbon .nib. According to Interface Builder help:

This doesn't seem to be the whole story though. I added a .png (and a PICT) to the one-and-only target in a test carbon project. It does not show up in the images tab. Sorry, I don't see how this is supposed to work...
at least have you managed to import a resource file to the carbon application? Can it happen, or am I not the only one that has the problem?
Soulstorm is offline   0 Reply With Quote
Old Feb 20, 2006, 02:03 PM   #9
gekko513
macrumors 601
 
gekko513's Avatar
 
Join Date: Oct 2003
Is the resource in the Resources folder in the main Xcode window?

If it isn't try to drag it there.
Attached Images
 
gekko513 is offline   0 Reply With Quote
Old Feb 20, 2006, 02:08 PM   #10
Soulstorm
Thread Starter
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
Quote:
Originally Posted by gekko513
Is the resource in the Resources folder in the main Xcode window?

If it isn't try to drag it there.
Yes it is. I think I already mentioned it in my first post.
Soulstorm is offline   0 Reply With Quote
Old Feb 20, 2006, 02:27 PM   #11
gekko513
macrumors 601
 
gekko513's Avatar
 
Join Date: Oct 2003
Quote:
Originally Posted by Soulstorm
Yes it is. I think I already mentioned it in my first post.
That you did. Sorry about that.

What happens if you don't add it in Xcode but only choose File -> Import -> Import Resource File in Interface Builder.
gekko513 is offline   0 Reply With Quote
Old Feb 20, 2006, 02:38 PM   #12
Soulstorm
Thread Starter
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
Quote:
Originally Posted by gekko513
That you did. Sorry about that.

What happens if you don't add it in Xcode but only choose File -> Import -> Import Resource File in Interface Builder.
Absolutely nothing. It prompts me a dialog which says to import a resource. I choose the resource I have made. But in the next dialog, all I see is an empty box, containing nothing that can be imported. This thing is getting weirder and weirder...

What method are you following to import pictures in carbon with interface builder?
Soulstorm is offline   0 Reply With Quote
Old Feb 20, 2006, 02:46 PM   #13
gekko513
macrumors 601
 
gekko513's Avatar
 
Join Date: Oct 2003
I've only used Cocoa. I'm just throwing out some ideas just in case I happen to suggest something you haven't tried.
gekko513 is offline   0 Reply With Quote
Old Feb 20, 2006, 03:14 PM   #14
Soulstorm
Thread Starter
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
Quote:
Originally Posted by gekko513
I've only used Cocoa. I'm just throwing out some ideas just in case I happen to suggest something you haven't tried.
Well I guess that's the price for me to learn C++... Everyone here uses Cocoa and can't help me. In Cocoa i think, there arent such problems, as there are many image formats you can import, such as plain png and jpg files.
Soulstorm is offline   0 Reply With Quote
Old Feb 20, 2006, 03:42 PM   #15
Soulstorm
Thread Starter
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
Sorry for the double post. I figured out what's happening. A guy at apple discussion forums told me what I must do. Damn! I would have never figured this out.

Apparently, many people have this question, since this system is much complicated.

Look at this page:

http://www.meandmark.com/xcodetips.html

in there is says:

Quote:
Using Resources Files with Xcode

I covered this topic indirectly in the book, but using resource files with Xcode and Project Builder has caused problems since Apple released Mac OS X so I decided to place the material here. Resource files were the way to store user interfaces before Mac OS X. They also can store pictures, sounds, and custom data. While nib files have replaced resource files for user interfaces, some programs (mostly Carbon programs) still need to use resource files. Xcode supports resource files, but it makes using them tricky. If you need to use resource files in your program, you must take the following steps:

Give your resource files the extension .r or .rsrc.
Add a Build Resource Manager Resources build phase to your target.
Add your resource files to the Build Resource Manager Resources build phase.
When you give resource files the extension .r or .rsrc, Xcode compiles the resource files in your project, merges them into one resource file, and automatically opens the file when your program launches. If you use a different file extension, you must write code to open the resource file so you can load the file's resources.

The Build Resource Manager Resources build phase compiles the resource files in your project. Unfortunately, none of Xcode's project templates includes this build phase so you must add the Build Resource Manager Resources build phase to your targets. Choose Project > New Build Phase > New Build Resource Manager Resources Build Phase.

When you add a resource file to your project, Xcode adds the file to the Copy Bundle Resources build phase. The Copy Bundle Resources build phases just copies the files to the Resources directory in the application bundle. You must move your resource files to the Build Resource Manager Resources build phase.

Click the disclosure triangle next to a target in the Groups and Files list to see the target's build phases. Click the disclosure triangle next to a build phase to see the files in the build phase. Select a file and drag it to move the file to a different build phase.
Soulstorm is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
XCode 5 DP and Java Problem aquethys Mac Programming 0 Aug 28, 2013 09:59 PM
Xcode OpenGL Ram Problem jmfel1926 Mac Programming 5 Aug 21, 2013 06:06 PM
Problem with XCode 4 .6 Senor Cuete Mac Programming 7 Feb 11, 2013 09:15 AM
After updating XCode, output terminal problem iMacFarlane Mac Programming 9 Oct 3, 2012 11:29 PM
Xcode problem JamesP. Mac Applications and Mac App Store 0 Jul 4, 2012 10:41 AM

Forum Jump

All times are GMT -5. The time now is 10:33 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC