Mobile First Cloud First

A blog by Geert van der Cruijsen on Software Development, Cloud, DevOps & Apps

Category: Xamarin (page 1 of 2)

Session videos to watch from Build 2017 for Mobile developers

It’s been 2 weeks since we had a great week at Build 2017 in Seattle. In the weeks after Build all recorded sessions came online on Channel 9. I’ve created a list of all things relevant for (Xamarin) mobile developers ranging from the new Xamarin announcements that made the headlines to some other sessions that you might have missed but can be relevant for mobile developers.

build

Lets start with the basics:

Keynotes of day 1 & 2

Although the first day didn’t have that much mobile stuff in it it did a good job on displaying where Microsoft is aiming for in the future. AI is a big part in this and AI can also be big on Mobile so it might still inspire you to build great new innovations. The Second day was the day of Windows and also contained all the mobile stuff.

https://channel9.msdn.com/Events/Build/2017/KEY01 & https://channel9.msdn.com/Events/Build/2017/KEY02

20170510_080708

“With great power comes great responsibility – Satya Nadella –  build 2017”

 

Xamarin

Xamarin had a bunch of sessions where they announced new things and showed their roadmap.

Xamarin: The future of mobile app development

When i first looked at the Build sessions i was about to skip this session. Sure James + Miguel are great presenters so that’s almost worth to watch but i expected this to be some Xamarin introduction. Luckily Miguel mentioned that this wasn’t the case so i was there. In this session Miguel explains what Microsoft is trying to achieve for mobile developers and they show all the new cool tools & bits for developers. a must watch! i especially like the bit where they demo the live player and the fastlane integration.

https://channel9.msdn.com/Events/Build/2017/B8103

 

Visual Studio for Mac

20170510_152836

During the keynote Visual Studio for Mac was already announced but in this session Miguel and Joseph go through more of the details of Visual studio for the Mac and what the future for this IDE will look like.  Joseph and Miguel were clearly having fun on stage. Bunch of Hackers!

https://channel9.msdn.com/Events/Build/2017/B8095

20170510_160818

 

What’s new in Xamarin.Forms

The third and last session held by Xamarin folks was about Xamarin Forms. Nobody less than Jason Smith explains about what is to come in Xamarin Forms 3.0 such as performance improvements,  and the FlexLayout which is an awesome feature for building apps across multiple device sizes. Some other things Jason mentioned were css like styling, one time binding and improvements in the listview

https://channel9.msdn.com/Events/Build/2017/B8099

 

Mobile Center & Visual Studio

Mobile center is a new product that together with VSTS should cover most devops teams in a full devops solution for mobile developers. Here are the key sessions to watch regarding mobile center:

Visual Studio Mobile Center: Ship mobile apps faster

The major session by the Mobile Center team is a must watch if you are thinking about using mobile center.  Thomas Dohmke and Keith Ballinger explain all the new features of mobile center like UWP support, Push notifications and store deployments

https://channel9.msdn.com/Events/Build/2017/B8072

 

Visual Studio Mobile Center and Visual Studio Team Services: Better together for your Mobile DevOps

This session by Simana Pasat explains what mobile center does and how this fits together with VSTS.

https://channel9.msdn.com/Events/Build/2017/T6079

 

General C# & .Net

Build is not only about mobile development. There are several other sessions that are not specific for mobile developers but can be really useful for mobile developers since we still code in C# and .Net right?

20170510_114637

Three Runtimes, one standard… .NET Standard: All in Visual Studio 2017

Scott Hanselman and Scott Hunter gave a great presentation on .Net Standard and .Net core. important changes coming to .Net in the coming year. If you’re not up to date with what .Net standard is all about this session has your covered. Next to that the 2 Scotts are just generally funny so worth a watch even if you’re already an expert on .Net Core and .Net Standard 2.0

https://channel9.msdn.com/Events/Build/2017/B8001

 

The future of C#

This session is a classic Build session that Mads and Dustin do every year. When i read the session abstract it made me laugh: “We’re Back!” it stated as this is a Build classic i remembered back from when i was at Build in 2012. This year they showed all the new features of C# 7 but also the road ahead of C# 7.1, 7.2 and C# 8!!

https://channel9.msdn.com/Events/Build/2017/B8104

 

SignalR .NET Core: Realtime cross-platform open web communication

Damian Edwards and David Fowler explain the future of SignalR. SignalR was already a way of building real time communication between several devices but this was always a bit unreliable and wonky, especially on Mobile devices. With SignalR Core they are focussing on a complete rebuild from the ground up and looks really promising. I think this will be used a lot after it’s GA somewhere later this year

https://channel9.msdn.com/Events/Build/2017/B8078

 

Cognitive Services

Cognitive services and AI were a major topic at build.  Here are some videos (next to the keynote) that might inspire you to use cognitive services in your apps

Computer vision made easy: From pre-trained models to Custom Vision, Microsoft Cognitive Services has you covered

