Disclaimer: this is an automatic aggregator which pulls feeds and comments from many blogs of contributors that have contributed to the Mono project. The contents of these blog entries do not necessarily reflect Xamarin's position.

January 23

Better Resource Organization in Xamarin.Forms

Resource Dictionary is a foundational building block to all Xamarin.Forms mobile development. It’s the primary vehicle for declaring XAML resources you’ll use throughout your mobile application, including everything from styles to value converters, content templates, and data templates. In the most recent stable release of Xamarin.Forms, we gained the ability to merge multiple resource dictionaries for even greater flexibility in composing resources. In this article, I’ll show you how to take advantage of that and give you a glimpse at some of the new syntax improvements coming your way.

Merged Dictionaries

Out with the Old

Prior to 2.5.0, you probably found yourself implementing a single resource dictionary per ContentPage or other control. Every control has a Resources property of type ResourceDictionary where you declare reusable resources.

<Application ...>
    <Application.Resources>
        <ResourceDictionary>
            <Color x:Key="PageBackgroundColor">Yellow</Color>
            <Color x:Key="HeadingTextColor">Black</Color>
            <Color x:Key="NormalTextColor">Blue</Color>
            <Style x:Key="LabelPageHeadingStyle" TargetType="Label">
                <Setter Property="FontAttributes" Value="Bold" />
                <Setter Property="HorizontalOptions" Value="Center" />
                <Setter Property="TextColor" Value="{StaticResource HeadingTextColor}" />
            </Style>
        </ResourceDictionary>
    </Application.Resources>
</Application>

You might define colors and styles that you wish to use throughout your application at the Application level in this code.

If you’re really industrious, you might have discovered that you merge one dictionary with another using the MergedWith property.

<Application ...
    xmlns:local="using:MyApplication">
    <Application.Resources>
        <ResourceDictionary MergedWith="local:Colors">
        <Style x:Key="LabelPageHeadingStyle" TargetType="Label">
            <Setter Property="FontAttributes" Value="Bold" />
            <Setter Property="HorizontalOptions" Value="Center" />
            <Setter Property="TextColor" Value="{StaticResource HeadingTextColor}" />
        </Style>
        </ResourceDictionary>
    </Application.Resources>
</Application>

In this example the primary dictionary is being merged with another resource dictionary of colors.

<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="MyApplication.Colors">
    <Color x:Key="PageBackgroundColor">Yellow</Color>
    <Color x:Key="HeadingTextColor">Black</Color>
    <Color x:Key="NormalTextColor">Blue</Color>
</ResourceDictionary>

Using a ResourceDictionary in this fashion requires a code file to declare the class.

...

public partial class Colors : ResourceDictionary
{
  ...
}

In with the New

This syntax gets much cleaner with the new implementation of merged dictionaries, and you can merge multiple dictionaries instead of just the one. Instead of using MergedWith, you now add to a new MergedDictionaries collection property.

<Application ...
    xmlns:local="using:MyApplication">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <local:Colors />
                <!-- Add more resource dictionaries here -->
            </ResourceDictionary.MergedDictionaries>
            <Style x:Key="LabelPageHeadingStyle" TargetType="Label">
                <Setter Property="FontAttributes" Value="Bold" />
                <Setter Property="HorizontalOptions" Value="Center" />
                <Setter Property="TextColor" Value="{StaticResource HeadingTextColor}" />
            </Style>
        </ResourceDictionary>
    </Application.Resources>
</Application>

A big thanks to Microsoft MVP Adam Pedley for his proposal and initial pull request for merged dictionaries and for working with us to make this happen.

Upcoming ResourceDictionary Improvements

The next major version of Xamarin.Forms will introduce several improvements to ResourceDictionary in XAML, which you can get a taste for now in the nightly build feed.

Pure XAML ResourceDictionaries
You’ll notice the Colors.xaml needs to have a partial class to accompany it in the example above, even though it’s totally empty. That’s no longer required in the nightly build, where you can declare a XAML file without any Class and it will still be compiled with XAMLC.

