iOS Show some error about PNG image - iphone

I am using Xcode 4.3.3, I already tried to build my app before and it run. But now I arranged my files inside my project's folder, grouped them by 'button' , 'icon' , 'background'... I also copied some resources/images in other folder put them in order but now I'm in trouble.
Im trying to build my app again in Xcode, I found a CopyPNG Error:
Can't find /Users/vella/Desktop/Sample/res/2.png
Command /Users/vella/Desktop/installer/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/PrivatePlugIns/iPhoneOS Build System Support.xcplugin/Contents/Resources/copypng failed with exit code 1
Now, I don't know if I missed some png files. I also read some answers like I should save PNG files as NOT INTERLACED or there is a PNG file that is corrupted. How will I know what PNG file is missing or corrupted?

Check wheather you added 2.png into your project folder.while adding images into your project,click the checkbox "Copy items into destination group folder".If your png file is corrupted, it will be in red colour in your project.

You have to save your PNG files as NOT INTERLACED. For example, bu using Photoshop, go to menu File->Save For Web and Devices. Unchecked the box of 'Interlaced' and save the file. Usually interlaced box is unchecked already. Hope that helps

Clean up the png file in your project and re-import it:
Delete (backup) that file in project navigator. Just delete and move file to trash can.
Go to project Build Phases:
i. Select the root project
ii. Select TARGETS
iii. Select Build Phases tag
iv. Expand Copy Bundle Resources list
If you see the file you just deleted still exists (maybe in red), delete it
Re-import the file again
This worked for me.

Yep, Add it again and this time dont arrange or rearrange any stuff in your resources folder.
Also give specific naming to the images so that its easy for you to remember and implement them later in ur project.

I just had the same problem. I always do the same thing to add images to my projects but I never had a problem like this before.
I found in the error message that, the image path that Xcode was trying to find the image was wrong. The path that Xcode is searching was like " ...../My Project Folder/images/favourites.png" but the correct path is like "...../My Project Folder/myProjectName/images/favourites.png". To solve this, I create a folder with path " ...../My Project Folder/images", then I backed up my images and deleted all of them from project window and selected "move to trash". I copied and pasted the images from my backup folder to this new folder. Then I drag-dropped them to "Supporting Files" and select "Copy items into destination group's folder (if needed)". Finally I cleaned the project and run it. It worked for me. Good luck.

Related

CopyPNGFile error

When I archive the application I get CopyPNGerror for all images in my project.I tried all means deleting all the images,adding them again,check Build Phases(copy bundle resources).No duplicates are found.I couldnot understand what to do further and submit the app.When I archive another application with same images archive is successful
CopyPNGFile "/Users/admin/Library/Developer/Xcode/DerivedData/App1-auevnkwujohdqtflzyputmxbvrmt/Build/Intermediates/ArchiveIntermediates/App/InstallationBuildProductsLocation/Applications/App1.app/about2 copy.png" "Classes/../about2 copy.png"
cd "/Users/admin/Documents/App/App (1)"
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/copypng -compress "" "/Users/admin/Documents/App/App (1)/Classes/../about2 copy.png" "/Users/admin/Library/Developer/Xcode/DerivedData/App1-auevnkwujohdqtflzyputmxbvrmt/Build/Intermediates/ArchiveIntermediates/App/InstallationBuildProductsLocation/Applications/App1.app/about2 copy.png"
Could not open output file /Users/admin/Library/Developer/Xcode/DerivedData/App1-auevnkwujohdqtflzyputmxbvrmt/Build/Intermediates/ArchiveIntermediates/App/InstallationBuildProductsLocation/Applications/App1.app/about2 copy.pngCommand /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/copypng failed with exit code 1
What shall I do to solve this error?
Solved here -> https://stackoverflow.com/a/18297130/1451462
I removed the duplicate references in my png files!
Build Phases -> Copy Bundle Resources
and removed all the duplicated entries of lunch images DefaultXX.png
I had the same problem, in my case the image causing the problem was a JPG renamed manually in PNG.
I suggest you to open the image in a Image Editor (Gimp, Photoshop...) and save it as PNG.
i face this problem an i solved as #Davide answer
you need to remove any reference for that image
after that clean and build and problem will be fixed
To solve this issue open your image (about2 copy.png) in photoshop or gimp or any similar image editor.
While saving(save as) your image check it as NOT INTERLACED.
Build your project again will remove the error.
I have this happen periodically, my solution, copy the images away, delete them from xcode, then copy them back. Fixes it every time.
Delete the file reference from xcode -> click your project -> Build Phases -> Copy Bundle Resources. Then, add the file again to your project.\
or
Build Settings -> Search for Compress PNG Files and set to NO .
or
You have to save your PNG files as NOT INTERLACED. For example, by using Photoshop, go to menu File->Save For Web and Devices. Unchecked the box of 'Interlaced' and save the file. Usually interlaced box is unchecked already.
In my case, I just removed the "$" character from the image name.
My case was that, I have image called imagex.png, then I removed that image and added one called imagex$xxx.png, then I got that error, everything went well when I just removed the dollar sign from the name.
Delete the file reference from xcode -> click your project -> Build Phases -> Copy Bundle Resources. Then, add the file again to your project.
I had the same problem. I have fixed it.
In my case. This error occurs because I have multiple files with the same name. To fix this. I delete remove the files from my project and the import again. Instead of create a group in project. I create a folder reference and everything works great as I expected!
Just remove the image file from the Xcode project, rename it as you want on FINDER and then readd it to you project. I just had this problem a while ago.
This is due to copy of image of same name in Project.
if there are icons in the exact path. you should check that all the icons are really png . just open icons in some editors and save as the icon in png format
Found those images are red in color in project.Simply deleting & readding them worked.
Just try deleting the .png extension for the files which are causing you the trouble.
Don't know how, but worked for me!

