Forum Cross Platform with Xamarin

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

First approach and first question(s)

Hi,

I'm a newbie of this type of programming. I'm testing the trial version and I wonder why, when I start a new xamarin.form project (cross-platform), it asks me to link it with a mac. Why? And why if I try to run an android app, it starts looking for a device?

I'm using it with visual studio. Maybe is it better if I use it with xamarin studio? (but why, in xamarin studio, the ios radio button is grey and not enabled?)

Sorry for the dumb questions, I hope you will help me :)

Answers

  • When you create a new Xamarin.Forms solution, you have 4 different Projects in there. A PCL library (or that shared thing) an Android Project, an iOS Project ans a WinPhone project. To be able to compile the iOS project you will need a build host, like a mac mini or something ,therefore it asks you to link it to one.

  • PippodePippode USMember

    But, so... I need to write 4 different project? I was thinking the cross platform works with one project, then it is compiled in 4 different native languages... so it isn't... or not? Have I to write 4 different projects? Where are the advantages?

  • DavidStrickland0DavidStrickland0 USMember ✭✭✭

    It is possible to Ignore the other 3 and just work with the one. You should have 1 project that has no .xxx extension this is your PCL and the Core of Xamarin Forms.

    When you write your app this PCL is were the majority or all of your code goes. The things that you can do in the PCL are things all three platforms have in common at some level. So Yes Xamarin Forms will let you write one codebase for your app to share across x number of platforms. However at some point your going to want to get at a that new feature on IOS9 that android doesn't have or your going to want to react to a hardware component only Android talks to Xamarin Forms also lets you get access to these features by writing platform specific code. How often you go out and write code in the platform is up to you. You can write your entire app 3 times and never touch the PCL or put it all in the PCL most apps end up somewhere in the middle.

    Code in the PCL is much easier to test, standard unit tests can be used and its by definition portable to any of the X number of flavors of the .Net Framework. Thus it runs on windows or on whatever development environment your working on. On the the other hand the Platform specific code only runs on the platform its targeted for so you can only test it on those platforms or in an emulator for those platforms. The more code there is in the PCL the easier it is test and maintain.

Sign In or Register to comment.