Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

blakintosh

macrumors member
Original poster
May 26, 2008
78
0
Ok, when I drag and drop an image to my iphone app project in xcode, it asks me if I want to make a copy.

What's better to create a copy or just centralize it in another separate folder and when I'm done everything will be wrapped up by xcode?

I believe that at the end there is some kind of png optimization and I don't want the unoptimized png files to stay on the app at the end because this would be useless

thanks in advance
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
What's better to create a copy or just centralize it in another separate folder and when I'm done everything will be wrapped up by xcode?
Create a copy. Because otherwise when the app is deployed to a device, it won't be there. Xcode does not wrap files into an app bundle that are included by reference.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
Hmmm, I don't think I've ever used that create a copy feature.

I have a Resources folder in my project folder. I put all my images and other resource files in that folder. I add them to my project just like a source file. They're automatically added to the copy bundle resources build phase and end up in the bundle.

That seems simple enough.
 

blakintosh

macrumors member
Original poster
May 26, 2008
78
0
Hmmm, I don't think I've ever used that create a copy feature.

I have a Resources folder in my project folder. I put all my images and other resource files in that folder. I add them to my project just like a source file. They're automatically added to the copy bundle resources build phase and end up in the bundle.

That seems simple enough.

So you know for sure that the images will be added at the end even if I don't copy them?

thanks!
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
Works for me.

If you look at the Copy Bundle Resources build phase in your project you'll see the files that it's going to copy into your bundle. And of course you can open up the app bundle in your build folder to look at it.
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
PhoneyDeveloper, could you elaborate on how you are adding files to your Resources folder? Just so I can be clear and help to understand the difference between your approach and what blakintosh is probably doing. Are you doing this via Finder or Xcode? If Xcode, are you using Add > Existing Files...?
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
I add the image files to the Resources folder in the Finder. I then add those files to the project by dragging them in from the Finder.

What does the create a copy do?
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
What does the create a copy do?
Just like what it says: it creates a copy of the file in your bundle rather than simply referencing it from another location (which is something you would normally do for frameworks, for example). If you use Add > Existing Files... and check the "Copy items into destination group's folder (if needed)" option, Xcode creates a copy of the file in your bundle and adds the file to the project in one step. (Also, it leaves a copy of the file in the original location, of course).
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
OK, I see.

When you say bundle you really mean project folder.

I'd never want it to do that. I almost never want an image file to be at the root of my project folder. That's what the Resources folder is for.
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
When you say bundle you really mean project folder.
Yeah, that's right. What resides in the project folder gets put into the bundle upon compilation, of course.

I'd never want it to do that. I almost never want an image file to be at the root of my project folder. That's what the Resources folder is for.
Yeah, it would be nice if Xcode better handled adding files to subfolders of the project folder. I wish it could better detect when a group is also a folder. When I right-click on the Resources group (which is also a folder) and add files, I'd love for them to be added to the folder as well.
 

TodVader

macrumors 6502a
Sep 27, 2005
596
0
Quebec, Canada
I just drag images from finder to the resource folder in xcode and check the "copy". It adds it to the Resources folder of my app and keeps the original file.

I thought everyone did it like that...?
 

blakintosh

macrumors member
Original poster
May 26, 2008
78
0
I just drag images from finder to the resource folder in xcode and check the "copy". It adds it to the Resources folder of my app and keeps the original file.

I thought everyone did it like that...?

thats what I think, so it just came to my mind that why does that option of "do you want a copy or not" exists and what is the difference at the end when you finish your app
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
I just drag images from finder to the resource folder in xcode and check the "copy". It adds it to the Resources folder of my app and keeps the original file.
Actually, that's not exactly correct. And I must apologize!; upon further investigation I realize I've been confusing the matter even further with my talk of groups vs. folders. An (iPhone) project, by default, contains a Resources group but not a Resources folder. So, when you move or copy files to Resources in Xcode, it is not actually placing them in a subfolder in your project folder; they're just added at the project folder level.

I seem to recall that if you wanted an actual subfolder in your project, you will have some extra work to do and then, I believe, you'll need to make sure all your references to files in the subfolder are adjusted accordingly. Actual folders will show up with blue icons in Xcode, groups are tan-colored. In the end, unless you're really anal about your file organization within your project folder, it's extra effort for little return.

Hope that helps and again, sorry, for adding to the confusion.
 

TodVader

macrumors 6502a
Sep 27, 2005
596
0
Quebec, Canada
I guess so. I never go check my files with finder. If I want one in Finder, I'll right click on it in xcode and click on "Reveal in finder"

It always worked fine like that for me. I'm reaalllly not anal about file placement, I'd rather give more time to actually programming :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.