Assets.xcassets disappears in Xcode - xcode

I have a projects that had many many assets that took countless hours to design. One day I went onto my project and my whole assets.xcassets folder is empty. The title is colored red and when I click on it it is just an empty file, no information in it. There is also no file for it in the file view of my project. How do I get it back. It is not in the trash can. It was emptied recently and it may have permanently removed my file. I have not done anything with source control. I never knew what it was. Now I need my assets because most of them were not saved anywhere else. I have also tried using EaseUS Data Recovery to recover it but it did not find the file. What can I do to get it back?

Related

Xcode can't find source files

I'm using Xcode 8. I recently inherited a project with several hundred files (including source and image files). I rearranged them on my local drive and the file names (appropriately) become red in the folder list on the left side of Xcode. I selected files/folders in this folder list, click on the "Hide or show Utilities" button to display the "Identity and Type" pane on the right side of Xcode, clicked on the little folder icon next to the Location, and selected the files'/folders' new locations. The text in that pane was updated to the new location and the file/folder names changed from red to black. So far, so good. I did this to all of the file/folder names until none of them were displayed in red.
However, when I go to build the project, I get numerous warning messages similar to, "image.png /Users/Me/Project/images/image.png is missing from working copy." The path shown in the error message is the file's OLD location. When I look at that image in the file list, it is displayed in black. When I select that file and look at the Full Path in the pane on the right, it shows the file's current location (e.g., "/Users/Me/Project/images/newfolder/image.png"). I'm unsure where in the project the old location is being stored. FWIW, I've tried Cleaning the project...
Thanks for insights.
So here is an approach that is perhaps not for the meek, yet it is something I do more often than one would expect to fix Xcode project files. I tend to be the one designated to do this on the teams I work with ... manually editing the project file. The .xcodeproj file is really just a special folder. The actual project file is project.pbxproj.
First back up the project file. Your choice on if you want to do the complete .xcodeproj or just the project.pbxproj.
Use your favorite text editor and open up the project.pbxproj file.
Search and replace the prefix to your path. For the sake of this exercise, you should try and keep your path as similar as possible to make it easier. For example, if the hardcoded path is /Users/Me/Project/Images/newfolder/image.png and all prefixes are generally "/Users/Me/Project", you can just do a search on "/Users/Me/" or "/Users/Me/Project" (the latter if you want more safety) and replace with "/Users/You/" or "/Users/You/Project". Note I am not searching on "Me" and replacing with "You". You want to search and replace but as controlled as possible.
Once done, save and open the project. If the project doesn't open at all, it means you messed something up. Start over. Note that changing the paths should not be sufficient to break the file. It will probably mean you accidentally added or deleted something.
If the project file opens now build. It should hopefully build.
Okay, so that gets you into a buildable state. Now you really want to fix things. Whomever did the project was a knucklehead for using absolute paths.
This next part will be tedious. There are probably ways to do this manually, but I'll leave that to an exercise for the reader right now. In file inspector within Xcode, you will want to change files to be anything but "Absolute Path". Here is an example, you can see the location is "Relative to Group".
Essentially you are going to have to around to Groups and files and fix things up to not be absolute. Make sure you backup incrementally and can build.
Wait, but unfortunately there is more. You'll then need to go into Build Settings to see if things are absolute paths. Then you'll need to decide how to adjust for that. For example, it is not uncommon for 3rd Party frameworks to be added with absolute paths.
Or I suppose if you want to, you can just get it working and skip the latter part of this and damn everyone else...

View Controller Keeps Disappearing

