PCLs and MvvmCross in the new tools

StuartLodgeStuartLodge Stuart LodgeUSBeta ✭✭✭

I can't answer even half the questions I'm being asked in my email inbox. Sorry. So I'm moving the conversation here.

The only thing I know is that Xam hope to demo something about PCLs sometime around the time of Evolve - so we're really close now to having amazing Cross-Platform support :)

Until then, the safest route is probably to use the old Mono tools, VSMonoTouch and the patched version of 3.1.1 - http://slodge.blogspot.co.uk/2013/02/a-patched-monodevelop-for-pcls.html - that's what I'm using right now today.

Alternatively, if you find something that works, please post it here :)

And if you have questions then again ask them here - hopefully someone here will be able to help you out.

We will get there - the future is definitely portable :)

Thanks (sorry I can't help more!)

Stuart

«1

Posts

  • DianeWilsonDianeWilson Diane Wilson USMember, Beta

    Full PCL integration pleeeeeeeeeezzzzz!

    There's plenty that I can work on between now and Evolve, since I'm still in learning and demo mode. But before long I'll need to integrate with MvvmCross and ServiceStack across iOS, Android, Win 8, and Win phone 8.

    BTW, the new Xamarin 2.0 looks excellent so far, other than the PCL status.

  • ChWoChWo Ch Wo DEMember

    @StuartLodge Thanks for this thread. I didn't try the new tools in order to avoid headaches especially with PCLs.

    @Xamarin I have a working cross platform solution using a PCL project and specific GUI projects for each platform. The PCL project references some MvvmCross PCL binaries. For the iOS project I have to compile the PCL against MonoTouch and need to reference the MvvmCross binaries that have been built against MonoTouch too. In order to keep my solution folder portable I'm using conditional compiling inside the .csproj file of my PCL to reference the correct binaries on each platform:

    <ItemGroup>
        <Reference Include="Cirrious.MvvmCross" Condition="'$(OS)' == 'Windows_NT'">
          <HintPath>..\MvvmCross\VS2012\Portable\Release\Cirrious.MvvmCross.dll</HintPath>
        </Reference>
        <Reference Include="Cirrious.MvvmCross" Condition="'$(OS)' != 'Windows_NT'">
          <HintPath>..\MvvmCross\MonoTouch\Touch\Release\Cirrious.MvvmCross.dll</HintPath>
        </Reference>
      </ItemGroup>

    (An example solution can be downloaded here: https://skydrive.live.com/?cid=D3D039F88037AAD4&id=D3D039F88037AAD4!139)

    Now I'm asking myself: Does this setup work with the new Xamarin.iOS plugin for Visual Studio? Does the PCL project reference the correct MvvmCross binaries on each platform? And do I still need the TargetFrameworkProfile hack inside the PCL project:

    <TargetFrameworkProfile Condition="'$(OS)' != 'Windows_NT'">Profile1</TargetFrameworkProfile>      
    <TargetFrameworkProfile Condition="'$(OS)' == 'Windows_NT'">Profile104</TargetFrameworkProfile>

    I'm afraid to break my setup and spend a lot of hours in testing Xamarin 2.0 and PCL support. If you say my solution doesn't work with the new tooling then it's not a problem. I can stay on the old tools for a while until PCLs are completely supported.

  • valdeterovaldetero Seth Valdetero USMember, Insider

    I was able to open the MvvmCross_NoSamples solution after installing Xamarin 2.0. I had to remove the references to to PortableSupport/Touch/System.Windows.Touch project from all of the iOS projects because of the following build error: The type 'System.Windows.Input.ICommand' exists in both 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoTouch\v4.0\System.dll' and '..\MvvmCross\bin\Touch\Debug\System.Windows.dll'

    I did get a slew of warnings about references, but everything still built.

  • valdeterovaldetero Seth Valdetero USMember, Insider
    edited February 2013

    I was able to add the iOS project to @slodge 's Sphero solution. I had to hack another target framework file similar to what he suggested at: http://slodge.blogspot.com/2012/09/mvvmcross-vnext-portable-class.html.

    I added one to target the official MonoTouch framework that Xamarin 2.0 installs.

    Add this file:

    <?xml version="1.0" encoding="utf-8"?>
    <Framework
        DisplayName="MonoTouch"
        Identifier="MonoTouch"
        Profile="*"
        MaximumVersion="*" 
        MinimumVersion="4.0" />
    

    to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile104\SupportedFrameworks

    I am all new to this so I have no idea if this runs but it compiles!

    EDIT: It compiled before I wrote this. When I got back, I had errors. :-/

  • StuartLodgeStuartLodge Stuart Lodge USBeta ✭✭✭

    Good stuff, Seth

    What are the errors? Together we will get this stuff working... thanks for doing all the work so far!

  • valdeterovaldetero Seth Valdetero USMember, Insider

    These are my errors with your Sphero project. I find some of them weird since ICommand and DefaultImagePath are referenced in the assemblies.

    Error   5   'Cirrious.MvvmCross.Plugins.DownloadCache.MvxDynamicImageHelper`1' does not contain a definition for 'DefaultImagePath' and no extension method 'DefaultImagePath' accepting a first argument of type 'Cirrious.MvvmCross.Plugins.DownloadCache.MvxDynamicImageHelper`1' could be found (are you missing a using directive or an assembly reference?) ..\BallControl-master\Cirrious.Sphero.WorkBench\Cirrious.Sphero.WorkBench.UI.Touch\Views\HomeView.cs    38  16  Cirrious.Sphero.WorkBench.UI.Touch
    Error   8   'System.Windows.Input.ICommand' does not contain a definition for 'Execute' and no extension method 'Execute' accepting a first argument of type 'System.Windows.Input.ICommand' could be found (are you missing a using directive or an assembly reference?)   ..\BallControl-master\Cirrious.Sphero.WorkBench\Cirrious.Sphero.WorkBench.UI.Touch\Views\HomeView.cs    41  33  Cirrious.Sphero.WorkBench.UI.Touch
    Error   9   'System.Windows.Input.ICommand' does not contain a definition for 'Execute' and no extension method 'Execute' accepting a first argument of type 'System.Windows.Input.ICommand' could be found (are you missing a using directive or an assembly reference?)   ..\BallControl-master\Cirrious.Sphero.WorkBench\Cirrious.Sphero.WorkBench.UI.Touch\Views\SpheroMovementView.cs  47  31  Cirrious.Sphero.WorkBench.UI.Touch
    Error   12  'System.Windows.Input.ICommand' does not contain a definition for 'Execute' and no extension method 'Execute' accepting a first argument of type 'System.Windows.Input.ICommand' could be found (are you missing a using directive or an assembly reference?)   ..\BallControl-master\Cirrious.Sphero.WorkBench\Cirrious.Sphero.WorkBench.UI.Touch\Views\HomeView.cs    53  34  Cirrious.Sphero.WorkBench.UI.Touch
    Error   4   The type 'Cirrious.MvvmCross.Plugins.DownloadCache.MvxDynamicImageHelper`1' is defined in an assembly that is not referenced. You must add a reference to assembly 'Cirrious.MvvmCross.Plugins.DownloadCache, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.   ..\BallControl-master\Cirrious.Sphero.WorkBench\Cirrious.Sphero.WorkBench.UI.Touch\Views\HomeView.cs    38  5   Cirrious.Sphero.WorkBench.UI.Touch
    Error   6   The type 'System.Windows.Input.ICommand' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.  ..\BallControl-master\Cirrious.Sphero.WorkBench\Cirrious.Sphero.WorkBench.UI.Touch\Views\HomeView.cs    41  5   Cirrious.Sphero.WorkBench.UI.Touch
    Error   7   The type or namespace name 'RelativePositionParameters' could not be found (are you missing a using directive or an assembly reference?)    ..\BallControl-master\Cirrious.Sphero.WorkBench\Cirrious.Sphero.WorkBench.UI.Touch\Views\SpheroMovementView.cs  41  23  Cirrious.Sphero.WorkBench.UI.Touch
    
  • AndreasHeydlerAndreasHeydler Andreas Heydler AUMember

    I have spent a bit of time getting mvvmcross to the stage of compiling with the Xamarin 2 VS plugin however when it comes to running say Tutorial.UI.Cross it fails without an error message, ie just a red cross in the error panel.

    I disabled the wpf projects as this is currently out of my scope and it did reduce some of the errors.

    Would certainly be interested to know if you manage to get the sphero project to run.

  • StuartLodgeStuartLodge Stuart Lodge USBeta ✭✭✭

    I am slowly starting to switch over... Just got some existing customer work that can't switch and I don't have a budget for multiple development Macs.

    One of the biggest issues seems to be the strong naming needed now - that stops the existing pre-built assemblies working.

    @valdetero were those build errors with the existing pre-built assemblies (built pre-signing) or with new ones?

    @aheydler there's not much debug info there, is there? If you can't get any other info, then can you post a screenshot and maybe some of the build output. I'll then see if we can attract a Xamarin dev here to help debug that.

  • AndreasHeydlerAndreasHeydler Andreas Heydler AUMember

    @StuartLodge believe me if there was more info I would have posted it! there is literally the red cross icon and a timestamp.

    If someone can tell me where any logs might be I will be happy to have a look as I am not yet that familiar with VS.

    Will post a screen shot and the build output when I can.

  • valdeterovaldetero Seth Valdetero USMember, Insider

    Those were with the new assemblies. I had a lot more with the existing ones.

  • DeanSchreinerDeanSchreiner Dean Schreiner USMember
    edited February 2013

    It seems like compilation errors appear because PCLs compile against "wrong" .NET Framework. Here's why I think so - if I create a class that implements ICommand in my MonoTouch project, it compiles and runs just fine. But if I move the same code into PCL and try to consume this class in my MonoTouch project, I get the following:

    error CS0012: The type 'System.Windows.Input.ICommand' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.

    I did go all over MvvmCross and remove references to System.Windows. And I am getting this error in Visual Studio on Windows machine when trying to compile the solution with Xamarin.iOS (Xamarin 2.0).

  • AndreasHeydlerAndreasHeydler Andreas Heydler AUMember

    this is the build log from a complete build of mvvmcross all with the .NetPortable files as described above along with what appears in VS when attempting to run Tutorial.UI.Touch

    image

    txt
    txt
    mvvmcross_all.txt
    30K
    Capture.PNG
    665 x 30 - 937B
  • StuartLodgeStuartLodge Stuart Lodge USBeta ✭✭✭
    edited March 2013

    We've not managed to lure anyone official on to here yet. So I think the best thing to do is to start opening Bugzilla entries on these things. So please start logging them and then link back here too.

    @Xamarin's response to PCL bug reports is really clear - "All our PCL support is really unsupported" - so that might just ignore these Bugzilla reports, but I would expect Xam to want to urgently fix things like an empty error message - it'll be cheaper to make the error message than to answer support calls about it:

    But at the same time as saying PCLs aren't yet supported, I think everyone's now genuinely really keen to make this all work - e.g. on Mac we've been given this hack - https://files.xamarin.com/~jeff/MonoDevelop-c015b551ceb5f43c864b039b0abd487dd46b5dc2.dmg - love it :)

    Sorry - this is so painful. It is a transitional process - the future is portable :)

  • MihaMarkicMihaMarkic Miha Markic SIMember ✭✭✭
    edited March 2013

    Stuart, what branch is v2 (latest stable I presume) - is it vNext?

    Found - yes. Mentioned somewhere in the vNext branch description on GitHub.

  • StuartLodgeStuartLodge Stuart Lodge USBeta ✭✭✭

    @MihaMarkic Yes, currently:

    • master is v1
    • vNext is v2
    • vNextDialog needs to be removed (will add to my todo list)
    • v3 is work in progress for v3

    There are some binaries available on SkyDrive - see the binaries link on the right of http://slodge.blogspot.com

    The code is stable on Xamarin 1.0 . For XamDroid it also seems good on Xamarin 2.0. For Xamios ... some people seem to be running OK, others not so OK.

    For all platforms, the special MonoDevelop/XamStudio builds from @jstedfast are brilliant - help a lot with easing setup :)

    Getting the Mvx source and binary process into a cleaner state is high in the priority list for v3 - but it's a shifting target with platform changes, PCL changes, await/async, etc - so I do expect to still keep working at it :) I have customers who want me to keep the VSMonoTouch code alive because of where they are in their dev (and budget) cycles. Supporting 5 different target operating systems and multiple Xam and MS product releases simultaneously makes me feel a bit dizzy even with the help of PCLs ;)

    Stuart

  • MihaMarkicMihaMarkic Miha Markic SIMember ✭✭✭

    I somehow don't want to mess with PCL at this time (having Xamarin Studio installed). I am considering an automated process that would copy/modify csproj files to have Android projects instead (I am not interested in iOS, just Android and Windows) - for the time being. Shame that Xamarin doesn't support PCLs officially yet...

  • StuartLodgeStuartLodge Stuart Lodge USBeta ✭✭✭

    Sounds like an interesting plan :) Probably something I should have done last Summer - but I opted for the 'Stampy' route instead - opted to keep bashing my head against and eventually through the wall instead.

    For Android only, I think PCLs pretty much just work in VS and in XamStudio 2.0 on the Mac (with @jstedfast patch applied)

  • MihaMarkicMihaMarkic Miha Markic SIMember ✭✭✭

    "For Android only, I think PCLs pretty much just work in VS

    I'll see, but first I have to get my activation back :-S still waiting for activation fix ..

  • MihaMarkicMihaMarkic Miha Markic SIMember ✭✭✭

    Indeed it opens and compiles (v3 is still a bit chaotic solution, I need to fix it a bit). It looks like just referencing a PCL assembly from within VS is a problem. I mean if I manually edit csproj it works just fine. That said I am almost compiling the Tutorial.Droid - just a problem with newtonsoft.json remaining.

  • MihaMarkicMihaMarkic Miha Markic SIMember ✭✭✭

    Stuart, does debugger stops on breakpoints within PCL sources? Mine doesn't, it stops for Android sources though.

  • StuartLodgeStuartLodge Stuart Lodge USBeta ✭✭✭

    There are people you can lobby... both on the inside and outside of Xamarin. I hate to say it, but so far making noise seems to be more effective than not...

    Meanwhile, if anyone's interested then I've got the v3 code building on VS and XS... so next up is QA and documentation... more details on: http://slodge.blogspot.co.uk/2013/03/v3-code-reaches-alpha.html

    Will spend a lot of time on this next week!

  • StuartLodgeStuartLodge Stuart Lodge USBeta ✭✭✭

    V3 binaries are now being pushed to https://github.com/slodge/MvvmCross-Binaries

    I'm working on docs on the v3 pages on https://github.com/slodge/MvvmCross/wiki/_pages - this list will hopefully grow a lot v soon.

  • ChWoChWo Ch Wo DEMember

    Thanks @StuartLodge!

    I'm a bit confused about the actual situation.

    The v3 binaries are still alpha, aren't they? Should vNext users upgrade to v3 or is it better to wait a few weeks/months?

    After upgrading to v3 existing solutions may not work anymore due to a new ViewModel lifecycle . Can I make vNext solutions work with v3 when I use the old ViewModelLocator and register it as described on StackOverflow?

    You're talking about PCL issues using Xam.iOS inside VS2012. So is it possible to build PCLs against Xam.iOS from inside VS2012?

  • StuartLodgeStuartLodge Stuart Lodge USBeta ✭✭✭

    HotTuna is brand new

    v3 is in Alpha - which means you can use it but you may get hurt.

    v3 has significant changes from vNext. Porting code from vNext to v3 will be mostly trivial, but the number of assembly, class and pattern changes mean that you should not attempt porting without some time to spare and without a swear box.

    I think v3 is v v v awesome, but I've spent a lot of time porting code to it - and I do now have Tourettes.

    No Xamarin products contain any official support for PCLs right now - there are hacks to make them work - see this thread, beg for info from Xamarin, or join me sitting in a dark corner holding my knees, rocking backwards and forwards.

    Official PCL support was allegedly integrated into Xamarin products last week according to the Hanselminutes podcast... but I get no inside tips on when that means there will be public versions available. If in doubt, assume I'll find out the same time as you, if not afterwards.

    Should vNext users upgrade?

    Developers should think for themselves.

    Your App is king.

    Long live the king.

  • ChWoChWo Ch Wo DEMember

    Thanks, I think I will stay on the old tools and vNext for a while.

  • StuartLodgeStuartLodge Stuart Lodge USBeta ✭✭✭

    I'm planning on shifting v3 to Beta on Wednesday this week.

    After it's shifted to Beta then it will be a lot harder to change patterns, APIs, namespaces, etc - I'll be self-enforcing some 'stability'

    So if anyone has any HotTuna requests... then get them in today or tomorrow :)

  • jrimjrim Jordan Rimsa USMember
    edited March 2013

    Ok, I am confused. Just to clarify... The Xamarin download link has clear advertisements that say:

    • Android - Develop native Android apps
    • iOS - Develop native iOS apps

    from http://xamarin.com/download

    Is it actually possible to do iOS/Android cross-platform development with Xamarin out of the box, or are there hacks and other adjustments required? I've been reading through MvvmCross for the last hour or so, sorting through all of the fragmentation and disorganization, and it's difficult to grasp a status quo. I don't want to pay $299 for their tool if it requires hacks and isn't really supported! I also don't exactly understand if I even need Xamarin, or if I can just use my current developer environment (Visual Studio 2010) for Android/iPhone cross-dev using MonoCross.

    To that end, does vNext/v3 support iPhone+Android integration out of the box, without having access to a Mac? I thought I read in another thread someone referencing needing a Mac to support iOS/iPhone cross-development.

    By the way Stuart, let me give an enormous KUDOS to you for your excellent support habits and efforts. It is rare to find someone demonstrating so much accountability for their open source projects. You are a true idol for the open source movement, or I suppose just for online communication habits in general!

  • StuartLodgeStuartLodge Stuart Lodge USBeta ✭✭✭

    Thanks Jordan

    Is it actually possible to do iOS/Android cross-platform development with Xamarin out of the box

    Yes

    But if you had asked:

    Is is possible to use PCLs

    No

    For PCLs, you do still need some small 'hacks' but these are fairly small now. Within the next month I hope you won't need them - listen to Miguel speaking recently on Hanselminutes podcast for the reason behind that hope.

    You can develop without PCLs and the path that way isn't that painful.

    without having access to a Mac?

    Doing any iPhone development without access to a Mac is not worthwhile IMHO - Apple make it hard - you are welcome to try, but honestly you will burn more money in time than you can save on a $499 Mac Mini (which later will have a resales value of $399)

    For general questions on do you need Xamarin... yes, you need their license - which means:

    • $299 per product if you use XS
    • $999 per product if you use VS

    Don't bother starting on the free version - it's too small to do anything - so start with a 1 month trial instead.

    MonoCross

    Also relies on having a Mac and Xamarin

    Honestly, if you want advice about how to get started, I'm the wrong person to give advice - others here have gone through the pain&pleasure much more recently than me.

    However, if you are a c# coder, I think you'll find you get going very quickly. If you read through http://www.codeproject.com/Articles/566191/MvvmCross-v3-Writing-a-First-App you'll get the idea for MvvmCross.

    I am working on more docs and getting started soon - but I am holding off from documenting some of the current hacks - especially as they will change any day now...

    Stuart

«1
Sign In or Register to comment.