Post navigation

Apps, Xamarin

Developing (and Marketing) a Xamarin App using Visual Studio

I’ve been developing apps using C# in Xamarin for a number of years now, up until now as a side project. This year I decided it was time to focus, especially as Xamarin was bought by Microsoft earlier this year and the annual license is now free 🙂

In order to develop apps using Xamarin you have to decide whether to develop on a PC or a Mac and then get your overall system set up and running. My setup of choice was to do all my coding on my PC in Visual Studio 2015 and use my Mac Mini on the same network to run my IOS simulators on, and connect my IOS test devices to. It’s important that the installed SDK versions for Xamarin match on both the PC and the Mac or you can run into compilation or deployment problems down the line.

During the process of getting all of this setup, and up to date I ran into a number of issues which, from the Google searches I did, seems I’m not the only person to have these problems. I’ve collected a rough and ready list of some of the errors and their solutions to hopefully save others a bit of the time it took me to eventually get to a stable working system.

During this process you may need to know a couple of key things, being how to –

1. Find the IP address of your Mac on the network
2. View your Xamarin log files
3. Update the Xamarin and XCode installs on your Mac
4. Update the Xamarin and SDKs on your PC

If you still haven’t got up and running by the end of this post you can turn to both the Xamarin forums and Stack Exchange for help.


Xamarin setup process and common error messages

Typically at some point you’ll have a problem getting your PC to connect to your Mac – this wouldn’t be a problem in itself apart from the fact for some reason the useful error messages are hidden deep within the Xamarin log files. Using the instructions below to get to the log file you are likely to find a message like:

“The installed Xamarin.iOS (version 10.0) on the Mac macname.local (192.168.x.xx) is not compatible with the local Xamarin.iOS 10.2.”

Which is just telling you to update whichever system is behind and then it will all work ok.

1. Error occurred in the designer agent. Object reference not set to an instance of an object – designer won’t load. Can happen for a number of reasons, in my case when I went on to my Mac and opened XCode / Apple developer account there was a license agreement dialogue box that needed to be accepted by me. Once I’d done that everything worked fine.

2. Failed to create the a fat library. The solution to this was to go to the Mac and open Xcode. An update had been installed and it was waiting for me to accept a new user agreement. Once I’d done that and returned to Visual Studio on the PC I could build the project no problem.

Xamarin related updates

There’s a series of places that updates need to be checked when you’re using Xamarin – the PC, the MAC, and if you are debugging on a device, then the device environment itself.

Updates are located in Visual Studio on the PC. On the Mac there’s system updates which might include Xcode, that need to be kept up to date. You’ll also have Xamarin Studio installed on your Mac, and that has an updater that will need to be run as well – File > Check for updates.

On your device you need to follow the normal process for updating your version of IOS (I’m only developing on Apple devices at he moment until I’ve got more comfortable with the full development cycle).

Diagnosing Problems And Using The Xamarin Log Files

The log files can be located by going to Help > Xamarin > Open Logs in Visual Studio and then browsing to the relevant folder location as follows:

Mac – ~/Library/Logs/Xamarin-[MAJOR.MINOR]
Windows – %LOCALAPPDATA%\Xamarin\Logs (on Windows 10 this will be something like C:\Users\Bob\AppData\Local\Xamarin\Logs)

If you don’t see the folder you may have to tell File Explorer to show hidden files as they could be hidden by default.

Also in Visual Studio pay close attention to the output window. Top left of that window is a dropdown that says ‘Show output from‘ and then there are several options:

– Build
– Build order
– Debug
– Xamarin
– Diagnostics

I ran into a problem where my app would build fine but wouldn’t deploy and there was a blue message at the bottom of the Visual Studio screen that said the Mac Agent wouldn’t load but I couldn’t understand why. Once I looked at the Xamarin and Diagnostics output I found the useful message which told me ‘The installed Xamarin.iOS (version 9.8) on the Mac macem.local (192.168.1.xxx) is not compatible with the local Xamarin.iOS 10.0.’ Much more useful! So I set off to update things and ran into another set of problems, descriptions of which, and solutions are provided below.

Building Apps, Useful Tips

Xamarin IOS Keyboard Done Button & Event
To add a done button –
textBoxName.ReturnKeyType = UIReturnKeyType.Done;

