Is it possible to use MvvmCross with Shared Projects, or a similar technique of sharing code between projects? If so, How?
It seems MvvmCross is built around using PCL. If I use PCL, how do I overcome the problem of not being able to reference platform-specific 3rd-party libraries?
Thanks.
You can manually add App.cs class to your shared project. The same way you need to add your view models and other code. All namespaces will be automatically resolved. Look for solution explorer. In my case AppInit.cs inherits Cirrious.MvvmCross.ViewModels.MvxApplication
Related
Being familiar with mvvmlight, I'm now starting to look into using mvvmcross instead given the nice ability to use it with Xamarin to eventually also support my code on ios and android. However, I'm not there yet and would like to avoid taking a dependency on xamarin as long as I'm not actively targetting platforms other than WP8.1 and Win8.1.
Question: can mvvmcross be used without dependency on xamarin? (From my research so far my understanding is that mvvmcross is closely linked to usage with xamarin; even to the extent they share libraries? Would love to understand to what extent there's a hard dependency.)
As an alternative approach is there anyone successful in using mvvmlight for cross platform dev?
Kind regards
Yes it can - the core of MvvmCross is PCL - it's portable.
Xamarin is used only for Xam.Android, Xam.iOS and Xam.Mac - you can use WP, WinRT, WPF, MonoMac, Unity, etc without any Xamarin products.
I'm just reading up about the inbuilt IoC of MVVM Cross and how it makes heavy use of reflection. Just wondering, does this cause issues with Xamarin linking? What are people finding best practise in this area? Using "Link SDK assemblies only" or perhaps configuring IoC in a way that avoids reflection?
Thanks in advance :-)
Both MvvmCross IoC and MvvmCross binding rely on Reflection.
Because of this, users often use "Link SDK assemblies only" and often use "LinkerPleaseIgnore" files.
You can read more about this on:
https://stackoverflow.com/questions/10224376/mvvmcross-experiences-hindsight-limitations/10225623#10225623
Problems with mvvmcross Binding on IOS (Works on Simulator, but some properties doesn't work on the Device)
... and many more https://stackoverflow.com/search?q=[mvvmcross]+linker
The MvvmCross nuget packages ship with default "LinkerPleaseIgnore" files - e.g. https://github.com/MvvmCross/MvvmCross/blob/v3.1/nuspec/TouchContent/LinkerPleaseInclude.cs.pp
I'm writing a plugin but I need a specific implementation for each Windows Phone version.
The problem is that the plugin system will try to load the platform plugin assembly based on a convention. In this case, "WindowsPhone".
We may try to override CreatePluginManager but then it will affect the rest of the plugins you may need.
I'm thinking of generating two different projects with different names but the same assembly and namespace. This, I think, would solve the problem of loading the specific plugin but I don't really know how to face an eventual publication to Nuget.
Best regards,
Roberto.
Generating assemblies with the same name is a viable way to go - it is something that the Microsoft Pcl teams do quite frequently - it is how the reference assemblies work.
The nuget distribution of these shouldn't be an issue - but would be a "faff" - as the nuget zip file would use different folders for the different files. There might, however, be some work to do at the .targets level if you want a single project to build both wp7 and wp8 configurations (this is similar to the effort needed for x86/x64/arm variants of assemblies in winrt nuget packages).
In fact, the main reason I can think for not using the same name is the very simple reason that it's far too easy to get in a muddle that way.
If for this one plugin, you wanted to override the plugin manager during setup, you could provide custom loading functionality based on
inheriting from https://github.com/slodge/MvvmCross/blob/v3/CrossCore/Cirrious.CrossCore/Plugins/MvxFilePluginManager.cs
and then overriding protected virtual string GetPluginAssemblyNameFrom(Type toLoad) to add a special based on some property of toLoad - eg if (toLoad.Name.EndsWith("Foo")) toReturn += PlatformPostfix
If this pattern becomes common - whether for wp or for the other versioned platforms - then we could include something back into the framework - it would be easy enough to try a version-neutral load followed by a version-specific load for every plugin.
There are also other ways you could go about this too...
E.g. Another possibility/opportunity is that your plugin core file could try loading multiple platform adaptions itself - eg using code like
public void EnsureLoaded()
{
var manager = Mvx.Resolve<IMvxPluginManager>();
manager.TryEnsurePlatformAdaptionLoaded<PluginLoader>();
manager.TryEnsurePlatformAdaptionLoaded<Sub1.PluginLoader>();
manager.TryEnsurePlatformAdaptionLoaded<Sub2.PluginLoader>();
}
This would try loading three child assemblies for that plugin - MyPlugin.WindowsPhone, MyPlugin.Sub1.WindowsPhone and MyPlugin.Sub2.WindowsPhone although you would only package one of these on each platform.
the only IDE I've used for many years was Flash Builder. Sadly the 4.7 version is in a poor state, so, I started looking at other IDE's lately.
I'm trying IDEA, but I don't know how to add a library to my project.
In FB it was simple, I go to the compiler settings and I just add a folder or swc. But here, it seems like there are 2 options, one under the "Libraries" tab and other is creating a new module, however, this new module requires a main app, SDK, and a lot of other stuff that doesn't make any sense to have in a library.
So, what is the equivalent of adding a library path here?.
Thanks.
"Libraries" is the correct way to do it. There are two kinds of libraries: libraries and global libraries. Global libraries can configured once and used in every project. Libraries are configured for each project. See http://www.jetbrains.com/idea/webhelp/configuring-project-and-global-libraries.html
VS gives me errors when I try to do it. Yet, it displays such projects as available to reference. Is it possible to add winRT project reference to the classic class library project somehow?
If not, how to bridge both worlds, so common logic can be stored in one place?
The short answer is yes. The long answer is that it's not supported and comes with some caveats that you need to understand.
See my answer here:
Using Custom Windows Runtime Components in Non-Metro Applications
VS2012 adds a "Portable Class Library" project type that allows you to select multiple targets, including the ability to target WinRT and full .Net 4.5 from one assembly.
See http://msdn.microsoft.com/en-us/library/gg597391.aspx.