Creating Cross-Platform Apps with Xamarin: A Complete Guide for Modern Mobile Development

394 0 0 0 0

📘 Chapter 6: Publishing Your Xamarin App and Transitioning to .NET MAUI

🧭 What You’ll Learn

In this chapter, you’ll learn how to:

  • Prepare your Xamarin app for publishing on the Google Play Store and Apple App Store
  • Create signing keys, provisioning profiles, and distribution builds
  • Understand app store requirements, icons, and metadata
  • Use App Center, Azure DevOps, or CI/CD for automated builds
  • Migrate or transition your app from Xamarin.Forms to .NET MAUI
  • Understand changes between Xamarin and .NET MAUI
  • Prepare for the future of cross-platform development on .NET

🚀 Publishing Xamarin Apps

General Requirements

Before publishing:

  • Finalize app name, icon, splash screen
  • Verify bundle identifiers (iOS) and application IDs (Android)
  • Set build mode to Release
  • Enable app linking to reduce size
  • Set proper version numbers and build codes

📦 Packaging Android APK/AAB

Steps:

  1. Right-click your Android project → Properties
  2. Under Android Options, check:
    • Configuration: Release
    • Linker: SDK Assemblies Only
    • Generate Signed APK/AAB
  3. Set Application ID in AndroidManifest.xml
  4. Add version info:

xml

 

<manifest android:versionCode="1" android:versionName="1.0" />

  1. Generate keystore:

bash

 

keytool -genkey -v -keystore myreleasekey.keystore -alias mykey -keyalg RSA -keysize 2048 -validity 10000

  1. Sign APK/AAB using Visual Studio or Gradle

📱 Packaging for iOS

Prerequisites:

  • Mac with Xcode installed
  • Apple Developer Account
  • Created App ID, Provisioning Profile, and Distribution Certificate

Steps:

  1. In Info.plist: Set version and bundle identifier
  2. Configure Release > iPhone build settings
  3. Sign in to Apple Developer Portal and download the profile
  4. Archive your app using Visual Studio for Mac
  5. Use Application Loader or Xcode Organizer to submit

💼 App Store Submission Checklists

Google Play Store

Apple App Store

Android App Bundle (.aab)

Signed .ipa or Xcode archive

Play Console metadata

App Store Connect metadata

Screenshots (min 2 per size)