Here’s another file Colors.xaml example, which contains all the colors to be used in an application.

<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
    <Color x:Key="AccentColor">#FF4B14</Color>
    <Color x:Key="BlackOpacityColor">#99253748</Color>
    <Color x:Key="BlackTextColor">#253748</Color>
    <Color x:Key="BackgroundColor">#F8F8F8</Color>
    <Color x:Key="PinkColor">#ED0241</Color>
    <Color x:Key="GrayColor">#ACB1B4</Color>
    <Color x:Key="DarkColor">#203446</Color>
    <Color x:Key="WhiteColor">#FFFFFF</Color>
    <Color x:Key="GreenColor">#368F95</Color>
</ResourceDictionary>

More Concise Syntax
XAML can get pretty verbose as you declare all the resources for your application, so we’ve done some work to cut the corners and save some keystrokes. Instead of writing:

<ContentPage.Resources>
  <ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Colors.xaml" />
    </ResourceDictionary.MergedDictionaries>
    <StyleSheet Source="style.css" />
    <Color x:Key="notgreen">FF00FF</Color>
  </ResourceDictionary>
</ContentPage.Resources>

You can simply write:

<ContentPage.Resources>
  <ResourceDictionary Source="Colors.xaml" />
  <StyleSheet Source="style.css" />
  <Color x:Key="notgreen">FF00FF</Color>
</ContentPage.Resources>

In this new syntax:

  • Source: You can now load your dictionary with the new Source property. The file should be relative to the document or absolute from the application root
  • No need to specify a top level <ResourceDictionary>, as it’s now created on demand
  • No need to specify <ResourceDictionary.MergedDictionaries> if your StyleSheet or ResourceDictionary is keyless

These improvements provide more flexibility for you to organize your application resources and compose them on a control however you need them.

Be Resourceful

Multiple merged dictionaries are available today on NuGet in the Xamarin.Forms 2.5.0 stable release. Be sure to also check out the nightly feed and explore the new features we have on the horizon.

Do you have an idea or request like Adam’s that you’d like to contribute? Start by exploring the enhancements project board on GitHub, and then open an enhancement proposal.

The post Better Resource Organization in Xamarin.Forms appeared first on Xamarin Blog.

January 22

The What, Why, and How of Mobile DevOps with Visual Studio App Center

With constant operating system releases, ever-shifting user expectations, and new form factors launching every year, making sure your apps are high-quality, take advantage of the latest technology, and deliver features that win users’ loyalty can feel like multiple full-time jobs.

The solution: mobile DevOps and automation, so you’re freed to focus on building new features and improving your users’ experience, not manual processes. Enter Visual Studio App Center, which brings all the cloud-hosted services you need to simplify and automate your Android, iOS, UWP, and macOS development pipeline into one easy-to-use service.

To help you get started with Visual Studio App Center and apply mobile DevOps to your development pipeline, Greg Shackles, Principal Engineer at Olo, Xamarin MVP, and Microsoft MVP, shares his experiences and advice for developers, from beginner to advanced, based on his work on 150+ apps for major brands. His Visual Studio App Center blog series includes step-by-step guidance and best practices for setting up continuous builds and automated UI testing, deploying to testers and app stores, and capturing and analyzing real-time analytics.

Read Greg’s series to implement, or improve, end-to-end mobile DevOps:

If you haven’t already, create your free Visual Studio App Center account here, connect your first app, and start shipping better apps now.

The post The What, Why, and How of Mobile DevOps with Visual Studio App Center appeared first on Xamarin Blog.

January 19

Running Xamarin.iOS Unit Tests in Visual Studio Team Services

In previous posts, we’ve discussed how to set up continuous integration for your Xamarin.iOS applications inside Visual Studio Team Services(VSTS) using the new Hosted macOS Agent. Building the application is only part of the full solution, though, as we want to fully test the logic of our application. We can test our app’s user interface with App Center Test, we can test our business logic with test runners, but how do we test platform specific functionality?

