Interface Builder just lost a day of my work... for 10 minutes

I experienced some baffling and very worrisome behavior yesterday in IB.


After spending a day laying out a couple of screens, setting up constraints and loading graphics into my assets file for use in buttons... it was all looking good.


Then, for no apparent reason, IB reverted the storyboard and lost everything. I didn't even leave Xcode. All the graphics were replaced with the pixelated ?... but this happens every so often. That wasn't the biggest problem. The entire screen layout reverted to one from a full day earlier, with all of my work deleted. Fonts, positions, controls... all reverted to a state that was long, long gone.


I didn't rebuild. I launched the app on my phone to make sure I wasn't in a fugue, but nope, all of my work was still there. I quit Xcode and relaunched it... still the work was lost and I was looking at a long-gone storyboard layout. I double-checked that I had opened the version of the project I thought, and checked the timestamps on the files in the project. Yes, I was in the right project.


So then I wanted to know what other work was lost, so I clicked on the asset file to see if it still showed the last bitmap I added... and it did.


And then... all my work came back. All I did was click around in the project tree. I have only one storyboard.


Has anybody else experienced this? I'm wondering if this could be traced to the invisible "versioning" that Apple forced on everyone a few years ago, or some defect in APFS. Where could it have pulled the ancient version of the file from?


This is in Xcode 10.1 on OS 10.14.3.


Update:

I just remembered what happened before the disappearance of my work: Xcode hit a breakpoint on an always-executed line of code that it hadn't hit all day. The breakpoint had probably been deleted long ago. This points to a reversion of more than just IB content in the project.

Replies

So, you have recovered everything ? Great.


Make immediately and regularly a save of the complete project (when I do a lot of changes to a project, I may save twice a day).


I don't know if that can help understand, but I sometime experienced similar behavior.

I modified a file in XCode. Then when I compiled, an older version was used (from a previous save).


I finally figured out that I opened this file in editor (or in IB by the way) from the "recent" popup.

The problem was that this "recent" was from another version of the project ! I was modifying the saved version and not the current one. Very hard to notice the error.

And I could not anymore connect an object between code and IB : IB file was from the current version, code file from the saved version.


(Re)Selecting the file in the file browser on the left pane of XCode cleared the issue.