Screenshots (6.5", 5.5", 12.9")

Privacy policy link

Privacy policy + tracking details

Target API Level 33+

Minimum iOS version 12+


🔄 Automate with CI/CD and App Center

Microsoft App Center allows you to:

  • Build Xamarin apps in the cloud
  • Run tests on physical devices
  • Distribute builds to testers
  • Monitor crashes and usage

Sample YAML for GitHub Actions (Android)

yaml

 

name: Xamarin Android Build

 

on:

  push:

    branches:

      - main

 

jobs:

  build:

    runs-on: macos-latest

    steps:

    - uses: actions/checkout@v2

    - name: Install .NET

      uses: actions/setup-dotnet@v1

      with:

        dotnet-version: 6.0.x

    - name: Build Android

      run: msbuild MyApp.Android/MyApp.Android.csproj /p:Configuration=Release


💡 .NET MAUI: The Future of Xamarin

.NET MAUI (Multi-platform App UI) is the evolution of Xamarin.Forms, part of .NET 6 and beyond.

It enables development for:

  • iOS
  • Android
  • macOS
  • Windows (WinUI)

All from a single project and codebase, with unified APIs, better performance, and modern tooling.


🧬 Xamarin.Forms vs .NET MAUI

Feature

Xamarin.Forms

.NET MAUI

Project structure

Multiple platform projects

Single SDK-style project

UI definition

XAML + code-behind

XAML + code-behind

Performance

Good

Improved with startup tracing

Dependency injection

Manual

Built-in DI with .NET Extensions

Desktop app support

No

Yes (Windows + macOS)

Styling

Styles + Resources

Styles + Fluent + Themes

Shell navigation

Yes

Yes (Enhanced)


🔁 Migrating Xamarin.Forms to .NET MAUI

Migration Strategy

  1. Update to Xamarin.Forms 5 (last stable)
  2. Audit third-party packages for MAUI support
  3. Move logic to .NET Standard or .NET 6 compatible libraries
  4. Start a new .NET MAUI project:

bash

 

dotnet new maui -n MyApp

  1. Port your XAML pages and ViewModels
  2. Refactor platform-specific code into Platforms/ folders
  3. Test on all four platforms (Windows, Android, iOS, macOS)

Example: Platform Structure in .NET MAUI

 

MyApp/

── Platforms/

│   ── Android/

│   ── iOS/

│   ── macOS/

│   └── Windows/

── Resources/

│   ── Fonts/

│   ── Images/

── MainPage.xaml

── App.xaml.cs


Xamarin.Forms to MAUI Snippets

Xamarin.Forms:

csharp

 

MainPage = new NavigationPage(new HomePage());

.NET MAUI:

csharp

 

MainPage = new AppShell();


🔧 Tooling for MAUI

Tool

Purpose

Visual Studio 2022

Official MAUI support (v17.3+)

.NET CLI

Create/build/deploy MAUI apps

Hot Reload

Live UI previewing

.NET Upgrade Assistant

Helps upgrade Xamarin apps

App Center

MAUI integration (preview/partial)


Summary Table: Publishing vs Migration

Task

Xamarin.Forms

.NET MAUI

Publish Android

APK or AAB

AAB (Preferred)

Publish iOS

.ipa archive with Xcode

.ipa via VS or CLI

CI/CD support

Full with App Center

Partial but growing

Desktop deployment

No

Yes (Windows/macOS)

Migration tool

Manual or Upgrade Assistant

Built-in templates

Shared project format

Multi-targeted

Single SDK project


Summary

In this chapter, you learned how to:

  • Package and publish your Xamarin app for Android and iOS
  • Handle app signing, versioning, and deployment
  • Automate your release process using CI/CD
  • Monitor and distribute apps with App Center
  • Begin your migration from Xamarin.Forms to .NET MAUI
  • Understand the differences, advantages, and future scope of MAUI


Xamarin is stable—but MAUI is the future. As .NET unifies under one framework, MAUI offers an exciting evolution for cross-platform development.

Back

FAQs


❓1. What is Xamarin and how does it work?

Answer:
Xamarin is a Microsoft-backed open-source framework for building cross-platform mobile applications using C# and .NET. It allows developers to write shared business logic and optionally shared UI using Xamarin.Forms, while still accessing native APIs for iOS, Android, and Windows.

❓2. What is the difference between Xamarin.Forms and Xamarin.Native?

Answer:

  • Xamarin.Forms lets you write a single shared UI in XAML that runs on both Android and iOS.
  • Xamarin.Native (Xamarin.iOS and Xamarin.Android) provides full access to native UI APIs, meaning you must create platform-specific UIs but share backend code.

❓3. Can I build apps for iOS using Xamarin on Windows?

Answer:
Yes, but iOS apps must still be compiled on a Mac build host due to Apple’s restrictions. Visual Studio on Windows can remotely connect to a Mac to build and deploy iOS apps.

❓4. How much code can be shared between platforms in Xamarin?

Answer:
With Xamarin.Forms, you can share 90–95% of your code, including business logic and UI. With Xamarin.Native, you typically share 70–80%, with UI coded separately per platform.

❓5. Is Xamarin still relevant with .NET MAUI coming?

Answer:
Yes. Xamarin remains stable and supported, especially for existing projects. However, new projects are encouraged to use .NET MAUI, the evolution of Xamarin, offering broader platform support and modernized architecture.

❓6. Does Xamarin deliver native performance?

Answer:
Yes. Xamarin apps are compiled into native code (AOT on iOS, JIT on Android) and use native controls, which means the performance is on par with apps built using Swift, Kotlin, or Objective-C.

❓7. What programming language does Xamarin use?

Answer:
Xamarin uses C# as the primary programming language, supported by the .NET platform. You can also use XAML for defining UIs in Xamarin.Forms.

❓8. What tools are required to develop with Xamarin?

  • Visual Studio 2022 or later (with Mobile Development workload)
  • .NET SDK
  • Xamarin SDKs (included with Visual Studio)
  • Mac build machine (for iOS development)

❓9. Can I access device-specific features like camera or GPS?

Answer:
Yes. Xamarin provides bindings to native APIs, and Xamarin.Essentials offers cross-platform access to common features like camera, sensors, geolocation, battery, and connectivity with a unified API.

❓10. What are the alternatives to Xamarin for cross-platform development?

Answer:
Some popular alternatives include:

  • Flutter (Dart-based, Google)
  • React Native (JavaScript-based, Meta)
  • .NET MAUI (Xamarin’s successor, Microsoft)
  • Cordova/Capacitor (Web-based hybrid apps)

Each has its own pros and cons depending on the use case, team skills, and performance requirements.