Bug 26556 - The iOS project compilation error after editing xib in XCode
Summary: The iOS project compilation error after editing xib in XCode
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: MSBuild ()
Version: XI 8.6.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Jeffrey Stedfast
URL:
Depends on:
Blocks:
 
Reported: 2015-01-29 13:39 UTC by Ievgen
Modified: 2015-01-30 13:11 UTC (History)
2 users (show)

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


Attachments
My Xamarin Studio Info (780 bytes, text/plain)
2015-01-29 13:39 UTC, Ievgen
Details
Including bin and obj folder to reproduce the build error (7.72 MB, application/zip)
2015-01-29 15:01 UTC, Ievgen
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:
RESOLVED FIXED

Description Ievgen 2015-01-29 13:39:15 UTC
Created attachment 9559 [details]
My Xamarin Studio Info

After upgrading to the Unified API I am having a problem with editing XIB files in XCode. After a file is edited there is a compilation error:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets: Error: /Users/####/Sites/Git/#####/Client/#####.iOS/bin/iPhoneSimulator/Release/#####.app/HomeView.nib is a directory  at System.IO.File.Delete (System.String path) [0x00000] in <filename unknown>:0 
  at Microsoft.Build.Tasks.Copy.CopyFile (System.String source, System.String dest, Boolean create_dir) [0x00000] in <filename unknown>:0 
  at Microsoft.Build.Tasks.Copy.Execute () [0x00000] in <filename unknown>:0  (ShowMap)
Comment 1 Ievgen 2015-01-29 13:46:10 UTC
After playing around the problem I figured out that it appears after changing of XIB deployment version to 1792 (I guess XCode sets is by some reason) in the header of the XML

    <dependencies>
        <deployment version="1792" identifier="iOS"/>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
    </dependencies>

If I manually change it for example to 1790 in Xamarin Source Code Editor, the build goes well and the app is started in iOS Simulator normally.
Comment 2 Rolf Bjarne Kvinge [MSFT] 2015-01-29 14:24:03 UTC
This does not look right. Can you attach a test project that we can use to reproduce the problem?
Comment 3 Ievgen 2015-01-29 15:00:55 UTC
I created a test TestCompileError project and will attach to this bug. But here my observations.

The problem appears if
- The solution was built before (I assume there is some symbols on disk)
- The XIB deployment version is changed to anything
- Attempt to built fails with error:

/Users/######/Projects/TestCompileError/TestCompileError/TestCompileError.csproj (Build) ->
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets (_CopyContentToBundle target) ->

	/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets: error : Cannot create /Users/######/Projects/TestCompileError/TestCompileError/bin/iPhoneSimulator/Release/TestCompileError.app/HomeView.nib because a file with the same name already exists.  at System.IO.Directory.CreateDirectory (System.String path) [0x00000] in <filename unknown>:0 
  at Microsoft.Build.Tasks.Copy.CreateDirectoryIfRequired (System.String name) [0x00000] in <filename unknown>:0 
  at Microsoft.Build.Tasks.Copy.CopyFile (System.String source, System.String dest, Boolean create_dir) [0x00000] in <filename unknown>:0 
  at Microsoft.Build.Tasks.Copy.Execute () [0x00000] in <filename unknown>:0 

If you the Clean command in run for solution or bin folder is manually deleted from disk the build is done successfully. (this is why I included bin folder into zip, you just need to try to build it to get an error)
Comment 4 Ievgen 2015-01-29 15:01:57 UTC
Created attachment 9565 [details]
Including bin and obj folder to reproduce the build error
Comment 5 Rolf Bjarne Kvinge [MSFT] 2015-01-30 04:38:51 UTC
It looks like changing xib version from 1790 to 1792 changes the ibtool output between a directory and a file.

Jeff, can you have a look? To reproduce:
* Build.
* Change 
    <deployment version="1790" identifier="iOS"/>
  to
    <deployment version="1792" identifier="iOS"/>
in TestCompileError/Views/HomeView.xib using a text editor.
* Try to build again.

Full build output: https://gist.github.com/rolfbjarne/b54eb8a355a620e7de62
Comment 6 Jeffrey Stedfast 2015-01-30 11:49:03 UTC
This is a problem with the Microsoft Copy task which apparently fails in this scenario (at least with xbuild's implementation).

An easy fix would be to fix xbuild's Copy task CreateDirectoryIfRequired() to check if the path already exists as a file, and if so, call File.Delete() on it first.

However, I have no idea if that would be consistent with Microsoft's implementation in MSBuild.
Comment 7 Jeffrey Stedfast 2015-01-30 13:11:34 UTC
Implemented our own SmartCopy task that deals with this condition.