Skip to content

aerogear/xamarin-showcase-template

Repository files navigation

Secure Xamarin Template

Android Compatible green iOS Compatible green

Project Info

License:

Apache License, Version 2.0

Build:

msbuild

End User Documentation:

https://docs.aerogear.org

Community Documentation:

https://aerogear.org

Issue tracker:

https://issues.jboss.org/browse/AEROGEAR

Mailing lists:

aerogear-dev

A Xamarin Application that demonstrates features of the Aerogear Xamarin SDK on iOS and Android.

For more information, please check the Mobile Security Project.

Prerequisites

The following softwares must be installed in order to be able to compile the application:

Get the sources

The master branch will always track to the latest release of the SDK.

$ git clone git@github.com:aerogear/xamarin-showcase-template.git
$ cd xamarin-showcase-template

Run the application

A Xamarin application can run on both iOS and Android.

Run on iOS Simulator with Visual Studio

$ open xamarin-showcase-template.sln
  • A Visual Studio window will open. In the top bar, choose Example.iOS→Debug→iPhone 8 iOS 11.4.

  • Click on the play button

Run on Android emulator with Visual Studio

$ git clone git@github.com:aerogear/xamarin-showcase-template.git
$ cd xamarin-showcase-template
$ open xamarin-showcase-template.sln
  • A Visual Studio window will open. In the top bar, choose Example.iOS→Debug→YOUR_DEVICE (for example: nexus_5x_api_27 (API 27))

  • Click on the ▶️ button

If there is no available devices in your environment, they can be added from within Visual Studio by clicking on Tools→Device Manager

Run on iOS Simulator from command line

  1. Add the Xamarin and mono tools executables to the path

    $ export PATH=$PATH:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
  2. Compile the sources

    $ nuget restore
    $ msbuild xamarin-showcase-template.sln /p:Configuration=Debug /p:Platform=iPhoneSimulator /t:Clean,Rebuild
  3. Choose the device to be used to run the app

    $ export DEVICE=":v2:runtime=com.apple.CoreSimulator.SimRuntime.iOS-11-4,devicetype=com.apple.CoreSimulator.SimDeviceType.iPhone-8"

    The available list of runtimes can be obtained with

    $ xcrun simctl list runtimes

    while the list of available devices can be obtained with

    $ xcrun simctl list devicetypes
  4. Run the application on the selected device

    $ mtouch  --device=$DEVICE -launchsim ./Example.iOS/bin/iPhoneSimulator/Debug/Example.iOS.app

Run on Android emulator from command line

To run the showcase app

  1. Add the Mono and Android tools executables to the path and setup the environment

    $ export SDK_HOME=$HOME/Library/Android/sdk
    $ export PATH=$PATH:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin:$SDK_HOME/tools:$SDK_HOME/platform-tools
  2. Compile the sources

    $ nuget restore
    $ msbuild Example.Android/Example.Android.csproj /p:Configuration=Debug /p:EmbedAssembliesIntoApk=True /t:Clean,Rebuild,SignAndroidPackage
  3. Get the launchable activity name

    $ export AAPT=`find $SDK_HOME/build-tools/ -name aapt | sort -r | head -n 1`
    $ export ACTIVITY=`$AAPT dump badging Example.Android/bin/Debug/org.aerogear.xamarin.Example-Signed.apk | grep launchable-activity | perl -pe "s/.*name='(.*?)'.*/org.aerogear.xamarin.Example\/\1/"`
  4. Start the android emulator

    $ emulator -avd nexus_5x_api_27 -partition-size 512

    The list of available avd can be obtained with

    $ emulator -list-avds

    If no avds are available, the easiest way to add one is to open Visual Studio and click on Tools→Device Manager.

  5. Install the Showcase app APK into the emulator and run it

    $ adb -e install -r  ./Example.Android/bin/Debug/org.aerogear.xamarin.Example-Signed.apk
    $ adb shell am start -n $ACTIVITY

Work with Self-signed Certificate

License

Questions?

Join our user mailing list for any questions or help! We really hope you enjoy app development with AeroGear!

Found a bug?

If you found a bug please create a ticket for us on Jira with some steps to reproduce it.