Computer vision is a super cool topic and it’s so easy to implement. In this session Anna Roth shows you the possibilities of cognitive services related to computer vision

https://channel9.msdn.com/Events/Build/2017/B8020

 

Using Microsoft Cognitive Services to bring the power of speech recognition to your apps

Next to computer vision speech recognition is another cognitive service that really blows my mind how far we’ve come with technology in the past few years. Watch this session for everything about speech recognition in your apps

https://channel9.msdn.com/Events/Build/2017/B8092

Project Rome

Project Rome is a really interesting project for mobile developers and most mobile dev’s i’ve spoken at Build or after Build still didn’t have any knowledge about it. Project Rome focusses on inter device experiences for apps which is something that is going to be huge in the future is my prediction.

bill buxton

Cross-device and cross-platform experiences with Project Rome and Microsoft Graph

This session gives a good overview of what is possible by using Project Rome. Vikas and Carmen gave lots of demo’s and explained the why, the what and how of project rome

https://channel9.msdn.com/Events/Build/2017/B8025

 

App engagement in Windows Timeline and Cortana with User Activities and Project Rome

Project Rome goes hand in hand with the Microsoft Graph and the addition of User Activities and Devices to the Microsoft Graph. In this session Shawn and Juan describe how you can engage users cross device by using the features of Cortana and the new Windows Timeline.

https://channel9.msdn.com/Events/Build/2017/B8108

 

Bots

“Bots are the new apps”. it’s a sentence i’ve heard quite often in the past year which was unofficially called “the year of the bots”. Is this mobile tech?  I’m still not convinced this will replace native mobile apps but it’s a great addition to cover certain mobile moments.

bot framework

Bot capabilities, patterns and principles

I visited this session and i have to say i really liked it.  Mat Velloso and Ryan Volum give some real life examples of how you could set up a bot and what design patterns you can use to set up a good bot. Even if you’re not a bot developer this might inspire you to build some small bots or integrate them in your apps.

https://channel9.msdn.com/Events/Build/2017/B8010

 

Windows

UWP was a big topic at Build as it is every year. although i haven’t focussed on this much during this year of Build since i was at all sessions above here focussing Xamarin and other Mobile or Azure related topics there is still quite a big list of videos worth watching is you’re building UWP apps.

The first major announcement that i really liked was the Fluent design system. Although i’m a dev i really love good design and these kind of systems really help me to build great stuff. I absolutely loved Metro (back when it was announced) but Microsoft didn’t upgrade this design language that much up until now.

 

fluent design system

Introducing Fluent Design

https://channel9.msdn.com/Events/Build/2017/B8066

Build Amazing Apps with Fluent Design

https://channel9.msdn.com/Events/Build/2017/B8034

 

Other sessions on UWP development:

What’s new and coming for Windows UI: XAML and composition

https://channel9.msdn.com/Events/Build/2017/B8100

Windows Store: Manage and promote apps your way

https://channel9.msdn.com/Events/Build/2017/B8098

App Model evolution

https://channel9.msdn.com/Events/Build/2017/B8004

Nextgen UWP app distribution: Building extensible, stream-able, componentized apps

https://channel9.msdn.com/Events/Build/2017/B8093

Ten things you didn’t know about Visual Studio 2017 for building .NET UWP apps

https://channel9.msdn.com/Events/Build/2017/B8096

XAML custom controls for UWP: Start to finish

https://channel9.msdn.com/Events/Build/2017/B8035

 

 

These sessions should cover quite some of your spare time to get you fully up to date of current mobile development in the Microsoft space. I really like listening to some of them during my commute. Did i miss any important sessions? please let me know in the comments.

20170512_151116

I had a great time at Build in Seattle so hopefully to see you next time.

Happy Coding!

Geert van der Cruijsen

It’s 2017: Test automation is not optional when building mobile apps!

Note: although this post focusses on mobile app development using Xamarin it also applies to other native mobile apps built in Swift, Java or even web apps. it’s 2017! whatever you are building get started with Test Automation!

As a consultant working for Xpirit i get to see a lot of different customers which I help with my expertise in building mobile applications to improve their mobile apps. Something I noticed in the previous year is that continuous delivery is a hot topic and companies and teams focus on deploying apps automatically to their testers through hockeyapp or even to the stores in beta and / or production.

In agile scenario’s (and come on who isn’t doing that currently? Every company or project I visit is saying they are agile or doing Scrum although some only do dailies and call that scrum 😉 ) In the current world it is really important to be able to release often because you want to be able to adapt to customer needs which are almost always changing and evolving.

Implementing a Shift left Quality Model

Test Automation is a process that does not belong to the developers or testers alone. It’s something that has to be in everyone’s mind from Product Owner to Developer and Tester. Automated tests can help you lower regression test effort but investing in Test Automation can really help you make a shift left focussing on quality earlier in your application development process.

Continue reading

Fix “App may slow down your iPhone” popup for Xamarin apps