Whenever I close Xcode and then open it again, some file gets deleted and I have to start all over again. When I checked the file status it says locally deleted. Is there a way I can fix this :
Thanks
There is a possibility that your 'red' files (classes) are not at the same location as they were the last time you opened the project.
Find the files which were red, add them back to your project, and
delete the red links. Assuming, that you haven't deleted them by
mistake. (in case you did accidently - here's a hack)
Check the full path of the missing file or 'Show in Finder'. Can you access it?
If this doesn't help, I found this useful thread when I was using Xcode 4.1 earlier. Check it.

Any explanation for wrong images showing up?

Some background. Until I redo this part of the app, for now, I've dragged a bunch of images into my project. They are called Landscapexx.jpg and Portraitxx.jpg, where xx is a number from 0 to the total number of pictures (minus one) for that orientation.
At some point, I replaced the images used in the project. But the original images are still showing up on my device (but not in Xcode). Using NSLog to confirm which image is being loaded, I then look up the image with the same name in Xcode. Sometimes it's the same image. Sometimes it's not.
At first I thought the problem was that when building the app again the data remained. That would be a reasonable explanation. However, when I deleted the app, acknowledging that the data would be deleted, that did not solve the problem. Could this be a cache issue? If so, how do I clear the relevant cache?
One last thing. The images that appear incorrectly on the iPad have the project name checked in the file inspector.
The way I'm loading the images, by the way is using NSString *newImageName = [NSString stringWithFormat:#"Landscape%d.jpg",n];, for example. So the file simply needs to be in my project space somewhere, I thought. If there are two copies, I have no idea where the second one would be. I don't see them in Xcode.
P.S. If I run the app in the simulator, I get the same images as on Xcode. This suggests the errant images are cached somewhere in my iPad. Since deleting the app didn't take care of the problem, is there something else I can try?
EDIT: I found something that may point to an issue. If I go to the Build Phases screen and open the Copy Bundle Resources item, all the images are listed there. However some of them don't have the ...in projectname after them. These same items have the project checked in the file inspector. Not all the images are this way. What do I need to do to ensure all the files are correctly in the project?
I suggest deleting the app from the phone, cleaning the project, and rebuilding the app. This happens to me on occasion and this usually fixes it.
I figured it out. Going through all the menu options in Xcode, I found an option called Clean in the Product menu. I selected it, rebuilt the app and all is fine now. This option apparently clears out the precompiled stuff that occurs the first time a project is built.

Issues importing xcode project from another computer

I have run into an incredibly frustrating issue. I wrote an iPhone app on one computer, and now I am trying to work on it on another computer. I zipped the project, and sent it to myself, but when I open it, it seems that none of the images came with it. When I was adding the images, I always checked the box to have the images get copied into my project. All the image files show up, but they are in red.
I tried fixing the path of one of the hundreds of images, and after doing that, the image appeared in the typical color scheme of xcode in my project. The problem was when I tried to run the code, xcode said it couldn't find the image I'd just imported.
Next, I deleted all the images, and tried importing them again. Once they were imported, they all turned red again.
Has anyone else run into this issue? Help!
In Finder go to where the actually code is, and see if it did in fact move the images into the project structure.
When the resources are red inside Xcode it means Xcode can not find them you can right click on them and see where it is expecting them to be located. You can also do this after you import images to make sure they are in the project structure.
Usually XCode folder structures have a "resources" folder off of the root of the source code, this is where you should put all images. I usually manually copy them in there, and then just import them into XCode from there.

xcode copying project to another computer

I'm having problems copying a project over from one mac to another. The project compiles and runs fine after being copied, however xcode seems to have some duplicate of the same classes which seem to be invisible on the project browser on the left.
For example if I jump to definition on a variable I get 2 suggestions pop up. The top file when I look at its properties is relative to xcode folder (this is also the one that shows up in the class browser to the left). The second file which cant be seen on the browser has absolute path type in the properties.
Is there any way to get rid of this behaviour so its just looking at one file only like it originally was doing on the other mac? Its a bit problematic as I am never sure which one I am editing and they don't seem to update each other even though they appear to be the same file.
On a side note if I copy the copied project to another location then I get 3 etc files pop up in the jump to definition.
It's usually a good idea to either not copy the "build" folder (or delete it after you've copied everything over - only do this when Xcode is not running though).
Ok so what you need to do is this:
1.Duplicate your project.
2.Open the copy w/the original ,but only the folder.
3.open the Projects files(not the tests the main files)
4.then Drag and drop the files into the xcode area.
5.Zip the folder and its done
its like that because it just removes the references but not the files they are all still there though so just add the references back into the file.

Resources