We can accomplish this by leveraging the Touch.Server on iOS to run our platform-specific tests on a real device or simulator. This is great for the platform-specific code of an application and ideal for testing libraries, such as plugins, that are purely application-specific code. In this post, we’ll show you how to set up continuous unit tests for SettingsPlugin projects in VSTS.

Getting started

Download the Touch.Server.exe to your project folder, a small tool originally built by Rolf Kvinge on the Xamarin.iOS team (this can be automated with a script later on). Touch.Server will make it easier to execute tests on a Simulator or a Device and pull tests results on the build machine for further processing.

Set the NUNIT_ENABLE_XML_OUTPUT and NUNIT_SKIP_LOG_HEADER environment variables to “TRUE” in Additional mtouch arguments in the Unit test project’s project options/iOS build.

iOS Project Properties

The iOS test project generates an excellent test result report by default; however, it is not compatible with the VSTS build system. Setting NUNIT_ENABLE_XML_OUTPUT to “TRUE” generates the test results compatible to the VSTS build system, and NUNIT_SKIP_LOG_HEADER removes redundant headers in the results file.

Setting up Build Configuration in VSTS

Add the following two additional steps to iOS build process defined on James Montemagno’s blog.

1) Shell Script

In this step, configure the shell script to configure test environment ie., set up the iOS simulator, auto execute tests, and provide a location to store test results.

Shell Script Config

Here is the simple script that does it all –

#!/bin/sh
echo 'Output path = ' $1
TEST_RESULT=$1/test_results.xml
echo 'Delete test result'
rm -rf $TEST_RESULT
mono --debug unit-test-tools/Touch.Server.exe \
--launchsim  \
-autoexit \
-skipheader \
-logfile=$TEST_RESULT \
--verbose \
--device=":v2:runtime=com.apple.CoreSimulator.SimRuntime.iOS-11-2,devicetype=com.apple.CoreSimulator.SimDeviceType.iPhone-SE"

 

2) Publish Test Results

This is a final step in the process. Once test execution completes, the build process will look for the test_results.xml and publish!

Publish Results

Note that VSTS will report the build successful even when there are failed tests in the published results. This issue is being discussed on GitHub.

Conclusion

VSTS will report the summary after every successful/failed build process with the test results:

Build Summary

Learn More

Be sure to read through Xamarin.iOS Unit Testing documentation to see how to setup your apps for testing. Then be sure to see how to set up continuous integration and deployment with Visual Studio Team Services with the Quick Start guide.

Discuss this post in the Xamarin Forums.

The post Running Xamarin.iOS Unit Tests in Visual Studio Team Services appeared first on Xamarin Blog.

January 18

The Xamarin Show: Getting Started with iOS Development in C#

220x165If you’re looking to get started with iOS development, there’s no better place to look than our amazing Xamarin.iOS documentation guides. They cover each and every topic that you can imagine when it comes to iOS development in C# with Xamarin. If you enjoy watching development videos on your favorite development topics, then look no further than The Xamarin Show, my weekly Xamarin developer video series on Channel 9. Each week I team up with other amazing guests to cover a topic in the world of Xamarin development. Since the launch of The Xamarin Show, we’ve covered a lot of great topics, from how to get started with iOS development to advanced topics such as publishing the app to the app store.

Below are just a few of our favorites to get you started with iOS development with C# and Xamarin.

Developing UI with the iOS Designer for Xamarin

Alex Corrado joins me to show off the latest and greatest updates to the Xamarin.iOS Designer in Visual Studio. This includes new support for Device adaptation, with brand new constraints and a frame editing mode. Alex walks through building a brand new screen from scratch that adapts to phones, tables, portrait, and landscape!

 


 

iOS Provisioning Made Easy with fastlane

Oleg Demchenko introduces us to the re-imaged and brand new simplified workflow for automatic iOS device provisioning with fastlane, which makes getting your application on your iOS device and into the app store a breeze.

 


 

Sharing Code with .NET Standard Libraries

On this episode, I’m joined by Immo Landwerth, who shows us how to start sharing code with .NET Standard 2.0 Libraries. He walks us through exactly what .NET Standard Libraries are, how they work, and how to get started with a lot of awesome tips and tricks along the way.

 


 