For a while now (september 2015)  Apple requires apps that are submitted to iTunes to be 64 bit. When building your app for the simulator this isn’t required because app doesn’t go through the Apple screening. Since iOS 10.1 update however Apple added a little popup that checks if an app supports X64 and otherwise will show you a popup telling: “[App name] may slow down your iPhone”. It will only show the error message once and is meant for old apps which are added to the store before september 2015 and are still on peoples phones/tablets who need to update to X64.

Popup message: [App name] may slow down your iPhone

Screen Shot 2016-11-08 at 22.09.46

The fix is quite easy. just set the iOS build to support X64 also when building for the simulator.

Xamarin Studio

in Xamarin Studio go to properties of your iOS project. by rightclicking your iOS project. -> iOS Build tab  -> make sure that Supported Architecture for each configuration contains X86_64 or i386 + x86_64

Screen Shot 2016-11-08 at 22.08.58

Visual Studio

in Visual Studio right click your iOS project and select properties. -> go to iOS Build -> Advance tab ->make sure that Supported Architecture for each configuration contains X86_64 or i386 + x86_64

Screen Shot 2016-11-08 at 21.45.38

 

Although this is a small issue i got some questions by new developers what this message meant. so hopefully this blogposts helps those who were questioning why this message is showing up all of a sudden.

Happy coding!

Geert van der Cruijsen

Techdays 2016 slides & Recap

Last week 4 and 5th of October Microsoft organized Techdays in the Netherlands and the full Xpirit team was there as platinum sponsor. We organized lots of cool things such as the Techdays Minihack zone where people could get hands on expierence and compete for cool prizes.  Xpirit was also the supplier of the official Techdays app which we open sourced during Techdays. The source can be found here on github: https://github.com/XpiritBV/app-evolve

 

As Xpirit we delivered 17 sessions and had 7 speakers on the event.  I delivered 2 sessions on Xamarin topics. Here are the slides for the sessions. The Videos are coming later (and will be in Dutch).

Xamarin Test cloud – From zero to hero in automated UI testing

Session abstract:

Looking at the mobile device landscape it became almost impossible to do manual testing on all types of devices that your customers use. Not even thinking about what your app looks like on some very rare Android devices. To ensure great quality of your apps you’ll have to introduce automated UI testing and Xamarin Test cloud can  be the tool for the job. During this session Geert will show how to  start building automated tests for mobile apps to demonstrate the features of Xamarin test cloud and how it could help you in your app development cycle. ‘Geert will give best practices and tips on what to test and what not to test and how to structure your tests. Join this session if you want to ensure your apps look great on all devices.

Slides:

Video: (in Dutch)

 

Techdays 2016 app: Behind the Scenes

Co-presenter: Roy Cornelissen

Session Abstract:

Every conference needs a good mobile app. During this session Roy and Geert will take you through the story of how they’ve built the Techdays 2016 app for iOS, Android and the Windows platform using Xamarin.Forms. They will show you cool stats of the app, it’s architecture, cool features we added and how we added them and lessons learned while building this app.

Slides:

Video: (in Dutch)

 

Next to all the cool sessions and minihacks we’ve delivered at Techdays we also launched a new issue of our magazine “Xpirit Magazine”. this magazine contains a lot of cool technical articles written by my colleagues and me. We handed out the magazine to everyone at Techdays but if you missed it you can still get a free copy (either pdf or FREE hardcopy)  here: xpir.it/magazine-3

XpiritMagazine_cover_large-1 (1)

articles covered:

CONTINUOUS DELIVERY 3.0
■ Continuous Delivery 3.0 – The next ‘next step’
■ Release management, from technical to functional practice
■ Infrastructure as Code
MOBILE
■ Mobile Innovation – Don’t wait for the ‘perfect’ app
■ Exploring the Microsoft Bot Framework
■ Continuous Delivery 3.0 for Mobile apps
ALM
■ Extending your Build and Release pipeline
■ Technical Debt you application Lifecycle
■ Doing testing right
CLOUD
■ Containers on the Microsoft platform: the full picture
■ Conquer the world with Azure Machine Learning
■ How to accelerate your choices using data

 

Hope to see you next year on Techdays. Xpirit will definitely be there!

Geert van der Cruijsen

Xamarin DevDays Amsterdam Recap

Yesterday  we organised one of the many Xamarin DevDays events in our Xpirit office in Amsterdam. It was great to see many people show up on such a sunny day in the weekend (Some of them coming all the way from London to attend this event here).

The day was split into 4 parts.

 

14051741_1239068676138188_4762360838751043582_n

All slides, samples and labs  can be found on github here: https://github.com/XpiritBV/dev-days-labs

Even if you weren’t at the event  the labs might be to interest of you because they contain some really nice detailed steps on how to create a Xamarin.Forms app including a Azure backend.

 

Xamarin Apps

14095850_1239068642804858_599288069959767511_n

