move xcode project causes red text (missing files from project) - ios

When I move iphone project directory to a new path.
There are some red texts indicate the missing files from the project source codes.
How to avoid these?

Here is how to locate the missing (red) files using the Xcode 4 interface:
Select the file or files in the left hand Project Navigator (the folder icon)
In the right sidebar click on "File Inspector" which is the leftmost icon resembling a page
In the "Identity and Type" section, there is a grey box labeled "Location".
Click on the small icon to the lower left that resembles a file browser - this will come up with a file browser to locate the file.
Voila, you are done.

Xcode 7
1.) Right click on the red (missing) file.
2.) Select "Show File Inspector"
3.) Look at the right hand side of the screen under "Identity and Type" between "Location" and "Full Path"
4.) Click on the folder icon to the right of the file name.
5.) Navigate to the file's new location in the pop-up window and select the file.

I encountered this issue when copying my project from one mac to another.
The solution for me:
assuming your files are grouped (in folder)
from xcode open the group in file inspector
The group will probably be missing the absolute path.
press the little icon nearby to pick the folder to associate the group with.
restart xcode to see the changes.

I had the same problem, when I changed the permission on the files/folders to everyone read/write they then appeared in Xcode.

This worked on a Pod project. Quit XCode.
rm -rf project.xcworkspace/xcuserdata/*
Restart XCode and reopen project.

In Finder, create a duplicate of the project directory just in case all goes squiffy.
In Finder, open the project directory that contains all the files with red references
For all the red files you see in XCode, except the info.plist file (see step 5 below), highlight them in Finder and drag them from Finder to XCode's project navigator. i.e. import them.
In XCode's "Choose options for adding these files" window: a) Select Copy items into Destination's group folder (if needed)
b) Select Create groups for any added folder
c) Select Add to Targets, and press Finish
Highlight and drag the info.plist file from Finder to Project Navigator and repeat step 4 WITHOUT selecting Add to Targets
If you had groups in Project Navigator (e.g. Supporting Files), reorder the files to be in the right places.
Delete the original bad red references in Project Navigator, and Cmd-Shift-K to clean for good measure.
Build and run on a device to remove the bad reference to the .app file

you just have to locate the missing file press in file icon in the identity and type you will find the full path just locate your file where do you move it click the file icon

When you create these files be sure to save in your app directory. Or if you import classes from other project be sure to check the copy option.

I dont know if this is the main reason but when you are importing files to the application, do you mary the "Copy items in to destination group's folder (if needed)" ?
this make sure the file is not only referenced but added to your project folder and ir will move any where you move your project.

Did you move files in to folders directly in your project folder and not in xcode?

This worked on a Pod project.
go into finder and project.
right click on your project .xcworkspace and click show package contents
right click on contents.xcworkspacedata and open with textEdit then make sure file path is correct. If project has been moved this can change
I also did this below but now sure if you need it
Quit XCode.
rm -rf project.xcworkspace/xcuserdata/*
Restart XCode and reopen project.

If you create an Xcode project, then move the .xcodeproj file or the newly created project folder to a different folder using Finder, subsequent builds may show many missing files which still reference the original folder locations (which no longer exist because you moved them). These missing files can appear as red text or as issues in the Issue Navigator.
This can happen when Xcode is configured to automatically add or remove files to/from source control (under Xcode > Preferences > Source Control). When configured this way, simply creating a project in Xcode causes new project folders and files to be marked for addition to source control. When you later move the project folder or .xcodeproj file these pending adds now point to missing files.
To resolve this issue when Subversion is the source control program, revert the pending adds for the phantom items from your local working copy folder. In my case this requires dropping into a Terminal window, navigating to the parent of the phantom project folder, then reverting the automatic add, e.g.
cd /my-working-copy-folder
svn status --depth infinity
svn status --depth infinity existing-parent-folder/phantom-project-folder/
svn revert --depth infinity existing-parent-folder/phantom-project-folder/
Note that the first svn status command will list both missing files as well as properly added, modified or deleted files which you must take care to avoid reverting. The second status command is "practice" for the final revert command, to ensure you've specified the proper path to revert.
I do not know git but I assume it offers corresponding commands.

It's too simple to do :
Close the project that includes the missed files and open the Xcode, go to "Organizer">"Projects" and remove the project from the list there. Open your project from Finder and that's it.
hope this help.

Related

/Products/Debug-iphoneos/: No such file or directory Xcode 8 [duplicate]

Xcode keeps prompting telling me I don't have a certain image in the project and it errors when I try to build. If I deleted the .png Xcode is complaining about from the project, why does Xcode error out when I try to build?
[Edited by Rhubarb (got too big for the comments)]
I'm getting the same thing with these details. The copy command looks like this
CpResource MyIcons/../13-bicycle.png /Users/Me/Library/Developer/Xcode/DerivedData/MyProject-cxsohyxdecdbptgrrtaixbhhixrj/Build/Products/Debug-iphonesimulator/MyProject.app/13-bicycle.png
then there's a bunch of setenv and the command is translated to "builtin-copy" but none of that matters, the result is when I compile I get this error:
error: /Users/Me/Development/MyProject/MyIcons/../13-bicycle.png: No such file or directory
Now, I opened the Copy Bundle Resources tab as suggested by Robert Harvey, and my .png is there, with nothing appearing in read. And it is in the file system (Finder) and in the Project Navigator. So I deleted it from the resources using the - button and added it manually using the + button at the bottom left of the list in the Copy Bundle Resources tab. This put it at the root of the project in the Navigator, so I moved it into my group again - but no luck, same error. So I just deleted it altogether (from the Project Navigator, allowing it to be moved to Trash). That worked, but I ran into the same error with the very next icon (it only reports one or two at a time).
Looking at the error message, it appears to think that MyIcons is a folder. It's not, it's just a group. There is no such folder, I can see in the file system.
When I added via drag-drop, I left the "Copy items into ... group folder (if needed)" checked and the "Create groups for any added folders" button selected. But note that I only dragged icons (en masse) into an existing group; I did not drag over any folders, nor where any groups or folders created. But somehow, the compiler thinks that these resources are in a folder in the file system that doesn't exist.
I right clicked the icon in the Copy Resources List and tried both Show in Finder and Reveal in Project Navigator: and both worked - the file is there and it knows where to get it - until it builds.
I haven't even found a workaround beyond deleting the icons yet - cleaning doesn't work. I think my group is corrupted.
look up here XCode Build – CopyPNGFile Error and No Such File or Directory .
I had same problem and this solution helps me.
If you receive either of these annoying errors when building your
xcode app, something has corrupted in your project bundle.
Open your project in Xcode
Click on your project
Click on your project under Targets
Hit the build phases tab
Open “Copy Bundle Resources” near the bottom
Look for any resources listed in red!
I had the same problem but my solution was a bit different:
Open project in Xcode
Open project navigator
In the filter down below, search for your erroneous file name
I found the file under a group called "Recovered References" and it was marked in red
Delete the red files and everything should work perfectly
Okay here's the unsatisfactory workaround that fixed it for me.
(First, note that when I right-clicked my dodgy Group in the Project Navigator) it looked like any other group except that Open in External Editor was greyed - weird eh?)
I closed XCode and restarted it.
=> Now I see all of the icons under the offending group are red (in the Project Navigator)
Delete the entire group.
Create a new group (same name) and drag-drop the icons from the original source into the group
=> Error failed to copy (or some such - I can't remember but I have seen and fixed this before - and seen it elsewhere on SO)
This error is due to leftover icons, so to fix this one now,
I deleted all other groups with icons and moved their icons to trash
open finder at the project location
delete every icon in the project (sort by kind, delete all the .png)
make a new group again, and drag all the icons in _again.
whew, now hit Builder
=> XCode crashes.
Lovely.
Restart Xcode
fingers crossed: Build
=> it works. Brief celebration and back to work.
(See what I mean about unsatisfactory)
perhaps you move the file named **-Prefix.pch,you can change the dictionary of the file ,do like this : the error about “no such file or directory”
Check your project file paths. If there is a space in any of the folders, it causes this error. Simply remove spaces.
Using XCode 10, I got this error after deleting some files I no longer needed in my project.
In my case, I went to XCode, clicked on the project name, then under Resources, the missing files were listed in red. All I did was to delete them.
In case you need the files, you will need to add them by going to File ->Add files to , then select the files. After selecting the file, make sure you have Copy files if needed checked.
Hope that helps someone.
HappyCoding
try set target CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS=NO
XCode Build – CopyPNGFile Error and No Such File or Directory
If you receive either of these annoying errors when building your xcode app, something has corrupted in your project bundle.
Open your project in Xcode
Click on your project
Click on your project under Targets
Hit the build phases tab
Open “Copy Bundle Resources” near the bottom
Look for any resources listed in red!

Error: no such file or directory

My project was working perfectly fine. I then moved some files around from the project's root directory to some subfolders. Now, when I try to run the app, I receive this error message:
<unknown>:0: error: no such file or directory:
'/Users/anapaix/Desktop/currencyExchange/CommentsController.swift'
And I receive this same error for all 20 of the files that I moved around.
Additionally, the files now show up in red like this in my project:
When I double click the file, an empty Swift file shows up, like there is nothing inside. I have a feeling there should be some easy fix to this, in order for Xcode to recognize these files, but just have no idea what it would be.
You moved the files. Xcode doesn't know that. You need to tell Xcode where the files are. (Note: the other answers work too, but if you don't want to remove them and add them again, you can use this method)
Select your red file(s), open the File Inspector (Option+Command+1), and click the folder (circled in red in the below screenshot). Then find your file(s) and click Choose. The filenames should go back to being black.
If multiple red files are in the same folder, you can select multiple files in the Project Navigator (left column, Command+1), click the folder icon in the File Inspector (still the one circled in red, but the text will be different; it might say "multiple selected" or something) and click the folder containing the files. Xcode should automatically detect all of them, provided the filenames haven't changed.
Go Xcode->File->Add Files... and add missing files to the project.
when you move any file in finder from the projewct workspace then xcode doesn't recognize the new path automatically, and xcode consider it as deleted. So,Please remove this files that are in red colour in your explorer.
Then again drag the files from the finder in to your project.
This way your project found the new file path of files for the compling.

Accidentally removed xcassets file from Xcode project

I wanted to remove a single folder from the image collection, however, I somehow managed to throw the entire xcassets file into the trash.
The normal 'Put back' method is not available, and simply dragging the deleted folder to Xcode yields an error:
"Images.xcassets" couldn't be copied to "ProjectPear" because an item with the same name already exists.
To save the file, either provide a different name, or move aside or
delete the existing file, and try again.
I'm not sure where this collection is located within my Xcode project, as the navigator doesn't appear to show anything, and the command-line isn't dropping any hints either. I'm afraid to mess around with the project.pbxproj file, as it might jumble up a lot more than just my image collection.
Edit:
Dragging the files back to Finder from Trash was successful, however, the Xcode navigator no longer recognises - or in this case, still doesn't recognise - the .xcassets file. I'm not sure whether to add something in the .pbxproj file.
I just did this myself and figured out how to quickly remedy the issue.
Go to the project folder in the Finder. You should find that the
folder Images.xcassets is still there.
Move it to a separate location like to the Desktop or something. It
still has all of the images and json files.
Jump back to Xcode and create a new asset catalog for images.
File > New > File... > Resource > Asset Catalog
Name it Images.
Quit Xcode and return to the Finder.
Copy the folders from within your old Images.xcassets to the new
Images.xcassets directory in your project.
Launch Xcode and you're back in business!
If you didn't delete it completely, you can just drag it back in from Finder. (Right click your project and select 'Reveal in Finder' to check)
If it's gone completely you simply go Cmd+N -> Resource and select Asset Catalog. You then re-add your imagages via drag and drop or right-click and 'Add Files to ...' and should be good to go.
Hope that helps.
Usually the file's reference is removed from Xcode, the original folder still exists in the project directory.
Right-click on your project folder, click "Add files to "your project"", find Assets in your project and click Add and you're
done
Had the same problem today with Xcode Beta, I also couldn't create a new assets catalog for some reason.
This was on a Watchkit Extension Project
Here's what I did to solve it:
In finder I copied an existing images.xcassets from another folder in my app to my desktop.
Removed the content of this folder.
Copied a deleted (single) Image Asset from my trash into the folder (on my desktop).
Dragged the entire folder into my project in XCode.
That fixed it and everything went back to normal.
If you have deleted it completely, then also these are the steps to get a new Images.xcassets:
In the Navigator, click on the project.
Go to : File>New>File> Add Asset Catalog> Name it.
To add AppIcon and LaunchImage in it:
Go to the Project Setting:
In General Tab, Slide down to App Icons and Launch Images
Click option next to App Icons Source and select Use Asset Catalogs
A window will pop up- select the name of your new Images.xcassets file and click on Migrate.
Select Also add LaunchImage. Now you can see the new Images.xcassets in your project :).
I accidentally deleted the reference to the asset folder so that it was no longer visible in Xcode. But when I checked from the finder, the asset folder was still in the project folder.
If you did that, just open the file menu in Xcode (from within your current project) and at the very top you can add (existing) files to that very project (back again) - it says "Add files to..."
Right click on anything in your project and click "Show in Finder". Search around in your project folder in the finder for a bit and you'll find it. I'm not on a Mac right now, or I'd give you a more direct path straight to the default .xcassets folder location.
And anyway, if you're not able to copy/create a "new" folder in that location because "an item with the same name already exists", then that means you didn't actually delete the folder. You just deleted your project's references to that folder in XCode. The folder on your hard drive didn't go anywhere.
[I realize this is a very old question from you #Aeveus]
All the answers talk about re-doing the adding assets again. Given you could not undo, the one step that is missing in your original description is this:
In your project.pbxproj file, there would have been references to assets as below:
45AE4E781C183FBA0051674F /* Assets.xcassets in Resources */ = {...
Assuming you have source code control system (git, etc) you can revert to the original contents of your project.pbxproj file, or manually just re-add the deleted lines, and re-open the project file in xcode. You are all set now.
I had the same problem. Open your XCode Project. Just go to File -> Add Files to...(your Project) -> Assets.xcassets and you are good to go!
I had same problem and I have followed the steps above from Jason, but finally i got Image.xassets in red color, so the in order to find my images I had to click in Image.xassets and then on the top right corner put the absolute path to my image.xassets folder and it fixed my problem.
Hope it helps!

Interface Builder could not open the document ".storyboard" because it does not exist

This problem is getting me really crazy. Xcode is looking for a storyboard in my project in a differente location from my project. I tryed removing the file, adding it again, cleaning the project, etc but didn't have luck.
This is the error.
cd /Users/fmartin91/Projects/loovin/loovin-ios
setenv IBSC_MINIMUM_COMPATIBILITY_VERSION 7.0
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
setenv XCODE_DEVELOPER_USR_PATH /Applications/Xcode.app/Contents/Developer/usr/bin/..
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/ibtool --errors --warnings --notices --minimum-deployment-target 7.0 --output-format human-readable-text --compile /Users/fmartin91/Projects/loovin/loovin-ios/Build/Products/Debug-iphonesimulator/loovin.app/Base.lproj/LOOVProductIndex.storyboardc /Users/fmartin91/Projects/Base.lproj/LOOVProductIndex.storyboard
/* com.apple.ibtool.errors */
/Users/fmartin91/Projects/Base.lproj/LOOVProductIndex.storyboard:
error: Interface Builder could not open the document
"LOOVProductIndex.storyboard" because it does not exist.
I could fix this bug by killing ibtoold:
$ sudo killall -9 ibtoold
Why does ibtool need a daemon anyway?
Your storyboard is not in NSBundle mainbundle.
this problem is probably due a "Copy Bundle Resources" in "Build phases" problem.
For corrected it verify if your storyboard file is in "Copy Bundle Resources" for all targets. On project navigator select the project file select Build phases tab and check it is.
When you upload your file to google drive without zip, it appends the extension of .storyboard to .xml automatically and hence when you download it obviously the file won't exist.
To solve this issue, go to the:
[project folder] > [Project folder] > [Base.lproj]
There would be a .storyboard.xml extension type of file which you would have to rename it to the .storyboard extension. And hence your work is done.
Story board error solving visual guide:
I had a very similar problem and it took a few hours to resolve. Clearly xcode locked itself in some strange state that the project explorer could see the xib file while the compile could not. Finally this got resolved when I changed the Location in the File Inspector from Relative to Group to Relative to Project. I got this by comparing the project.pbxproj file in a regular text editor to search for any clues.
I encountered this same issue and here's how I resolved it:
Save a copy of the affected file outside of the project
Delete the file from the project, selecting Move to Trash to completely delete the file and reference from the project
Edit ProjectName.xcodeproj/project.pbxproj to remove all lines referencing the affected file
Re-add the file, making sure to check Copy items into destination group's folder (if needed)
Clean and build
I just ran into this issue running Xcode 9.2. I had copied my files from a school computer onto google drive and then downloaded them at home.
When I opened the files at home it kept telling me main.storyboard and the launch storyboard did not exist. The two storyboard files would display as xml, so they clearly existed, but even right clicking to "open as" produced nothing. After much troubleshooting I found a fix that worked for me.
SOLUTION:
Open your project folder, then the next folder named the same as your project. Open Base.lproj and you will see your two storyboards in xml format. Copy both the files, paste them into the same folder, delete the .xml and confirm the change to .storyboard. Do this for both files and you're set!
This happened to me after a git merge. I changed some storyboard localized files from one project to another and Xcode seems to keep on searching the file in the old project.
My solution was:
Edit the OldProjectName.xcodeproj/project.pbxproj
Search for the Storyboard name
Delete the references to the Storyboard name that appear followed by localization stuff (things like "Base.lproj", "es.lproj", etc)
Delete also the following localization entries (because they refer to the Storyboard file)
Clean and build
Repeat if other files keep throwing compile errors
For me I use xcode 10,
Click on the your project name (blue icon on left) > Build Phases > Under Copy Bundle Resources
Find the file, remove the duplicates if it’s there. Clean project and run again
I encountered same problem when moving the project to another computer. I followed below steps to solve this issue:
Open previous Main.storyboard file as Source Code, copy all
Create a new Main.storyboard file, Open as Source Code, paste
Delete previous Main.storyboard
Clean and build project.
In my case I found that the storyboard was placed in a group that referenced a folder that did not exist in the "Identity and Type" panel.
Removing that group and the storyboard, and adding it back referencing an existing folder solve the problem for me.
For me resetting the container folder of Main.storyboard file worked
I resolved this by doing this:
Open your Xcode project folder in finder, then find the file that you can't open.
Drag that file to your file path in Xcode Project (Inside Xcode App) like this.
Thick "copy item if needed" and choose "create folder references" and then click finish.
Restart Xcode
I could solve my issue, i really don't know how i did it but the things i tried were cleaning and building the project like a billion times, i hope this will be of help to anyone.
I just experienced this, and fixed it by restarting the darn computer. I found out more about it, though. In my case, my ibtool scripts weren't working, giving file-not-found errors just like yours. However I noticed a change in behavior when I ran them as sudo:
2013-09-20 20:49:40.339 Interface Builder Cocoa Touch Tool[58454:303]
CFPreferences: user home directory at
file:///var/root/Library/Application%20Support/iPhone%20Simulator/User/
is unavailable. User domains will be volatile.
Subsequent commands would fail or return without doing anything. So! ibtool/Interface Builder/whatever is somehow using some other launching service to run itself, with some other username or privileges.
Could it be that I installed some tool updates for Xcode 5.0, and it screwed up whatever serving process was running? Yes it could :)
I experienced the same situation with Xcode 7 beta 5. Rebooting my Mac did the trick.
Goto Build Phases > Copy Bundle Resources > Check for the Storyboard for which you are getting error > It should be displaying as blurred > If YES then delete its reference and add it again > Compile again.
In my case, folders in the project navigator and finder were not formed exactly the same. The Main.storyboard was in \Views folder in the project navigator but not in finder. Xcode wouldn't let me quit the app, because Main.storyboard couldn't be saved.
Here's what I did, that solved this problem:
Identify which files are missing or misaligned in your project navigator and finder simultaneously.
Copy Main.storyboard and other files that are not in their right place to a safe location.
Force quit Xcode from Activity Monitor. Reopen Xcode.
Paste previously copied files in finder. Make sure that the folder order is the same as the Xcode project navigator.
In Xcode, from project navigator right-click to where you need to add files and click add new files.
Add files from the finder.
Clean and build.