Getting Started with iOS Simulators

We take a look at the many ways of running iOS applications on simulators from Visual Studio and Visual Studio for Mac in this brief Snack Pack episode.

 


 

Accelerated iOS App Development with the Xamarin Live Player

This short Snack Pack episode takes a look at how to use the Xamarin Live Player with Coded UI Xamarin.iOS applications, enabling developers to rapidly iterate on their application and custom controls without ever having to stop and compile.

 


 

More Xamarin Show

Every week a brand new episode of the Xamarin Show on Channel 9 is available for your viewing pleasure. Head over to the show page, where you’ll find more episodes across a broad range of topics, and make sure to subscribe so you’ll receive notifications of future episodes, which will cover Custom Vision, Azure Cognitive Services, App Translations, App Center, and more!

The post The Xamarin Show: Getting Started with iOS Development in C# appeared first on Xamarin Blog.

January 16

The C# Developer’s Guide to Shipping Better Apps with Visual Studio App Center

At our annual Microsoft Connect event in November, we announced the General Availability of Visual Studio App Center, combining our best developer services, incuding Xamarin Test Cloud and HockeyApp, into one free, easy-to-use cloud service to help you ship better apps, faster. From building in the cloud to automatically testing on thousands of real devices, distributing to testers and app stores, and monitoring real-time crash and analytics data, Visual Studio App Center fully supports Xamarin apps.

Many of you have already starting using App Center, but we know some of you haven’t had a chance to try it out yet. To help you jumpstart a year of shipping amazing apps, we’ve rounded up our favorite resources that we think everyone will find useful, whether you’ve already started playing with App Center or are just starting out.

If you’re completely new to Visual Studio App Center, this introductory session from Microsoft Connect(); is a great place to start.

To get up and running with DevOps, you’ll want to check out this session on CI/CD DevOps Pipeline for Mobile Apps and Services.

Whether you’re new to mobile or are looking to improve your 15th, 50th, or 650th app, Visual Studio App Center makes it easier than ever to simplify and automate your iOS, Android, Windows, and macOS app lifecycle, all in one place.

Getting Started Videos

These short, technical videos will get you up and running with Visual Studio App Center quickly.

The Best of the Visual Studio App Center Blog

These informational “how-to” style posts have everything you need to start building better apps, faster.

 

Get Started for Free

The post The C# Developer’s Guide to Shipping Better Apps with Visual Studio App Center appeared first on Xamarin Blog.

January 12

Podcast: Android 8.1, Xamarin Device Manager, and Visual Studio versions 15.5 & 15.6

In this episode of the Xamarin Podcast, James Montemagno and I cover Android 8.1, the new Xamarin Device Manager Preview, what’s new for mobile developers in Visual Studio versions 15.5/15.6, and share our favorite Xamarin moments from 2017.

Be sure to download today’s episode from your favorite podcast app.



Subscribe or Download Today

Keeping up with the latest in .NET, C#, and Xamarin is easier than ever with the Xamarin Podcast! Cohosts Pierce Boggan and James Montemagno cover topics relevant to Xamarin developers, from designing mobile apps to identity management. Be sure to subscribe to the Xamarin Podcast on iTunes, Google Play Music, Stitcher, or your favorite podcast app you use to ensure you don’t miss an episode.

The post Podcast: Android 8.1, Xamarin Device Manager, and Visual Studio versions 15.5 & 15.6 appeared first on Xamarin Blog.

Interactive Line Editing in .NET

Even these days, I still spend too much time on the command line. My friends still make fun of my MacOS desktop when they see that I run a full screen terminal, and the main program that I am running there is the Midnight Commander:

Every once in a while I write an interactive application, and I want to have full bash-like command line editing, history and search. The Unix world used to have GNU readline as a C library, but I wanted something that worked on both Unix and Windows with minimal dependencies.

Almost 10 years ago I wrote myself a C# library to do this, it works on both Unix and Windows and it was the library that has been used by Mono's interactive C# shell for the last decade or so.