Marcel kicked of the day by explaining how to build true native apps using the traditional Xamarin approach.  How we can share up to 70 to 80% of our code while still having all features we would have when building native apps in Objective-C, Swift or Java. By building apps using Xamarin you have the possibility to use all the native tools to build your UI, you can create storyboards for iOS, define your Android UI in AXML and on Windows you can create your UI in XAML. These native UI’s connect to your business logic which you can write in C# and can be the same for all platforms.

Screen Shot 2016-08-28 at 13.01.45

Marcel also talked about the performance and how Xamarin apps can often even beat Java or Objective-C apps in performance. This is possible because on android the Mono runtime is sometimes just faster as the Java runtime on Android devices.

There are also some differences on how  your code will be compiled and published to the different devices. Android makes use of  Just in Time compilation in combination with IL code while on iOS a ARM-Binary is created using Ahead of Time compilation to build true native apps.

Screen-Shot-2016-08-28-at-13.02.02 (1)

14054243_1239172942794428_4862573752858820030_n

Xamarin.Forms

Then it was my turn to take the stage to do an introduction on Xamarin.Forms. Xamarin forms is library built my Xamarin to increase code sharing even further. you could go up to 99% code sharing with Xamarin while your apps still look and perform natively.

Xamarin forms is a UI framework that creates an abstraction on top of the UIs for Android, iOS and Windows and will let you design and create these UIs in your shared code which will then be turned into real native UI components when you compile for iOS, Android or Windows. if you use things like Tabbed pages the tabs will be placed at the bottom for iOS because that is what iOS users expect, and for Android it will create beautiful material design tabs at the top of your screen.

Screen-Shot-2016-08-28-at-13.02.36 (1)

You can define your Xamarin.Forms UI using XAML or C# and there are over 40+ pages, layouts and controls available.

Screen-Shot-2016-08-28-at-13.02.55 (1) Screen-Shot-2016-08-28-at-13.03.05 (1)

14063932_1239172959461093_6424750382214445463_n

Xamarin + Azure

After lunch Roy told a great story on how azure can help you speed up the development process of building your mobile backend with all the features that come with Azure.  We zoomed in on Azure Mobile apps and al the components that help you create mobile back ends and adding offline data synchronising between your mobile and the mobile backend with just 4 lines of code!

Screen-Shot-2016-08-28-at-13.03.59 (1)

14064284_1239173046127751_4605706219513382693_n

In the afternoon we spend some time with all the people who attended on building the labs or discussing different Xamarin questions. It was great to see all the people who were new to Xamarin being able to pick this up so fast and were able to write a simple app in a couple of hours.

If you missed this Xamarin DevDay in Amsterdam make sure you check the posts by Xamarin where they announce more of then during the coming months. Xlevelupmobile_logorgbpirit is also organising another Mobile development related event on 22nd of September together with AFAS. This FREE event is called LevelUp Mobile and we have great speakers like  Brechtje de Leij (mobile strategist and expert),  Laurent Bugnion, Jorn de Vries of Flitsmeister, Johan Gorter & Rick Hoving from AFAS Software & Roy Cornelissen and me From Xpirit . Sign up here: http://www.levelupmobile.nl

Happy coding! Geert van der Cruijsen  

Xamarin apps: Sqlite vs Realm. What’s the best mobile DB solution?

Last week Realm.io introduced Realm for Xamarin. Realm promises an easy object database with full query options and better performance than existing solutions (so also sqlite which is probably the most used database solution). Time to put both sqlite and Realm to the test. which is better?

SqlitevsRealm (2)

When comparing these solutions i wanted to test out the full relational options of the database because that is what Realm advertises with. if we are looking at just plain key value storing we could use something like akavache (based on sqlite back end) which is probably faster because of lots of optimisations in queries. I do recommend using akavache for caching scenarios or when you are just storing simple types of data that do not require complex querying.

To test sqlite and Realm i’ve created a simple datamodel with orders and order lines. each order has a list of order lines and i would like to be able to query orders and get the underlying orders back immediately. but also the other way around. i would like to query certain orders which have order lines that contain a certain product. those kind of queries happen often when you are working in a real world business app.

So now we have this datamodel + some queries we want to execute. lets define some criteria on how to score both solutions. I came up with the following critters: Ease of use, speed, & maintainability.

let’s talk about these criteria in a bit more depth. I’ve created a sample project on github that has the samples and source code for you to experiment.

You can download the source here: https://github.com/Geertvdc/Xamarin-RealmVsSqliteCompare

Ease of use

Sqlite and Realm are both pretty easy to set up. I’ve used Sqlite in the past before and had never used Realm so i had to do some reading up on Realm. I didn’t have to read that much though because the basic explanation of Xamarin.Realm on the Realm.io site explains the most used features and all the features i need for this first test.

Realm is actually really simple to set up. Where Sqlite does require some plumbing (getting a location for a file to store your DB in and creating a SqlAsyncConnection) this is not needed for Realm. In Realm you can just call the GetInstance(); method and you are ready to go. For both we need to install nuget packages of course which can be though for sqlite as well since there are so many different packages it’s sometimes hard to know which ones to use.

