10

I have a Monotouch iPad application for which I am trying to set up an automated build script. I am attempting to use mdtool, but I seem to have hit a wall. If I build the solution using the MonoDevelop GUI, it builds successfully. However, if I clean the solution, and build using mdtool, it get an exception about a null reference exception in an unknown file.

I've googled around for the last couple of hours. I thought I found a couple of leads here on Stack Overflow, but they all seem to be different situations. Not much out there about successful building in the UI and a failure on the CLI.

Here is some output:

     Performing main compilation...
        Updating CodeBehind files
ERROR [2011-06-03 11:27:52Z]: Error generating code for xib file '/Users/Me/Documents/Code/MyApp/MainWindow.xib'
System.NullReferenceException: Object reference not set to an instance of an object at MonoDevelop.DesignerSupport.CodeBehindWriter.<get_OpenFiles>m__21 () [0x00000] in <filename unknown>:0 
at MonoDevelop.Ide.DispatchService.GuiSyncDispatch (MonoDevelop.Ide.MessageHandler cb) [0x00000] in <filename unknown>:0 
at MonoDevelop.DesignerSupport.CodeBehindWriter.get_OpenFiles () [0x00000] in <filename unknown>:0 
at MonoDevelop.DesignerSupport.CodeBehindWriter.Write (System.CodeDom.CodeCompileUnit ccu, FilePath path) [0x00000] in <filename unknown>:0 
at MonoDevelop.MacDev.XibCodeBehind.GenerateDesignerCode (MonoDevelop.DesignerSupport.CodeBehindWriter writer, MonoDevelop.Projects.ProjectFile xibFile, MonoDevelop.Projects.ProjectFile designerFile) [0x00000] in <filename unknown>:0 
at MonoDevelop.MacDev.MacBuildUtilities.UpdateCodeBehind (IProgressMonitor monitor, MonoDevelop.MacDev.XibCodeBehind generator, IEnumerable`1 items) [0x00000] in <filename unknown>:0 

The command that I am executing looks like this:

/Applications/MonoDevelop.app/Contents/MacOS/mdtool -v build "--configuration:Release|iPhone" "/Users/Me/Documents/Code/MyApp/MyApp.sln" 

And just to keep it thorough, here are my versions:

    OS X: 10.6.7
    XCode: 3.2.6
    iOS SDK: 4.3
    Mono: 2.10.2
    MonoDevelop: 2.4.2
    MonoTouch: 4.0.3

Update (6/7/2011):

As an alternative, I tried doing mdtool generate-makefiles. It created everything one would expect, and ./configure ran properly, but make failed pretty miserably. I'd love to solve this problem if anyone has any thoughts.

Sathyajith Bhat
  • 21,321
  • 22
  • 95
  • 134
Kirk
  • 234
  • 3
  • 13
  • I think this can only work when called inside MD, the stack trace implies it is trying to act on files opened in the ide :( – IanNorton Jun 14 '11 at 13:57
  • @Ian, just to make sure that I am following, you are saying that I just can't compile from the CLI, that it can only work from the IDE? – Kirk Jun 14 '11 at 15:03
  • @Kirk, possibly :(, just a guess though – IanNorton Jun 14 '11 at 15:16
  • I'm talking rubbish, clearly this is a bug. – IanNorton Jun 14 '11 at 15:20
  • @Kirk, the source of this part of monodevelop is here: https://github.com/mono/monodevelop/blob/master/extras/MonoDevelop.IPhone/MonoDevelop.MacDev/XibCodeBehind.cs. Have you tried monodevelop 2.6 beta? – IanNorton Jun 14 '11 at 15:23
  • @Ian, I have not, but mostly because of the state of the MonoTouch project, I am extremely hesitant to make changes to an functioning system. Perhaps I will clone my drive, and see if I get different results like that. I'll try to keep you posted. – Kirk Jun 14 '11 at 16:23

1 Answers1

5

This is a bug, however designer code is generated only if the xib or the project (csproj) file is newer than the designer file. Build it once inside the IDE or "touch" the designer file and mdtool will work again.

Mikayla Hutchinson
  • 16,113
  • 2
  • 44
  • 50
  • This seems to work, but since my goal is to build a one touch build script, it seems that this bug is going to thwart my efforts. I am however constructing my script in AppleScript. It looks more like a shell script, but it does seem to work. – Kirk Jun 26 '11 at 03:48
  • Well I take it back, I guess I forgot about the touching of the designer file. I didn't try that. If that works, then my shell scripting might still work. – Kirk Jun 26 '11 at 03:49
  • Touching the designer file seems to do the trick. But here is my follow up question: you said "designer code is generate only if the xib or project file is newer than the designer file." By touching the designer file, this sets it to be the newest file in the directory, which makes it seem contrary to your original statement. – Kirk Jun 26 '11 at 14:12
  • 1
    The only reason the designer file would be regenerated is if you've modified the project file or the xib file without rebuilding the project in MD, or if something else (e.g. a VCS) is messing around with file write times. By making the designer file newer than the other files, you prevent triggering its regeneration. – Mikayla Hutchinson Jun 27 '11 at 12:52
  • Can we get a link to the bug? – Randy Syring Apr 19 '12 at 18:29
  • MonoDevelop 2.8+ no longer generates MonoTouch code at build time, so the bug no longer exists. – Mikayla Hutchinson Apr 23 '12 at 12:32