Bug 45524 - Follow-up to Bug 44285 for backwards-compatibility: With Xcode 7.3, "Xamarin Studio could not communicate with Xcode" error dialog appears after Xcode project opens during "Open With > Xcode Interface Builder" command
Summary: Follow-up to Bug 44285 for backwards-compatibility: With Xcode 7.3, "Xamarin ...
Status: VERIFIED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: iOS add-in (show other bugs)
Version: 6.1.0 (C8)
Hardware: PC Mac OS
: --- critical
Target Milestone: (C8SR1)
Assignee: Jeffrey Stedfast
URL:
Depends on:
Blocks: 44285
  Show dependency tree
 
Reported: 2016-10-15 19:11 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2016-10-18 21:02 UTC (History)
1 user (show)

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


Attachments
IDE log files (6.76 KB, application/zip)
2016-10-15 19:11 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details


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:
VERIFIED FIXED

Description Brendan Zagaeski (Xamarin Team, assistant) 2016-10-15 19:11:27 UTC
Created attachment 18056 [details]
IDE log files

Follow-up to Bug 44285 for backwards-compatibility: With Xcode 7.3, "Xamarin Studio could not communicate with Xcode" error dialog appears after Xcode project opens during "Open With > Xcode Interface Builder" command




## Steps to replicate

1. Create a new "iOS > App > Single View App", iPhone project in the user home folder.

2. Select "Open With > Xcode Interface Builder" from the context menu on "Main.storyboard".




## BAD results with Xamarin Studio 6.1.2.31 (cdbaa604) + Xcode 7.3

Xamarin Studio generates the Xcode project and opens it in Xcode successfully, but then an error dialog appears:

> Xamarin Studio could not communicate with Xcode
>
> If Xcode is still running, please ensure that all changes have been
> saved and Xcode has been exited before continuing, otherwise any new
> changes may be lost.
>
> [OK]

It seems this error might be happening when Xamarin Studio sends AppleScript commands to tell Xcode to open the particular storyboard that the user selected in Xamarin Studio.

If you make and save changes in the Xcode project before clicking OK on the error dialog, those changes _will_ in fact be synchronized successfully back into the Xamarin project.




## GOOD results with Xamarin Studio 6.1.2.31 (cdbaa604) + Xcode 8.0

Xamarin Studio generates the Xcode project, opens it in Xcode successfully, and opens the storyboard that the user selected.

No error dialogs appear.




## Additional version checks

BAD:  Xamarin Studio 6.1.2.30 (c95fd69d) + Xcode 7.3
GOOD: Xamarin Studio 6.1.1.15 (fa52f026) + Xcode 7.3




## Potential improvements

It looks like it might unfortunately be necessary to have 2 different variants of the AppleScript commands to open the storyboard that execute conditionally depending on the current Xcode version.

tell application "/Applications/Xcode.app"
	return version
end tell




## Additional environment info (brief)

Xcode 7.3, Build version 7D175

Mono 4.6.1 (mono-4.6.0-branch-c8sr0/abb06f1)

Mac OS 10.11.6
Comment 1 Jeffrey Stedfast 2016-10-16 16:17:32 UTC
This isn't related. This is caused by Xcode not responding to a script and timing out.
Comment 2 Brendan Zagaeski (Xamarin Team, assistant) 2016-10-17 06:00:26 UTC
Whoops, I forgot to mention a key point which is that Xamarin Studio closes the Xcode project after the user clicks "[OK]".  That makes it rather tricky to use the synchronization feature with Xcode 7.3 at all.




## Further investigation

Looking in the attached IDE log file I see:

> WARNING [2016-10-15 15:06:40Z]: Applescript failure: ScriptError: Xcode got an error: Can״ make loaded of workspace document "UnifiedSingleViewIphone1.xcodeproj" into type specifier.
> [[
> tell application "/Applications/Xcode.app"
> 	open "/Users/Shared/UnifiedSingleViewIphone1/UnifiedSingleViewIphone1/obj/Xcode/0/UnifiedSingleViewIphone1.xcodeproj"
> 	set workspaceDocument to workspace document "UnifiedSingleViewIphone1.xcodeproj"
> 	-- Wait for the workspace document to load with a 60 second timeout
> 	repeat 120 times
> 		if loaded of workspaceDocument is true then
> 			exit repeat
> 		end if
> 		delay 0.5
> 	end repeat
> 	if loaded of workspaceDocument is true then
> 		with timeout of 30 seconds
> 			open "/Users/Shared/UnifiedSingleViewIphone1/UnifiedSingleViewIphone1/obj/Xcode/0/Main.storyboard"
> 			activate
> 			return true
> 		end timeout
> 	end if
> 	return false
> end tell
> ]]



Indeed the `loaded` property does not exist on the `workspace document` AppleScript type in Xcode 7.3, but it does in Xcode 8.




## Candidate pull request

I have submitted a pull request that takes a perhaps somewhat naive approach of just adding back the old logic for the 2 affected AppleScript scripts.  It uses the old logic if the Xcode version is less than 8.0.  I built Xamarin Studio locally with those changes, and that allowed me to complete all of the verification steps from Bug 44285, Comment 48 successfully on both Xcode 8.0 and Xcode 7.3.  There might be another property in Xcode 7.3 that could be used in place of the `loaded` property, but it didn't jump out at me on a first quick glance through the AppleScript dictionary.



Best,
Brendan
Comment 4 Jeffrey Stedfast 2016-10-17 16:05:27 UTC
oh, I completely misunderstood this to be that this happened sometimes with Xcode8, not with Xcode7.3.
Comment 5 xamarin-release-manager 2016-10-18 19:52:19 UTC
Fixed in version 6.1.2.38 (cycle8)

Author: Brendan Zagaeski
Commit: b10b2035a4f8a2eae1ad3667043184b40b24058f (xamarin/md-addins)
Included in Commit: 8937e51ff879e4062e660a70d13463510a2664c4 (mono/monodevelop)
Comment 6 Brendan Zagaeski (Xamarin Team, assistant) 2016-10-18 21:02:20 UTC
No worries.  All sorted out now :)




## Verification status: verified

> GOOD on all steps from Bug 44285, Comment 48: Xamarin Studio 6.1.2.38 (8937e51f) + Xcode 8.0
> GOOD on all steps from Bug 44285, Comment 48: Xamarin Studio 6.1.2.38 (8937e51f) + Xcode 7.3