Sqlite needs 3 nuget packages for the basic functionality:  SQLite.Net-PCL, SQLite.Net.Core-PCL and SQLite.Net.Async-PCL. next to that i use 2 extra packages to give me some extra extension methods: SQLiteNetExtensions & SQLiteNetExtensions.Async.

For Realm we just need to add Realm nuget package to all our projects.

After we have an instance of both Sqlite and Realm we can start inserting some data into our database. Below is some sample code to insert 1000 orders which each have 5 order lines. I want to be able to insert all of them and make sure that there is a relation stored between the orders and the order lines so i can retrieve both in 1 query.

Looking at the code Realm just works a bit easier. we don’t have to think about doing sql transactions (if you forget/remove the transaction it is about 3x slower.) We just need to create the objects in a Realm.Write block and Realm will handle all the things for us. I do have to say i’m no fan of having my database objects have to inherit from RealmObject and that the constructor has to be Realm.CreateObject() but more on that in the Maintainability criteria. When looking at ease of use only i have to say Realm is easier because it does all the plumbing and yak shaving for you. Winner: Realm

Speed

Realm promised us a faster database than the competition so this was the reason i started this investigation. Sqlite can be slow some times but most often this is because of bad use. Paul Betts (creator of Akavache) did a great session at Xamarin Evolve this year on why sqlite is often slow and how to use it properly. To test the speed I’ve created a xamarin forms app and ran some tests on both Android and iOS. speeds do change a bit from platform to platform and also there is a some difference in using a device or emulator/simulator. Overall Realm seemed a bit faster in querying complex queries and it seems to use some caching looking at the query that took 0 ms on iOS. A note here is that Sqlite can probably be even a bit faster when you optimize the queries. What i used now for Sqlite is just a generic query to retrieves all objects with it’s children.

Screen Shot 2016-05-17 at 13.52.12 Screenshot_20160517-135540

After looking at the test data there are some differences and sometimes Sqlite is faster then Realm and the other way around. Sqlite can be fast if you know what you are doing and Realm seems to do the job quite well without any special thought on how to do things like transactions. scoring points for ease of use again.

Winner: No clear winner between Sqlite & Realm purely regarding speed

Maintainability

The last criteria on which i wanted to test these 3 solutions is maintainability. Sure the ease of use of Realm seems nice but how would this work in actual apps that need to be maintained and tested for long periods of time.

The first think i noticed when looking at Realm is that all your database object need to inherit from RealmObject. Because of this inheritance Realm knows how to do all it’s magic but i really don’t like this approach. creating objects cannot be done by using a simple constructor you always need to use Realm.CreateObject, creating a tight reference to Realm. Same goes for the lists of objects within a RealmObject which have to be of the type RealmList<T>. I like Sqlites approach much better where you just use simple POCOs (Plain Old CLR Objects) with some attributes attached so Sqlite knows how to store certain things.

In a proper testable software architecture you want to keep the dependency on either Realm or Sqlite to a minimum of places and preferably only in the classes that handle the database communication. for Sqlite this is possible however for Realm this will be quite hard since creating new objects can only be done by Realm.CreatObject. You could do a mapping from Realm to POCOs in your repository but that defeats the purpose of the ease of use of Realm which offers functionality for listeners on object changes to easily update your UI.

another thing that is really missing from Realm is support for Async. In my opinion every mobile library should have async features as default (or as only option). It is on the “missing features” list of Realm so they are aware that this is an important feature. But at it’s current state in the beta it’s not in.

The last thing i noticed was the Fody Weaver that is being used by Realm. At first it’s not that important for you as a developer because it just works. the weaver will do some changes to your IL to add stuff Realm needs. As long as everything works it’s no problem, however when you run into problems you might have issues finding the issue because the code that is being executed is actually a bit different from what you wrote.

Combining these things related to maintainability i think Sqlite is a clear winner here.

Winner: Sqlite

Conclusion

Looking at these 3 criteria i think Sqlite is still the best solution. Sure Realm is pretty fast and needs almost no plumbing i think the maintainability of Sqlite will win it in the end. I do see some use for Realm, especially for POC’s or small projects. (although for POCs i have to much experience of POCs running in production in the end or growing to larger apps, if that is the case i would pick Sqlite).

We have to take into account that Realm is still in beta and Sqlite has been there for ages but the things i don’t like about Realm are basically in it’s base so i don’t see them changing that quite soon. I’ll be watching Realm to see what they are up to in the future but for now i’ll keep using Sqlite.

Let me know your experiences with Realm in the comments below. i’m curious if people have different opinions than me after playing with it for a few days.

Happy Coding

Geert van der Cruijsen

Xamarin Evolve Day 1 Recap

At the moment of writing i’m still at Xamarin Evolve. Yesterday was the first day of the conference where all the new goodies were announced. Time for a quick recap of what was announced and the sessions i followed.

