Wednesday, September 05, 2012

A helper on getting MonoTouch building Portable Library code

I've not had a lot of time to play with this yet, but in the last 24 hours I've managed to get a lot more of the Mvx vNext portable code building using the hint:

You may be able to fix this by editing the file /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild/Microsoft/Portable/v4.0/Microsoft.Portable.CSharp.targets, finding the PropertyGroup that sets
MonoTouchAnd to it, adding the lines:
smcs/Developer/MonoTouch/usr/bin

Found this hint via http://stackoverflow.com/questions/12041290/monodevelop-is-it-possible-to-switch-pcls-compiler/12062589#12062589 and https://bugzilla.xamarin.com/show_bug.cgi?id=5329 - wish I'd found it months ago (note to self - don't give up so easy next time!)

For Mac newbies, note that this file is in the root from the hard disk (not from the user) and that you will need to edit file (and folder?) permissions in order to edit it - you can do this from finder using 'more info'.


9 comments:

  1. Hi, do you have anything further on this? I get incompatible target framework when trying to use from a MT project... I'm using profile 104 and set up as described in your previous posts.

    ReplyDelete
  2. I got my first project loading and running this morning (2 hours ago).

    Sadly you do have to edit the PCL project files from Profile104 to Profile1, and I did have to change the way the plugins loaded (http://stackoverflow.com/questions/12401588/can-you-use-assembly-load-in-monotouch) but apart from that it works...

    I'll ping the Xamarin guys to see if I can get the 104 thing fixed...

    And I'll write some more code this weekend - after 4 months, it finally works :)

    ReplyDelete
  3. There was also a couple of problems building the Touch version of the System.Net forwarding libary - but fortunately they're fairly easy to workaround.

    ReplyDelete
  4. Logged to https://bugzilla.xamarin.com/show_bug.cgi?id=7173 - hopefully this is just a small issue and the team will be able to implement it quite quickly.

    ReplyDelete
  5. Brilliant, thanks! I'll dig in on Monday but that should at least get me going. From your bug report it looks like it should be trivial for them to support 104 too which is great news.
    Thank you for all your work on piecing this together, it's been a massive help. Really appreciate it. I'm finding the Xamarin products great so far but this one issue is the only real pain point.

    ReplyDelete
  6. Thanks Sean.
    Are you using PCLs for MvvmCross or for your own libraries? If for MvvmCross, then I should warn you that that vNext branch is slightly out of date - there are a few recent fixes from the master branch that I haven't yet copied across.
    Regardless, good luck with whatever you're doing - I know @dsplaisted and @davkean at Microsoft are both super keen to see more PCL projects out there :)
    Stuart

    ReplyDelete
  7. Happy to report I have it working great so far on Profile1...
    Not actually using MvvmCross on the current project as it's iPad only. I've had a good look at it though and it looks like a fine piece of work, I'm quite sure I'll be using it in the future! Keen to dig through the source at some point and understand how you've implemented the data binding bits :)
    I'm using a PCL to share code between the MonoTouch project and an MVC4/Web API web project. Despite all the hacks piled on top of hacks to get it all functioning, the workflow is actually now quite seamless. My only want now would be to have async/await in MonoTouch but I've lived without it to this point in life, I can wait a little longer!

    ReplyDelete
  8. Cool. Jealous that you get to use Profile1 (every hack hurts a little!)

    If you fancy some more hacking then async/await might only be a compiler change away... http://fizzylogic.azurewebsites.net/2012/05/04/adding-asyncawait-support-to-your-mono-for-android-projects/

    ReplyDelete