How to change location of iPhone app icon?

Okay, I am a noob. It must be simple but I stuck here.
I do rigth-click and choose 'select file'.
After I choose the file the dialogue appears:
I want to keep my icons not in the root directory. But I can't figure out how to do this. I tried different ways, even create project from scratch...
Please help.
When you bring image assets into Xcode they will all be in your application bundle's root directory at run time.
It appears that you've added a file named "icon#2x.png" to your project at one time already. Go to the project's summary page in Xcode click Build Phases and then expand the section titled Copy Bundle Resources. There you'll find the reference to the resources that will be copied to your bundle at run time.
More on bundle structures here:
https://developer.apple.com/library/mac/#documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html
Anyway, the way I've done this in the past is to:
Remove the existing image duplicate from Xcode and from the folder structure in Finder.
Add a new folder in Finder call it "/AppIcons" (or whatever).
Copy all the app icons to that folder in Finder.
Drag the "/AppIcon" folder into your XCode project. I typically put images in an "/Images" subdirectory in the Xcode project. Again you can put it wherever you'd like.
In Xcode on the project summary panel, add your app icons from the folder "/AppIcons" by dragging / dropping or by right clicking and adding them as separate files.
Alternatively in the past when I've had problems with this sometimes Xcode will copy the app icons to the root project directory. If that happens, I make sure that I have the "/AppIcons" folder structure on disc (in Finder) and in my Xcode project. I add the app icons to the project, then move them to /AppIcons in Finder, and re-reference them all over again.
Your Copy Bundle Resources should then have the proper file reference. Note that my apps icons go in "/Images/AppIcons"
Good luck!
I would add the image files to your project with the name icon#2x.png. To do this right click where you want to add the files in xcode and click add file/s. Then search for your image and add them using the dialogue that pops up. - there is a check box so that you can either copy them to the projects destination folder which will copy them into you project folder or leave it unchecked (inadvisable) which would reference it's current location on your HDD. Make sure the file doesn't already exist in the project before doing this!
EDIT:
Sorry I forgot to mention then drag and drop the file from within xcode onto the image location box.
In XCode 4 (I'm using 4.6.2) you will get this confusing message if you've just moved the target's info.plist file, but not corrected the location at the top of the summary panel. Fix this and the icons will reappear, assuming they are added to the project, or if not you should now be able to drag them in without xcode insisting on making extra copies.
This tends to happen when you're starting a project and sorting out the mess of default file locations that xcode gives you. I like my project structure to be 99% the same as the file system structure.
This is an easy fix. If the image you want as your App Icon resides outside of the root of your project, when you get that dialog just click "Yes", and then click delete on the newly created file in the root, and "Move to Trash".
The reference is still there and works without a hitch, since the file will still be in the root at runtime

How to correct missing files in xcode iOS project

I have a project with some missing files. The files are their own folder on the same level as the iOS app project folder. Not sure why but the files are showing up as "missing"
Is there something I can do to the Library Search Paths (see screenshot below) so they find them correctly?
fyi: I inherited the project, so it was just sent to me. I try to build it and get all those files missing.
thanks for any help :)
It's nothing to do with library search paths, they are used to find libraries to compile against; they're nothing to do with source files contained within your project.
They are missing because your project file is trying to reference a location for the file that doesn't exist. You have two options:
If you have all the missing files on hand in Finder, you can delete the references to them in Xcode, and re-import them. Do this by dragging them back into the project from Finder.
You can instead 'fix' your project file, to have it refer to the right place. To do this, use the File Inspector on the right, and under Location, select the 'box' icon (not sure what it is, but select it), and relocate your file.
open the folder in which these files are present then drag and drop the missing files in you project. check the "copy items into destination group's folder(if needed)", choose "create groups for any added folders".
Remove these files from the project view (list on the left side), drag them back into the project and make sure you don't select Copy to project, but you also have to check which target to put in.