The day started with a so called “mini-hack” at 6.15 in the morning. There are several mini-hacks at evolve most of them require you to do some basic exercise with a specific technology or tool such as Hockeyapp, MS Cognitive services, Bitwise etc. This one was a bit different. Craig Dunn organised a 5k run at 6.15 in the morning with a bunch of Xamarinians. I joined together with my Colleague Roy and other Dutchguy Marco Kuiper. It was a great run and really gave a boost of energy to start the day. After that it was time to get breakfast and head to the keynote.

Keynote: Nat took the stage and told everyone about some things that happened since the Microsoft takeover. Interest in Xamarin increased by 3x since the announcement of the Microsoft merge. Great times to be a Xamarin developer! After Nat, Miguel took the stage to show us the new stuff.

Miguel showed us the dark theme for Xamarin studio for us young hackers. (felt me feel young again) I  really like using the dark theme in Visual studio and now we also can in Xamarin Studio. Xamarin also included a lot of Roslyn features to improve code quality and to help you build beautiful code.

Xamarin also announced that they are open sourcing all the SDK’s and they will be located at open.xamarin.com. In the first few hours there were already pull requests which i think is pretty cool.

Miguel invited Nina Vyedin on stage to talk about the Xamarin forms previewer. Nina explained that XAML officially stands for Xamarin And Microsoft Love and after that she showed us how the Xamarin forms previewer works. I think this was THE feature where a lot of people were waiting for.

Miguel took over again after Nina and showed us his new baby the Xamarin Workbooks. i have to say i really love the workbooks and have played with it after they were released at BUILD. Workbooks are a great tool to teach people new features in Xamarin or C# in general. Workbooks are basically MarkDown files that contain text and also pieces of code. these pieces of code can be ran onto a simulator in real time. There are several sample workbooks which can be found here: https://github.com/xamarin/Workbooks

Xamarin Evolve 2016 pre-conference write up

Xamarin Evolve 2016 is about halfway now for the 600 people who attended the 2 days of training so time for me to do a quick write up on the last 2 days.

When Nat Friedman did the opening keynote he said: “This will be the best conference we ever did.. and with we i mean Microsoft” until now Xamarin/Microsoft is delivering.

 

 

Before Xamarin Evolve started we arrived in Orlando FL on Saturday. After having a great steak at Mortens on Saturday night we went to visit Kennedy Space Center on sunday before the training and conference kicked off. It was a great day with nice weather and really awesome things to see.

13103266_1152228171488906_8531731149448128603_n13082499_1152228194822237_9223364263606609861_n

13096075_1152228331488890_8129698238633410606_n

on the way back we had an Uber driver who was retired but was actually an engineer on the space shuttles for 30 years. He had some great stories from all the launches he had witnessed and cool stuff he worked on.

So back to Xamarin Evolve:

I joined the 2 day intermediate training and thought it was pretty good. I knew most of the stuff already since i’ve been working with Xamarin for several years now but it was good to do the training since my colleague Roy Cornelissen and i are in the process of becoming certified Xamarin trainers so we can deliver in person Xamarin training in the Netherlands or Europe. It was a good learning experience on how training like this works and we had really good trainers with Andrew Ditmer and Rob Ringham

Here are some of the topics we followed during the intermediate track:

Async / Await

We started off with some deep dive on async and await. I believe this is a crucial part of knowledge to “build better apps” which was the Andrew and Rob’s slogan for the training. In my role as technical architect and consultant i’ve lead several teams of junior developers and using async and await is something a lot of people are doing wrong. The main reason why people use it incorrectly is because it seems so easy while before async/await was announced doing multi threading was quite a burden.  It’s really important for a developer to know what happens behind this syntactic sugar of async await and during this training Andrew and Rob told the class all about it.

Cross Platform Design

One of my favorite parts of doing software development is design patterns. During the second part of the training we looked at patterns on how to share code between several platforms and we mainly looked at 3 patterns: The Factory pattern, the service locator pattern and my favourite Dependency injection. although this seems basic for me it wasn’t that much for most people in the class. Setting up your software architecture to use dependency injection is really important to make testable maintainable code. Lot’s of people don’t like this kind of work but shaving yaks as it is called is one of my favourite things

shavethatyak

Testing

After we had set up a good testable software architecture it was time to talk testing. we started of with basic unit testing (which in my opinion should be part of any basic programming track) but i was baffled by the amount of people not doing any unit tests in our class.  We talked about AAA (Arrange, Act, Assert) and quickly moved to Xamarin UI tests and test cloud.

The testing subject concluded the first day and we continued the 2nd day of training on tuesday:

Securing local data

Security, a topic not that many people had to many knowledge about. We talked about the Xamarin.Auth library which can really help you with securing and encrypting local data. Of course this library is open source and located on github: https://github.com/xamarin/Xamarin.Auth

my Xpirit colleague Roy actually found a bug in Xamarin.Auth about a year ago and the cool thing of Evolve is that all the Xamarin guys are actually here on Evolve as well. so our trainers send a message to the guy who maintained Xamarin.Auth and he came to our classroom to talk about the bug and the pull request Roy made to get it fixed.