This explains how easy it is to make sure the done button dismisses the keyboard.
https://developer.xamarin.com/recipes/ios/input/keyboards/dismiss_the_keyboard/

Xamarin app launch screens

I had a fair few problems figuring out launch screens, and from my online research it seems I’m not alone. There seems to have been a number of changes in the way it’s recommended you handle launch screens in Xamarin and this has resulted in there being a lot of outdated instructions out there online. Here’s a basic summary of how I got it working.

1. Create a new storyboard in solution explorer in Visual Studio by right clicking your IOS project and then selecting ‘Add New Item’ > Apple > IOS > Storyboard View Controller. I called mine Launch.storyboard. With your launch storyboard open in visual studio you’ll be presented with a blank screen. In the properties tab make sure the ‘Can be launch screen‘ checkbox is checked, and then from the Toolbox drag a view controller. Then I edited info.plist in a few ways as follows, I opened it as a text file and searched for :

UILaunchStoryboardName

The corresponding value should be set to the name of your launch screen storyboard, so as mine is called Launch.storyboard my key value pair in the info.plist file looked like this:

UILaunchStoryboardName
Launch

I saved and closed the file. From Solution Explorer I right clicked my IOS project and clicked Properties. Select ‘IOS Application‘ and find the Launch Images section, and select ‘Don’t use Asset Catalogs‘ from the drop down. Close the file.

That’s you ready to start building your launch screen. I initially followed this post – https://developer.xamarin.com/guides/ios/application_fundamentals/working_with_images/launch-screens/#launchscreens – but found it didn’t 100% match up to my development environment so hopefully the combination of this and that will get most people there.

Xamarin app icons

Xamarin seems to have trouble with app icons and the issue is confused by a gradual migration away from the old way of defining your icons in info.plist to using Asset Catalogs. I found this forum post that suggested this issue is a little buggy – https://forums.xamarin.com/discussion/48162/why-does-my-app-icon-not-show-up which suggests a little housekeeping on the Mac might be necessary.

Multiple screens & iOS storyboards

It’s pretty straightforward creating a single screen app, many people, myself included stumble once they try to create multiple screens. As ever there are several ways you can build a multiscreen app which often means its difficult to find a simple, get you started, walk through. This is the one that helped me make the leap to multi screen – https://developer.xamarin.com/guides/ios/getting_started/hello,_iOS_multiscreen/hello,_iOS_multiscreen_quickstart/

Submitting Your Xamarin App to the App Store

I found this article the most useful – https://developer.xamarin.com/guides/ios/platform_features/app_submission/
and https://developer.xamarin.com/guides/ios/deployment,_testing,_and_metrics/app_distribution/app-store-distribution/publishing_to_the_app_store/#Preparing_for_App_Store_Distribution

I’d recommend researching keywords for your app before you submit it, you’ll get a much better chance of it being a success if you hit the top of those search results. You need to look into App Store Optimisation (ASO), the App specific version of SEO. This article gives a great overview of ASO – http://www.silkstream.net/blog/2015/03/app-store-optimisation-aso-rank-factors-tips.html. Bear in mind that significant App store changes have been introduced by Apple in September and October 2016 so it’s worth making sure you only refer to up to date information – I’d recommend AppAnnie for everything detailed and up to date – https://www.appannie.com/insights/topic/aso-app-store-optimization/ , and they recently build a downloadable reference available here https://www.appannie.com/insights/aso-app-store-optimization/playbook-build-app-store-optimization-aso-strategy/

A huge list of App store SEO/ ASO tools that will get you started :
http://www.apptamin.com/blog/app-developer-tools/#aso

It’s also vital to set up a website to provide marketing data and support for your app. If you get your SEO research right for this you’ll also collect new users via your website where you can then direct them to your app on the app store. I’d recommend using SEMRush for SEO keyword analysis:

SEMrush

Publishing Xamarin app to the App store

Submit through iTunes Connect. I found this useful – https://developer.xamarin.com/guides/ios/deployment,_testing,_and_metrics/app_distribution/app-store-distribution/publishing_to_the_app_store/#Submitting_Your_App_to_Apple

I used Application Loader. Initially I got an error message saying the bundle identifier in my project didn’t match what was in iTunes connect – they have to be completely the same and are case sensitive.