Find missing files in Xcode

I am re-arranging files in my file system for my Xcode projects. Therefore, when I open the Xcode project, all of the files are red.
I can add each file manually, but is there a way for Xcode to quickly find these files for me? All of the files are located in one directory.
If you have a bunch of missing (red) files that now live in the same directory, you can improve on the "fix each path individually in the inspector" method by selecting (Cmd-click) all the files at once. You'll see "multiple values" in the inspector, like so:
Clicking the button under the Location dropdown will bring up a directory selector -- note that the prompt says "Choose folder containing..." rather than "Choose file and location".
As far as I know, Xcode doesn't have a way to automatically locate moved files. You can reconnect a reference to its file using the Inspector (panel on the right) but it is somewhat tedious to do so. In your case, it would probably be faster to simply delete the references and then add the files back to your project.
I agree with the answers already given. In a real pinch, or as a last resort, you can open the project file in a text editor and fix the path references by hand.
Close the project in Xcode
Backup the project file someplace safe
In the Finder, right-click on the project file and select "Show Package Contents"
Drag project.pbxproj to BBEdit (or TextEdit or whatever)
Edit whatever "path = xxx" references you want
In this case i do this steps:
1) Add a new group with name Res
2) Click "Add Files to ..."
3) Find a folder with resources, and click CMD + A
4) Set check box on "Create folder references for any added folders".
And in source code i use e.g. "fonts/font1.xml".
5) Then for refresh, i just Removing a Res group references
6) And do steps from 1 to 4
Hope this will be a useful

Resources