Oauth

After securing local data we continued the training with using Oauth which is a topic that a lot of apps will use. not that many people had to much knowledge about it because this is set up once most of the time and people don’t really understand what is going on. The Xamarin.Auth library can help you with OAuth as well and although we didn’t cover it you could also use the Microsoft ADAL library for doing Oauth.

Garbage collection and Memory management

The last topic was all about garbage collection (Rob’s favourite topic). When you are building apps and are not focussing on memory management or have no clue on how to do it  this will eventually bite you in the back so it was essential for the training. We talked about all the pitfalls and tips and tricks for doing memory management in both iOS and Android.

This rounded up the training. most of these topics can be found as tracks in Xamarin University so if you have an account there you can do these courses as well.

After the training the Darwin lounge was opened and Xamarin showed again how to throw a great party. On monday evening we already had a great party at La layettes and this time there was great food and drinks  throughout the darwin lounge and sponsor stands.

There was some local craft beer tasting, Artisan chocolate tasting. build your own tacos, paella and other great food. I had the chance to talk to a lot of Xamarin people, some Dutch people i met and my former Avanade Colleagues who i’ve bumped into.

ChBP_l1W4AE2wk-.jpg-large

After having some great talks and beers it was time to go to bed because this morning at 6.15 we had to go for the Xamarin Evolve 5k minihack organised by Craig Dunn.

there was quite a lot of people there at 6.15 and it was a great run. Thanks Craig!

 

In about 45 minutes the keynote is starting so now it’s time for me to grab some breakfast and head to the keynote. For news about the keynote watch the live stream of follow my twitter updates.

Improved Hockeyapp publishing from VSTS for Windows 10 UWP apps

In my last blogposts that  showed a tutorial on how to do automated builds in VSTS and continuous deployments to Hockeyapp. For UWP the support wasn’t that good and we couldn’t use the Hockeyapp Build steps from VSTS because Hockeyapp could not handle zip files containing the files from your app package such as the appx or appxbundle file, the powershell install script etc. I made a workaround using powershell but that is not needed anymore because the Hockeyapp team made some changes to the Hockeyapp build step.

This has changed last week although it wasn’t announced anywhere. I asked the question on the Hockeyapp slack group when the Hockeyapp team would implement this feature and they told me they just did it before the Microsoft Build conference started.

So if you’ve used my Powershell script before to publish your app to Hockeyapp you can now change it back to the  Hockeyapp build step and leave the rest of the steps the same. the zip file should contain all your files from the AppPackages folder. I’ve also updated the tutorial post for anyone who’s using it in the future to use the correct way right away.

image_thumb62.png

Hockey app UWP deployment

If there is an .appxsym file in the zip file as well the symbols will also be used within Hockeyapp.

I’m really glad that UWP apps are on the same level of maturity again as Android and iOS apps are regarding Continuous deployments in Hockeyapp.

The Hockeyapp team also announced in the public Hockeyapp Slack group that they are working with the Windows product team to improve installation of apps so more to come in the future. I can’t wait!

Happy Coding!

Geert van der Cruijsen

Continuous deployment of Xamarin.iOS apps to Hockeyapp using VSTS

Last week I’ve created 2 posts on setting up VSTS and Hockeyapp in a continuous deployment scenario for both Xamarin.Android and Windows 10 UWP apps. Today we’ll discuss the 3rd platform: Apps built using Xamarin.iOS

The basics of all 3 platforms are the same but there are still quite some differences so lets look at the steps for Xamarin.iOS apps:

image

Context: the app we are going to deploy

We’re going to deploy the same app as yesterday in the Xamarin Android post. I’ve created a simple solution in Visual Studio containing an average Xamarin project. 1 PCL, 1 Android app, 1 iOS app and 1 Windows 10 UWP app.

image_thumb1_thumb

To make things easier during automated build I’ve also created a new solution that only contains the projects relevant for the iOS app.

image-1

This solution only contains the PCL project and the Xamarin.iOS app project.

Setting up the build in VSTS: Prerequisites

 

There are some difficulties comparing the build of iOS apps to Android or Windows apps. first difficulty is that you are going to need a Mac to do the actual build steps. to do this you have 2 options. The first is to just use a Mac within your network and use that as a build agent, the other option is to use a service called MacInCloud.com which has a special plan for VSTS build agents.

Mac Build agent

Mac in cloud has a special VSTS build agent plan which only costs 30$ a month. in my experience this works really well. If you have a spare Mac somewhere to use as build agent this would also work fine but most clients I come don’t have that Winking smile

Setting up a VSTS build agent on a mac isn’t that hard. There is a good guide on this on github here: https://github.com/Microsoft/vso-agent/blob/master/docs/vsts.md

make sure Xamarin Studio is installed on the mac because it’s needed for doing the actual builds. (not in the VSTS build agent guide)

App Certificates

