Bug 1648 - XCode modified XIBs not synced back consistently
Summary: XCode modified XIBs not synced back consistently
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: iOS add-in ()
Version: 2.8.1
Hardware: Macintosh Mac OS
: High normal
Target Milestone: ---
Assignee: Alan McGovern
URL:
Depends on:
Blocks:
 
Reported: 2011-10-23 11:13 UTC by Robert Jordan
Modified: 2011-12-29 05:03 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Robert Jordan 2011-10-23 11:13:49 UTC
It seems that sometimes changes in XIB files performed in XCode are not recognized by MD's iOS plugin. It is hard to reproduce, but I believe it's FileSystemWatcher related, because it seems only to happen under a slight system load.

I wonder if it won't be better to symlink the XIBs instead of copying them into XCode's mirror project, if possible.
Comment 1 Mikayla Hutchinson [MSFT] 2011-10-23 17:55:29 UTC
There's no FileSystemWatcher involved, since it's unreliable on Mac. Instead, when MD regains focus we use AppleScript to make Xcode save all open documents in the project, then check all the xibs' write times against a cache of times that the files were copied out. The copies use hard links, however it appears that Xcode uses the old trick of writing a new file a copy and renames it over the old one to ensure an atomic write, so I don't think symlinks would work.
Comment 2 Mikayla Hutchinson [MSFT] 2011-10-23 18:00:57 UTC
Maybe when the IO subsystem is under load there's a race between the AppleScript save call returning and the file actually being flushed to disk.
Comment 3 Robert Jordan 2011-10-23 18:24:35 UTC
Michael, thanks for explaining the internals.

I think I know how I broke the synchronization: I've closed XCode out of bad habit (I used to close IB3 like this) prior to switching back to MD.

I saw that in this case MD is re-spawing XCode right after it has regained the focus (maybe due to the aforementioned AppleScript). The new XCode instance is "empty" (no project loaded).
Comment 4 Mikayla Hutchinson [MSFT] 2011-10-23 19:24:58 UTC
It sounds like something got broken in MD - we test Xcode's open before trying to run the AppleScript, so it shouldn't be re-spawning. I suppose it's also possible that the syncback early-exits if Xcode isn't open and misses the updated file - we'll have to check those codepaths.
Comment 5 Alan McGovern 2011-10-24 05:07:40 UTC
Another reason why we can't use symlinks is that not all filesystems support it, such as network filesystems. We couldn't use symlinks as the only supported mechanism as it would just fail for people opening their projects over the network.

Also, closing xcode and then going back to MD is exactly what I do every time. My guess would be that MonoDevelop is regaining focus before the xcode app has completely finished shutting down. That way we send applescript which is then picked up by a new app instead of the one we intended.

I'll review the code and see if I can figure out what's gone wrong with the sync'ing. There are a couple of things we can try to improve things.
Comment 6 Alan McGovern 2011-11-22 11:13:26 UTC
Can you confirm that you were experiencing this issue with MonoDevelop 2.8.1 or higher with Xcode 4.2? I'm just looking into the code and can't see what would cause this problem. We seem to have all our applescript covered with checks to ensure that we do not accidentally re-launch Xcode if it has been shut down.

Would you able to give a more detailed description of the steps you follow to reproduce the issue? Is it simply a case of:
1) Open a xib in xcode
2) Make some modifications
3) Hit save
4) Press command-q to close xcode
5) MonoDevelop does not sync the changes and instead relaunches and empty xcode
Comment 7 Robert Jordan 2011-11-22 18:27:52 UTC
It was 2.8.x (x < 2) from the stable channel as of 2011-10-23 11:13.

Yes, the steps were pretty much these, plus the system load. I'll retest with 2.8.2 and come back to you.
Comment 8 Alan McGovern 2011-12-14 07:07:42 UTC
Do you have any further information on this or has the issue been fixed?
Comment 9 Alan McGovern 2011-12-22 05:43:49 UTC
This cannot be reproduced anymore and I've spent some time trying. If it manifests again, do let me know!
Comment 10 Robert Jordan 2011-12-22 06:28:37 UTC
I cannot reproduce it with 2.8.5 anymore. Thanks!
Comment 11 Atin 2011-12-29 05:03:42 UTC
I have validated this issue and followed the steps provided by Alan and did not get this issue.

Please close this issue or let me know if I am in wrong direction.

Environments:
MAC 10.7
Mono Develop 2.8.5 Stable.
Mono Touch 5.0.4 Stable
Mono Framework 2.0.7 
Xcode 4.2 iOS 5