This library used to be called getline.cs, and it was part of a series of single source file libraries that we distributed with Mono.

The idea of distributing libraries that were made up of a single source file did not really catch on. So we have modernized our own ways and now we publish these single-file libraries as NuGet packages that you can use.

You can now add an interactive command line shell with NuGet by installing the Mono.Terminal NuGet package into your application.

We also moved the single library from being part of the gigantic Mono repository into its own repository.

The GitHub page has more information on the key bindings available, how to use the history and how to add code-completion (even including a cute popup).

The library is built entirely on top of System.Console, and is distributed as a .NET Standard library which can run on your choice of .NET runtime (.NET Core, .NET Desktop or Mono).

Check the GitHub project page for more information.

January 11

Xamarin.Android Now Double Stuffed with Oreo 8.1

Android Oreo 8.1 introduces new features, including Android Go, Neural Networks API, Autofill framework enhancements, SharedMemory API, and many more.

We’re excited to announce Xamarin.Android support for Android Oreo 8.1 in our latest release of Xamarin.Android for both Visual Studio and Visual Studio for Mac.

Installing Xamarin.Android for Android Oreo 8.1

You can get Android Oreo support in Xamarin.Android 8.2.0.1 and above, which is available today in the Visual Studio Preview channel and Visual Studio for Mac Beta channel.

Visual Studio

  • Open the Visual Studio Installer, and download the latest Preview (15.6 Preview 2).

Visual Studio for Mac

  • Switch the Visual Studio for Mac Update Channel to the Beta channel.
  • Ensure Xamarin.Android 8.2.0.1 is available for download and install the updates.

Both Visual Studio and Visual Studio for Mac

Android 8.1 development requires JDK 1.8 for compilation of applications; JDK 1.8 is available from Oracle. See the requirements documentation for more information.

Install the Android Oreo 8.1 SDK

Start the Android SDK Manager:

  • Visual Studio, use Tools > Android > Android SDK Manager
  • Visual Studio for Mac, use Tools > SDK Manager

Install Android 8.1(API 27) SDKs and Device Images:

Install the latest Android SDK tools, listed under the Tools tab, and include Android SDK Tools revision 26.1.1 or later, SDK platform-tools 27.0.1 or later, and SDK build-tools 27.0.0 or later:

For more information about using the Android SDK Manager to install the Android SDK, see Using the SDK Manager.

After restarting Visual Studio, you’ll be able to set your <TargetFrameworkVersion> to Android 8.1 (Oreo) in your project and take advantage of the new APIs:

Learn More

For more detailed information on how to get started with Android Oreo, please see our documentation.

We encourage your feedback on any issues to be reported via the Report a Problem option found in your favorite IDE via Help > Report a Problem. If you have any questions regarding Android Oreo APIs, please post them on the Xamarin Forums or Stack Overflow.

Discuss this post in the Xamarin Forums »

The post Xamarin.Android Now Double Stuffed with Oreo 8.1 appeared first on Xamarin Blog.

Upcoming Webinar | Xamarin University Presents: Ship Better Apps with Visual Studio App Center

Join Mark Smith, Director of Xamarin University, on Thursday, January 25 at 9 am PT / 12 pm ET / 5 pm GMT to learn how to automate your app development pipeline with Visual Studio App Center. You’ll walk through how to connect your app to App Center and start improving your development process—and your apps—immediately.

Jam-packed with step-by-step demos, this session has something for everyone, from app development beginners to seasoned pros who’ve built dozens of apps.

In this webinar, you will:

  • Connect your first app and add the Visual Studio App Center SDK in minutes.
  • Kick off continuous cloud builds, straight from your source control repo.
  • Run automated UI tests on thousands of real devices and hundreds of configurations.
  • Distribute to beta testers or app stores with every successful build, or on-demand.
  • Engage users with targeted push notifications in a few easy steps.
  • Get technical guidance and advice from our app experts.

 

Register

 
We encourage all registrants to attend the webinar live, as we will be answering questions throughout the event. However, all registrants will receive a link to the recording, so please feel free to sign up even if you cannot join us that day.