To be able to build the iOS app and to do ad-hoc distribution we’re going to need to set up certificates from the apple developer portal on our mac build agent. Xamarin has a great guide on how to do this so I won’t copy all the steps in this blogpost: https://developer.xamarin.com/guides/ios/deployment,_testing,_and_metrics/app_distribution/ad-hoc-distribution/

After we’ve arranged a mac build agent and set up the app certificates we can actually start building our app.

Setting up the build in VSTS

in VSTS open your team project and go to the BUILD tab. in here we’re going to create a new build definition by clicking the green + sign.

image_thumb3_thumb

Choose the Xamarin.iOS build template to set up the build.

image

In the next step select the correct repository you want to use for your app and make sure you select the Mac build agent in the drop down box.

image
Click Create and now our build definition is created with 2 out of the box steps. The first step is doing the actual Xamarin.iOS build. select the iOS specific solution so only the iOS related projects are build.

We’ll be removing the Xamarin test cloud step for now. if you want to know more about this let me know in a comment so I can create a new blogpost about this if people would like that.

image

so we only have the Xamarion.iOS step left but this will only build our app. we’re also going to need 2 extra steps which are not part of the Xamarin.iOS step:

  • Nuget package restore
  • Copy and Publish Artifacts.

Nuget Package restore:

I’ve you’ve read my previous posts on Android and Windows UWP you would expect we’re going to use the out of the box “restore nuget package” build step. But that is not possible for iOS. Why not? these steps are implemented using Powershell which doesn’t run on your mac agent. so we’ll have to do it manually by executing a shell script. So we’re going to create a shell script task. First we need to create the actual script. The script is quite simple. download the nuget.exe file and execute the nuget restore command

 

 

Save the .sh file in your repository so we can add it to our build step. Click the green + and select “Shell Script”

image

Drag the .sh script to the top of the build so the nuget restore will be executed before the actual build step. Select your .sh file in the script path and as argumenets pass in the path to your iOS solution file so the script knows what packages to restore.

image

Copy and Publish Artifacts

So we’ve set up the nuget restore and the build. the last step of our build is to copy and publish the build artificats  so we can send these to Hockeyapp later.

Add a “Copy and Publish Build Artifacts” step to your build definition.

image

In the copy and publish step set the root to the correct folder and for contents we’re going to select the .ipa file. The Artifact name we’re naming “drop” of type server.

image

These 3 steps should together be able to do a successful build. Go to triggers to schedule your build nightly or set it to build every time someone checks in code.

Queue a build to see if everything works.

image

Setting up Hockeyapp

I assume you’ve already created an account at Hockeyapp otherwise just sign up at www.hockeyapp.net (It’s free for 2 apps or less) once you’ve logged in go and create your first app by pressing the New App Button

image_thumb38_thumb

Hockeyapp will ask you to upload a build. we’re not going to do that since we’re setting up automatic deployments. choose to add the app manually

image_thumb40_thumb

Choose  iOS as the platform and fill in your release type and title of the app.

image

Click Save and in the overview of the app copy and save the App ID

image_thumb-19

To be able to deploy from VSTS we need to set up an API token we can use in VSTS. If you already followed the Android or Windows UWP guide you might have already taken these steps so you can skip these steps and move to the chapter of deploying the app.

Click on your user icon in the top right and select API Tokens from the menu on the left.

Create a new API token and call it VSTS. Copy this API token. we’ll need it in VSTS

image_thumb46_thumb

Move back to VSTS and  open up the marketplace (top right next to your name) and click manage extensions. browse the marketplace and install the Hockeyapp extension

image_thumb49_thumb

After installing the extension go back to your VSTS team project and navigate to the settings window. in the settings menu go to Services and add a new service Endpoint of type “Hockeyapp”

Give the endpoint a proper name and copy in the API token you’ve generated earlier. now save the service endpoint.

image_thumb51_thumb

Now all the plumbing with Hockeyapp is done we can actually start deploying our app to hockeyapp

Deploying your automated build to Hockeyapp

Go back to your team project in VSTS and navigate to the Release tab

image_thumb53_thumb

Choose an Empty deployment template and press OK.

image_thumb56_thumb

First go to the Artifact tab and select the build we’ve created earlier as supplier of the artifacts we’re going to release to hockeyapp.

image

Go back to Environments, name your deployment template and add a new Task

image_thumb60

This list should now contain a Hockeyapp step since we installed that as our extension

image_thumb62

Configure the Hockeyapp step by selecting the Hockeyapp connection from the list. (the service connection you’ve created earlier should be listed here) Enter the APP ID you copied earlier and select the .ipa file that was generated by the build.

image

That’s all it takes to set up the release. for the final step we’re going to set the triggers in the “Triggers” tab of the release to be deployed continuously after each build.

image

Press the Green + To start a manual release towards Hockeyapp. Everything should work and the release should be created in Hockeyapp.

If you have any questions let me know via twitter @geertvdc or by commenting below.

Happy coding!

Geert van der  Cruijsen

Older posts