Find a consulting partner to help you take your business mobile, ramp up with Visual Studio and Xamarin, and build higher quality mobile solutions. Long-term strategic partners are mobile experts who can guide you through any stage of the app lifecycle and will help you design, develop, and test high-performing cross-platform mobile apps. Xamarin brings open source.NET to mobile development, enabling every developer to build truly native apps for any device in C# and F#. We’re excited for your contributions in continuing our mission to make it fast, easy, and fun to build great mobile apps. Xamarin.Mac, as with Xamarin.iOS and Xamarin.Android, gives developers up to 90% of code reuse across Android, iOS and Windows. Xamarin.Mac gives C# developers the ability to build fully native Cocoa apps for macOS and allows for native apps that can be put into the Mac App Store.
Back in .NET Conf 2017 The Xamarin team already shared what’s going to be new with Xamarin Forms 3.0 and it actually surprised me. I was expecting some performance improvements, bug fixing and a big upgrade on XAML. But, what they announced focuses on enabling the usage of Xamarin.Forms in more ways and on more platforms. I was really hoping for XAML improvements, maybe add some cascading styling like how CSS works. Maybe sometime in the future, we’ll get it. For now, I’ll just use the XAMLCss by warapa. Anyway if you want to watch all sessions from .NET Conf 2017, you can check it out on Channel9. Going back, I really didn’t expect these new features, but definitely, I love it and really excited to try it out!
That’s why right now, I’m going to show to you one of the exciting features added to the Xamarin.Forms 3.0 that I think you’ll also love. I’m talking about Xamarin.Form’s macOS support.
One of the Xamarin team’s plan is to reach more platforms. That means UWP, iOS and Android are not only platform the Xamarin.Forms will be able to target from now on, they are also bringing macOS, GTK#, Linux and WPF!
You might think that it will be hard and will take a lot of time to integrate your Xamarin.Forms solution into the macOS project, but it’s not. Not at all. You’ll be able to create a native macOS application using your Xamarin.Forms solution using Visual Studio for Mac or Xamarin Studio in just 3 quick steps!
First step: Add a Cocoa App project
Right now, Xamarin.Forms template doesn’t have a Cocoa App initially. So, what you would do is to start Visual Studio for Mac or Xamarin Studio and open your existing Xamarin.Forms solution. Then, add a project into the solution by right-clicking the solution and selecting Add > Add New Existing Project.
Xamarin Studio Mac
You can then select Mac > App > Cocoa App and name it whatever you want, but ideally, the name has a suffix of .macOs.
Second Step: Add the Xamarin.Forms NuGet Package
You will have to add the Xamarin.Forms’ latest pre-release nuget package or specifically 2.4.0.282. To do this, right click the Cocoa App project that you just created and select Add > Add Nuget Packages.
Then, search for ‘Xamarin.Forms’ and make sure that the ‘Show pre-release packages’ is ticked. Click ‘Add’ to add Xamarin.Forms nuget package.
You will also need to update the Xamarin.Forms on your shared project and the version should be the same with what the Cocoa app have.
Xamarin Mac Agent
Third Step: Configure the Cocoa App Project
The first thing that you should do with your Cocoa app project is to add the shared project into your Cocoa app as a reference.
Then, open the Info.plist and remove the ‘Main storyboard file base name’ entry (Opened with XCode)
Or just open the Info.plist inside Visual Studio or Xamarin Studio by clicking it and leave the Main Interface blank.
The next one is to update your Main.cs’ Main method to initialize the AppDelegate:
Lastly, update the AppDelegate by changing the NSApplicationDelegate to FormsApplicationDelegate:
Initialize the Cocoa app window within the constructor:
Then inside the DidFinishLaunching method, initialize Xamarin.Forms and load the application:
You can now set your project as the startup project and run your macOS!
![Xamarin mac desktop app Xamarin mac desktop app](/uploads/1/3/4/1/134153294/151221547.png)
Again, in just 3 quick steps, it’s done!
This is just a basic walkthrough since this is still on preview. Expect that there are still bugs and not ready for production. Not all nuget packages are compatible and surely, there are lots of UI features still not implemented, but this is a good start. For now, you can send your issues and problems that you encounter in this forum discussion: https://forums.xamarin.com/discussion/93585/preview-xamarin-forms-for-macos/p1
As mobile applications are proving to be one of the greatest assets, maintaining and making them easily attainable for the users is utterly important. With billions of android app downloads each year, developers need to present the best before deploying their app on the Google Play store.
The first and foremost that pops up in our mind is the size of the app. Users all across wish to download apps that occupy less space and leave an everlasting impact. Whether it’s an update or a fresh download, it is recommended to keep your app’s size down and then deploy it to the play store.
Xamarin plays the best role here!
Xamarin Forms Mac
Helping developers in reducing the size of their app while keeping its impression intact, Xamarin development offers some simple yet effective ways for the same.
Let’s know about them.
Linking The Libraries
In order to reduce your app size, Xamarin applications use a “linker. With the help of static analysis, it removes assemblies and types that are of no use in the app and brings down the size. For instance, a developer tried reducing his app(Hello World) from 16 MB to 2.9 MB. There are three settings that you can supply from the project’s settings:
In order to reduce your app size, Xamarin applications use a “linker. With the help of static analysis, it removes assemblies and types that are of no use in the app and brings down the size. For instance, a developer tried reducing his app(Hello World) from 16 MB to 2.9 MB. There are three settings that you can supply from the project’s settings:
Don’t Link will do just that, it won’t link anything and you will be left with All of Mono, mscorlib, Xamarin.Android, and a bunch of other stuff:
Xamarin App Tutorial
Linking SDK Assemblies is your safest bet and should be your default as it only attempts to strip things out of Xamarin.Android without disturbing any of your third-party libraries. However, to bring down your app size significantly, you should pot for Link All Assemblies Mac fan cooler app. , as it investigates everything and then does the required sizing.
Be sure to carefully test your app as sometimes the linker might be aggressive and end up striping out something important. In that case, use a [Android.Runtime.Preserve] flag or set a linkskip in your MSBuild to ensure that not all of your libraries get linked.
Hope this proves helpful. You can also browse through the documentation and find out how this works in detail.
Splitting APKs
In Android, there are ABIs (Application Binary Interfaces) that can be supported when you ship your application. The most used is armeabi-v7a, however, there are still tons of devices that support and run the old armeabi ABI and even x86 devices. Thus, in order to that your app reaches the most users, you must have selected every single in the project settings.
In Android, there are ABIs (Application Binary Interfaces) that can be supported when you ship your application. The most used is armeabi-v7a, however, there are still tons of devices that support and run the old armeabi ABI and even x86 devices. Thus, in order to that your app reaches the most users, you must have selected every single in the project settings.
However, for every ABI that you select, you are actually bundling a separate libmonodroid and sgen with your app. Can’t agree? Then, rename your .apk to .zip and take a look in the lib folder:
This, of course, makes sense as you would need a different version of monodroid and sgen that supports the particular ABI. The issue is, now when you have all of these libraries bundled into a single APK, your users will be downloading all of them! The solution for any Android developer (even Java devs) is to simply split up the APKs and upload all of them to Google Play!
This way you end up having a smaller app size across all three APKs.
You can do this now with a simple check in your project options:
So, now instead of just a single APK to upload, we have three different and smaller sizes:
- armeabi-v7a: 10.2MB
- armeabi: 10.3MB
- x86: 10.4MB
Kindly Note:
You may need to close XS after selecting check box and ensure this flag is set in your csproj:
<AndroidCreatePackagePerAbi>true</AndroidCreatePackagePerAbi> Mac display color app.
Additionally, your new APKs will be in your /bin/Release folder and will be marked with Signed in their file name.
Xamarin Forms Mac App
Adopt these simple tricks and get set going!
For any further details and information, contact an expert xamarin developer and be prepared for an outstanding app response.