diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2011-07-29 12:30:06 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2011-07-29 12:30:38 +0400 |
commit | 6c29cfe612f2d435bd93f480c3f130c04ebfa2cf (patch) | |
tree | 7887ba87f5d8bb1965e7d54abcc72d93df900878 /main | |
parent | 0a725bb519964117feddc02bb6ac24a42c9000c6 (diff) |
Remove Xcode's DerivedData directories when cleaning up the generated
projects.
Diffstat (limited to 'main')
-rw-r--r-- | main/src/addins/MonoDevelop.MacDev/XcodeSyncing/XcodeMonitor.cs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/main/src/addins/MonoDevelop.MacDev/XcodeSyncing/XcodeMonitor.cs b/main/src/addins/MonoDevelop.MacDev/XcodeSyncing/XcodeMonitor.cs index 8efe57ca8e..8263ffa9e5 100644 --- a/main/src/addins/MonoDevelop.MacDev/XcodeSyncing/XcodeMonitor.cs +++ b/main/src/addins/MonoDevelop.MacDev/XcodeSyncing/XcodeMonitor.cs @@ -39,6 +39,8 @@ using MonoDevelop.MacInterop; using MonoMac.AppKit; using MonoMac.Foundation; using MonoDevelop.Ide.ProgressMonitoring; +using MonoDevelop.MacDev.PlistEditor; + namespace MonoDevelop.MacDev.XcodeSyncing @@ -239,6 +241,7 @@ namespace MonoDevelop.MacDev.XcodeSyncing return; if (Directory.Exists (this.originalProjectDir)) Directory.Delete (this.originalProjectDir, true); + DeleteDerivedData (); } void DeleteProjectArtifacts () @@ -248,6 +251,51 @@ namespace MonoDevelop.MacDev.XcodeSyncing Directory.Delete (xcproj, true); } + static string GetWorkspacePath (string infoPlist) + { + try { + var dict = PDictionary.Load (infoPlist); + PString val; + if (dict.TryGetValue<PString>("WorkspacePath", out val)) + return val.Value; + } catch (Exception e) { + LoggingService.LogError ("Error while reading info.plist from:" + infoPlist, e); + } + return null; + } + + void DeleteDerivedData () + { + var derivedDataPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "Library/Developer/Xcode/DerivedData"); + string[] subDirs; + + try { + if (!Directory.Exists (derivedDataPath)) + return; + subDirs = Directory.GetDirectories (derivedDataPath); + } catch (Exception e) { + LoggingService.LogError ("Error while getting derived data directories.", e); + return; + } + + foreach (var subDir in subDirs) { + var plistPath = Path.Combine (subDir, "info.plist"); + var workspacePath = GetWorkspacePath (plistPath); + if (workspacePath == null) + continue; + if (workspacePath == xcproj) { + try { + XC4Debug.Log ("Deleting derived data directory"); + Directory.Delete (subDir, true); + } catch (Exception e) { + LoggingService.LogError ("Error while removing derived data directory " + subDir, e); + } + return; + } + } + XC4Debug.Log ("Couldn't find & delete derived data directory"); + } + public bool IsProjectOpen () { if (!CheckRunning ()) |