XCode: The document: "<document name>" could not be saved. The file has been changed by another application" - xcode4

Since starting to use XCode 4.2 I've more-or-less routinely had the error:
with various substitutions for the filename. This is normally when Xcode is doing an autosave, so it happens seemingly at random. I generally click "Save Anyway" and my recent edits are then preserved, although there is a significant probability that Xcode will then hang. I don't typically lose much when it hangs, other than a minute to shoot it and get it to restart, but still...
I don't open any of these files in any application except XCode. I have not been able to figure out the pattern, although it may have to do with popping back and forth between files. The last time I noticed it, I also noticed that the previous round of edits to that file hadn't taken. So some other editor had not saved the file.
Enough preamble: here's the question:
Are others running into this? Has anyone narrowed down what causes it? Is there a setting I can change to prevent it? Is there something I can change in my behaviour?

You will get this happening when
1) There are locally unsaved modifications (the navigator icon will be shaded)
2) AND something else has changed the file outside of Xcode. For me this occurs when I do an external update from svn on the command line or via Versions
What do you have that is modifying and saving the file outside of Xcode? Anything?
Check your source control (if any) and figure out if something you are doing is causing the conditions to be met.

Well I had the same problem when I was trying to Localize my files. Then I noticed that every time the message was popping up was because the icon of the selected file in the Project Navigator was grey, which means that was not saved. So what I did was to save the file (Cmd+S) before doing the action that made the "changed by another application" message to appear, in my case the Localize button.

Related

Icons behaving weirdly

I made an application with Visual Studio 2019. I already set an icon for it, but then I wanted to change it. When I changed the icon, in some folders where I had the program saved with the old icon, the displayed icon didn't change when in replaced the file. The program only contains one icon file. I even tried redoing the program by deleting the vs project and copying my code. After that didn't work, I tried changing the icon back but now in every folder that once contained the file while it had the newer icon, the file wouldn't change back. Renaming the file doesn't work either. I have never seen this before. Can anyone help?
So, it went away by itself. If you ever have this problem, it will probably go away on its own. Don't exactly know how long it takes, restart is not enough. It took only one day in my case.

When do changes to a QML file not take effect?

I've had a problem happen for the second time over the last week. It seems to happen randomly. I change something in a QML file, save it, run the app, and see that my change has not taken effect. I rerun the app and it still has not taken effect.
The first time this happened to me, it got fixed by itself after I did some git stuff (in this order: git stash save, rollback to an older revision, go back to the newest revision, git stash pop). The second time I didn't do that, but ran qmake from the Qt Creator menu and that fixed it.
What could be the cause of the problem?
I'm using Qt Creator 4.1.0.
Stephan i have seen this happening and from what i have read before is a know bug, more information can be found in:
https://bugreports.qt.io/browse/QTCREATORBUG-1627
The thing is that it seems qtcreator is unable to detect a change of qlm/qrc files being changed, so the makefiles are not being updated due qmake is not being run.
seems they are not going to be solved bug, it has been already for years there, the workaround in qtcreator is to run qmake manually and after rebuild.
I just hit this problem again, this time despite diligently running qmake before every run.
I think I figured out what caused it this time. It's that I was using the small Run button (actually called "Re-run this run configuration") that resides in the "Application output" pane's toolbar. Seems like this button has the treacherous property of running without rebuilding.
The solution is to use Ctrl+R, or, equivalently, the big run button in the vertical toolbar along the left side of the window.
Another time the problem wouldn't go away until I deleted the myproject.pro.user file.

xib file save doesn't stay saved in Xcode

