The Xamarin Show 1: Sharing Code Across iOS, Android, and Windows

Download this episode

Download Video

Description

Welcome to The Xamarin Show, your weekly native cross-platform mobile development show with your host James Montemagno. Each week join James and his guests as they discuss building mobiles apps, integrating SDKs, extending mobile apps, the latest Xamarin news, awesome apps developers are building, and so much more. On this weeks episode we take a look at how to share code across iOS, Android, and all of the Windows platforms. There are many strategies to help share code across a single application or across several applications and we explore all of them! 

Segments:

Show Links:

Embed

Format

Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      jerocis

      Many presenters begin a talk by saying that they are "super excited" about their topic. James is one of the very few whose voice actually backs up that claim throughout the presentation. Great video! I'm looking forward to next week's show.

    • User profile image
      Ashish Jain

      How share code in Blank App (Xamarin.Forms Portable)? It will be very helpful. How i am sharing code?
      1) I am creating models in portable project.
      2) Creating UI using xaml pages
      3) Calling MainPage = new Welcome() page into App.cs.

      Now struggle point where i should write code for navigating from one page to another page and during showing splash screen where i should write the background database creating code?

      I have search many solutions but not worked even on xamarin support forums show partial tutorials. During tutorial they have not mentioned which template they are using so it is very confusing for beginners.

    • User profile image
      yootha

      Ashish if you haven't seen it already then I would suggest you take time to look through Charles Petzold's free ebook "Creating Mobile Apps with Xamarin.Forms" - a quick search of that title will find it online

       

       

    • User profile image
      John

      I was just wondering what you were using the show the phone emulators James?

    • User profile image
      Hines

      @John he said he was using Vysor (https://chrome.google.com/webstore/detail/vysor/gidgenkbbabolejbgbpnhbimgjbffefm?hl=en-US)

    • User profile image
      John

      @Hines: Thanks, I must have missed that bit :)

    • User profile image
      Jasker

      Hello James, thanks for this. Explains a lot for me as a beginner. So, you create this app and what if you want to get an audio and visual warning when you are driving around and want to know when there is a coffeeshop around. We have an app that does something similar, but it is always a problem when dealing with bluetooth car systems. One has music streaming and doesn't want it to be interrupted. Android had about 4 different channels and different volume settings wether the sound is connected with BT or not. It is the most received user complaint that we get. If you could explain something about it, it would be very helpfull

    • User profile image
      James​Montemagno

      @John: I also have a great blog post that shows all the different platforms: http://motzcod.es/post/90610802117/screen-mirroring-for-ios-android-and-windows

    • User profile image
      James​Montemagno

      @Jasker: I would definitely ask on the forums to see what the best approach is as there is probably a priority that you can request.

    • User profile image
      James​Montemagno

      @Ashish Jain: that template creates a portable class library to write all of your shared code in. That would be where your models, views, databases, etc would be. Here are the Forms docs and that book https://developer.xamarin.com/guides/xamarin-forms/

    • User profile image
      RaReRa

      Hi James, thanks this was a great video. Can you please also share some information about the setup for IOS. Many of us are not really "Mac people" so we would just need a not too expensive Mac for builds and may be simulation.

      The minimum requirement seems to be met by "Early 2009" Macs. Would a Mac Mini "Early 2009" with 2 GB RAM be enough for building mid size projects. Do you have some experience values to share?

      Thank you!

    • User profile image
      James​Montemagno

      @RaReRa: So I actually just communicate to a standard MacBook, which is a small 1.2ghz dual-core core m3 processor with 8gb ram. it works really nice as I need it to be portable and let my Surface Book do the heavy lifting. 

      If you don't need protability then a Mac Mini is just fine, the thing to watch for is that it must be able to run the latest version of macOS and I would recommend at minimum 4GB and then of course a hard drive that can handle some storage on it.

      So the 2010 Mac Mini is the oldest version that can run Sierra(http://www.macrumors.com/2016/06/13/list-of-macos-sierra-compatible-macs/) so you would want something probably even earlier then that since you don't want it to be out of date next year, 2012 or 2014 would be my recommendation. You can find specs and serial numbers here from Apple: https://support.apple.com/en-us/HT201894

       

    • User profile image
      Versive

      Hi James,

      Thanks for an enthusiastic kick off. 

      I'm wondering if you are going to post the solution that you made? 

      If not, maybe you could point me towards a good article that has iOS,Android,UWP with a shared code "mvm" style and separate ux (not Xamarin Forms) and has the wire up to the Azure backend entities and mobile services - something maybe with the Azure service wrapper class your friend wrote that you mentioned you were using? 

      I keep looking for a sample just big enough to have two or more views so I can practice getting the pattern of mapping to the cross-platform mvm bits to the different ux desiger classes on each platform.

      May be too much to ask, but it never hurts to try and thanks again.

      Dave Gerding

       

       

    • User profile image
      StretchMan

      Great first show! 

      Would be nice to be able to have access to the solution.... Any plan to share code you use on these shows ?

       

      Guy

    • User profile image
      James​Montemagno

      @StretchMan: I have added a link to the GitHub repo where you can find all of the code from the show and future episodes: https://github.com/jamesmontemagno/TheXamarinShow

    • User profile image
      MhAlan

      Who said we want to write code for multiple platforms in the same class? the portable library should just have interfaces, abstracts, and cross platform code, any code that is platform specific should be overridden through inheritance.

    • User profile image
      JohnDB

      @JamesMontemagno: that's great, I'll take a look at your blog, thanks James

    • User profile image
      StretchMan

      @JamesMontemagno:Great, thanks a lot for the awesome work and long live The Xamarin Show!

    • User profile image
      RaReRa

      Hi James,

      thanks for the detailed answer. Actually I had read that the minimum requirement for Mac OS was 10.10 Yosemite (https://developer.xamarin.com/guides/cross-platform/getting_started/requirements/#mac) , so I thought a Mac Mini Early 2009 can make it.

      For better performance I wanted then to go for Mid 2009 (4GB) which is quite affordable on ebay.

      With my App I anyhow want to support all iPhones 4s and higher.

      Is it a must with Xamarin to have the latest Mac OS or could I just stick with an older version if I anyhow want to have it run on old devices?

      Last question some Mac Minis that I found on ebay have the server version of Mac OS installed, do you know if that will do the job?

      Thanks again!

       

       

    • User profile image
      JonasR

      Great first show! thanks...

      How do "Plugins" https://github.com/xamarin/XamarinComponents fit into the three ways listed above as another way of sharing code across platforms?

    • User profile image
      Alex

      Guys what app was used to share screen from Android?

    • User profile image
      James​Montemagno

      @JonasR: So "Components" are libraries specific to iOS/Android such as google play services or facebook SDKs. Plugins are amazing and I actually have made a lot that you will see on that page is an abstraction of platform specific APIs into an easy to use cross platform API. The easiest way to add platform specific functionality.

       

      @Alex: Check out this video: https://channel9.msdn.com/Shows/XamarinShow/Snack-Pack-1-Android-Emulators I cover all of it there.

    • User profile image
      LizardKing

      @RaReRa:You might want to try Mac In Cloud: http://www.macincloud.com/.  You don't need to buy anything, just rent via a VM online. 

    • User profile image
      Dani

      Could you add some subtitles to these videos? Great work by the way, although I get lost sometimes because of my english understanding

    • User profile image
      Nandhini

      James, Just today I joined your crew.... How to create on with building apps.... Can you suggest me with few videos, that help me to start up

    Add Your 2 Cents