Changing app target name makes PNGs disappear?

Trying to change the name of the app from the development name to the production name, I renamed the target as a first stab. The PNGs in the app disappeared. I then changed the target name back to the original name and re-built, but now the PNGs are still missing.
I'm looking at step-by-step guides on project/app name changing, but I don't want to proceed until I'm unable to undo whatever this did.
Does anyone know why the images would now be missing? Even after I changed the name back?
I'm assuming there is some path based on the target name and that changing the target name triggered other changes not reversed by simply changing the target again?
Many thanks
why not just use Product Name under Target -> Build Options. So you don't have to change the target name! :)
Type in the name of your project in the finder, and double click on the project folder. Inside that folder (it may be in a folder inside that folder, like resources or something but on my computer its all in the project folder) look for .png images. These images are the images that are in your project. Delete every image inside here, or just move it somewhere else. If your app has the .png files inside the project folder, but the files are in your resources folder, you won't be able to put in the same image in your resources folder because your project (your app) says its already there, even though its just sitting there and your not using it...
So delete all the .pngs inside your project folder, then open up the app with xcode and drag the image files you need into the resources folder. Hope this helped.
Each file in a project can be included in a target, when you changed the target name, its possible that png files lost association to the target. right click on the folder which has the png files, and click on get info, there you will be able to select which targets this folder is included in, mark the check box for your intended target, and the files will be included again in your target.

Problem removing and re-adding an image file into my iOS4 app bundle

My problem is something that should be so simple it is mind boggling. When I change the look (in PhotoShop) of an image file that is being stored in my app bundle. My method for replacing the old image in the bundle with the new one is this:
1) remove the old image from the app bundle (choosing to also move to trash)
2) drag the new image into my file hierarchy in xcode (choosing to copy to app directory)
when I do this, the app cannot find the image no matter what I do. The new images have the same name as the old images but none of the image loading methods (imageNamed, imageWithContentsOfFile, nibs) work. (Although I believe nibs also load with imageNamed, i'm not sure).
Is there something that I am missing here? I feel like it should be a relatively simple process but I am having all kinds of trouble. I also make sure to delete the app off of the target device and clean all targets before rebuilding and running after changing the image files just in case.
Any help would be appreciated.
Thanks
Your problem is probably that the image is not copied to the target. In xcode groups & file pane, fine the node for targets, expand your app target and you'll see Copy Bundle resources expand it and you'll see all the files copied to the default resource bundle when you deploy your app to the sim/device. Only the resources found there will be available to your app. If you don't see your image there you can just drag it there and everything will work.
Now, in order to understand why this might happened we need to look at the different options for adding files to xcode.
When you're adding a file to xcode you are presented with a dialog that includes a few interesting and sometimes overlooked option.
The first - Should the file be copied to the project folder, or should it just point to the file original location. The safest way will be to always copy the files to the project's path. However for images (such in your case) I do it differently. I maintain a separate graphics folder for every app, I save images there (both sources, and final png). When I add an image I do not copy it to the project folder, rather xcode just points to its location. That way I can just edit the image in photoshop, do a rebuild, and the updated image will show up on the phone. Whats important to understand that the directory structure of files you include in the project have almost no meaning, files that appear in the Copy Bundle Resources for the target will always be copied to a single (and flat) bundle/"directory" on the phone. The only exception for this is if you actually add directories to xcode (Personally I recommend against it).
The second option when adding files, is to which targets to add the file. This is the list with checkboxes on the bottom, if when you added the image, your app target wasn't checked the file won't be included in the target Copy bundle resource, and won't be available for the phone.
A few caveats - When using references to files in other location, that location is relative to the project's path, so it's a good idea to keep all the files in directories below the project's root directory. That way you can still copy the entire project to a different location and it will still work.
Great advice above: I thought I would add more for future searches on this topic:
I was adding and removing images to the project just like above:
Remove the old image from the app bundle (choosing to also move to trash).
Drag the new image into my file hierarchy in xcode (choosing to copy to app directory).
However when I tried to drag the new image with the same name to my file hierarchy in xcode I was getting an error that this was not allowed.
Turns out when I was removing the old image Xcode was removing it from the project file hierarchy but the actual file wasnt being removed from the project's root directory.
I solved my problem by removing the image from the project's root directory and added the image again!
Do you put your images in a custom sub-folder? If you just drag in images into the Xcode project tree, if you copy them, the images will be copied to the root of the project directory, instead of the "Images" or other folder you might have set up.
Note that you can right-click on the image in your bundle, select "Get Info..." and reset its location, if it has been moved or copied to a folder you didn't expect.