I made some changes to my MainWindow.xib in Xcode and every time I hit save it appears to indicate success, changing from dimmed to normal in the navigator. Seconds later it goes back to dimmed, as if it has been modified and needs to be saved again. Has anybody seen this before? What do I do to make it stay saved.
I have tried deleting the derived data and reopening the project. The changes do appear to remain as edited, the project compiles and seems to work properly. Only sign of an issue is that the file looks to need saving no matter what I do.
On further analysis I found that it seems to change to modified state whenever I select it, whether I make a change or not. I can't say if this is normal behavior but it does not seem to result in any problems for my project. If I select a different file in the navigator pane, prior to a build, the xib file is saved and stays saved. If I select the xib again after that build, it instantly goes back to modified.
This does not happen with any other xib files in my project.
I have never noticed this behavior prior to now, of course it has been ages since I altered this specific xib.
I am going to conclude that this was a bug in a former XCode build. Since latest, now 4.4, I have not seen this behavior at all.

Storyboard file missing

I'm new to xCode 4 and have playing with storyboards for most of the day. I was making an edit to one of the segue's and didn't realize that the entire file was selected, not just the arrow on the right side. This deleted my ENTIRE storyboard, which usually isn't a big deal as it's either still in the folder if i only deleted the reference, or in the trash if the file was actually deleted.
Strangely, it's in neither. I created a storyboard to test this out and sure enough, xCode warns "this can not be undone"....and it's gone. No where in finder or the trash bin.
Now, the weirdest part. My application is still running fine. I can't make any edits obviously as i can't bring it up, but xCode is still running fine. I've reset my computer and done everything else to clear it out but i can't my storyboard nor find it anywhere!
any help would be greatly appreciated...
jason
This happened to me as well - very alarming! However I searched for "storyboard" using SearchLight on the desktop. This found the file as the top hit! I was then able to track its location to a folder called en.lproj within the project folder and use File > Add to bring this folder back in.
Everything seemed fined except I had a problem every time I tried to delete the same image that caused the problem in the first place. The image was just sitting in a viewcontroller as a background image and each time I deleted it the whole storyboard vanished (temporarily).
So, I simply removed this viewcontroller altogether and created a new one and that worked. Much better than recreating the whole storyboard!

Strange Error in Xcode 4 that persisted across different versions of the same file

I want to preface this question by admitting that I'm still very much a novice, to Xcode 4 and to development in general. But I find I learn the most when I've made mistakes and been able to discover ways to correct my errors.
So I was mucking about in Xcode, following an example in the book I've been studying, in this case trying to determine why the keyboard wouldn't hide when I touched outside a text field. In the process of experimentation, I tried adding an Outlet to the top level View of a View Controller, dragging into the Header file to automagically create it. I knew almost at once this wasn't what I wanted, and I deleted the reference in Interface Builder, and the code it had added to the other files.
And when I did run the program, it threw an exception. Being new to this, I didn't think to check the log files, and when I couldn't work out what the error was, I restored an earlier version of the project from Time Machine, and tried again -- same result. I restored an even earlier version and tried again -- and got the same error!
When I finally did have the good sense to look at the log file, I noticed the reference to the name of the Outlet I had added, but removed! But these were older versions of the code, before I'd even made that change.
I made a thorough search of the code, and my NIB file, looking for any reference to the deleted Outlet. I couldn't find anything.
I eventually replaced the NIB file with a version from the tutorial from the book I was following (it was identical, and easier than rebuilding it from the bottom up), and all was well, everything ran just fine. But now I'm left wondering -- what could I have done to make this error so persistent, across different versions of the file? I'm already kinda uncertain about the way Xcode 4 will automagically add code under certain circumstances (that's probably more dangerous than useful for the novice), and I wonder if this is a bug in Xcode 4, or if I inadvertently tripped over a useful feature.
Xcode loves to play tricks on you. I've several times gotten an XIB mysteriously hosed up to the point where I had to delete it and start over. No matter what I'd do to the XIB some elements wouldn't display correctly (or at all).
In a recent case I had an XIB with a label with the text "Start date:". I changed that label text to "Treatment date:", but it still kept coming out "Start date:". I opened the XIB as text and scanned for "Start date:" and it wasn't there. So I tried dragging the label off to one side. Then it displayed the correct words. Dragged the label back to the correct place -- back to "Start date:". I finally deleted the label and recreated it and then the text came out correctly.

Resources