The post Upcoming Webinar | Xamarin University Presents: Ship Better Apps with Visual Studio App Center appeared first on Xamarin Blog.

January 10

Visual Studio 2017 Version 15.6 Preview Available Today!

Last month, we released Visual Studio 2017 version 15.5, which came with awesome new features, including the iOS Remoted Simulator becoming available to all developers, live XAML previewing in Android emulators with the Xamarin Live Player, new Xamarin.Forms project templates for .NET Standard, and improvements to the Mac pairing mechanism.

Today, we’re excited to build on that progress with the release of Visual Studio 2017 version 15.6 Preview 2. In this blog post, we’ll take a look at what was added this release, including macOS environment provisioning, iOS WiFi deployment, live XAML previewing in the Remoted iOS Simulator, and more!

Automatic macOS Provisioning

Building iOS apps with Visual Studio on Windows just got even easier with a brand new feature called automatic macOS provisioning. Rather than manually maintaining a Mac build machine, all you need to do is connect to the Mac, and we’ll handle the heavy lifting of installing and configuring your build machine with the correct Xamarin.iOS and Mono bits, all from Visual Studio.

Below, you can see the complete flow of connecting to a brand new Mac with only Xcode installed:



iOS WiFi Deployment

The Remoted iOS Simulator, which allows developers to test and debug iOS apps entirely in Visual Studio on Windows, is now available to all editions of Visual Studio (as of version 15.5), including the free Community Edition! The simulator supports functionality such as location simulation, rotation, gestures, and even includes functionality that the iOS simulator on Mac does not, like multi-touch. This provides a great simulator experience for developers building iOS apps on Windows, but what about devices?

With Visual Studio 2017 version 15.6, you can now deploy your iOS apps over the network with WiFi deployment, no cables required! After setting up a wireless device in Xcode, it shows up in Visual Studio just like a normal deploy target.

Live XAML Previewing with the iOS Simulator

The Xamarin Live Player enables developers to continuously deploy, test, and debug their apps using just Visual Studio and an iOS or Android device. Visual Studio 2017 version 15.5 added support to preview real-time XAML changes directly in the Android emulator without requiring a recompile or redeploy. This release brings that functionality to the Remoted iOS Simulator for Windows.

To use this feature, select an iOS simulator from the deployment targets dropdown and choose Live Run Current View using the context menu, keyboard shortcut, or the banner at the top of each XAML file.

Machine Learning with CoreML

Visual Studio 2017 version 15.6 also adds support for the CoreML framework that was introduced in iOS 11. With this framework, iOS apps can take advantage of trained machine learning models to perform tasks using the CoreML framework.



Check out our Introduction to CoreML tutorial and sample project to get started today.

So much more!

This release also includes Xamarin.iOS 11.8 and Xamarin.Android 8.1, improvements to design-time build performance for Android developers (which affects solution load and provides metadata for IntelliSense, among other things), and static analysis for Xamarin.iOS projects.

To get started with the previews today, download the Visual Studio Preview installer, and select the Mobile .NET (Xamarin) workload just as you did for your stable installation. Remember, Visual Studio previews are installed side-by-side your current installation and are sandboxed from your production development environment.

If you decide you no longer want to use the preview, simply use the Visual Studio Installer to uninstall any preview instance. While your stable installation should not be affected by doing this, we do recommend running a “Repair” on your other installation afterward as a precaution.

There’s so many reasons to try Visual Studio 2017 version 15.6 Preview 2, so give it a try and let us know what you think via Help -> Report a Problem in Visual Studio, on Developer Community, or reach out directly on Twitter.

Discuss this post on the forums

The post Visual Studio 2017 Version 15.6 Preview Available Today! appeared first on Xamarin Blog.

Monologue

Monologue is a window into the world, work, and lives of the community members and developers that make up the Mono Project, which is a free cross-platform development environment used primarily on Linux.

If you would rather follow Monologue using a newsreader, we provide the following feed:

RSS 2.0 Feed

Monologue is powered by Mono and the Monologue software.

Bloggers