Xamarin Projects – Configuration Tips

Use .gitignore

By default, you want to ignore anything that is automatically generated or downloaded. This includes compiler output (e.g. obj files), packages and components, user settings, etc.

Note that if you’re using Xamarin Visual Studio Extension, you probably want to base your .gitignore on a visual studio template.

This is what I use for my projects:


/NuGet
*.apk
*.ap_
*.dex
*.class
bin/
gen/
local.properties
.DS_Store
.idea/workspace.xml
.idea/tasks.xml
.idea/libraries
.gradle
/*/local.properties
/*/out
**/build
/*/*/production
*.iws
*~
*.dll
*.swp
**/obj/
monotouch_dll_content_processed
monotouch_trial
arguments
*.userprefs
*.mdb
Resource.designer.cs
Components/
packages/

Use command line tools to restore components and packages

Since we don’t keep assemblies in the repository, we need a way to restore them.

There are 2 issues here:

  1. Xamarin Studio is not so good in restoring dependencies. Most of the time it fails to restore all dependencies.
  2. If you’re using a CI server you want to be able to restore dependencies from command line.

See my previous post about command line tools for restoring dependencies.

I put both tools in the repository’s root folder so they are always available.

Xamarin – Package and Component Restore

We usually don’t keep packages and components dlls in the code repository.

Sadly, the Xamarin Studio IDE is not very good at restoring packages and components. More often than not, when someone clones a project and opens it for the first time, the IDE will not restore everything.

At this point, the common remedy is to open and close the studio several times, delete the project and re-clone it and other voodoo stuff.

Luckily for us, there are command line tools that you can use to explicitly restore dependencies. They are NuGet.exe and xamarin-component.exe.

I think the original motivation for these tools is CI (and we are using them for CI) but they are also quite useful on developers’ machines.

Note that the NuGet.exe utility is a special mono flavor. Apparently you can’t use the vanilla NuGet utility.

Instructions for use

Download

Download NuGet and the xamarin component tool. I usually add the files to each repository so they are always available to developers and to the build server.

Login to Component Store

To setup the xamarin component tool, you need to login with it to the component store. You do this only once and it will store your credentials info in your user folder so you don’t have to repeat it again


$ mono xamarin-component.exe login me@my.company
Password:
INFO (login): Computed cookie jar path: /Users/doron/.xamarin-credentials
INFO (login): Credentials successfully stored.

Restore Components

To restore components, you run xamarin-component.exe with the restore option and give it the path to your solution file.


$ mono xamarin-component.exe restore MyApp.sln

Restore Packages

To restore packages, you run NuGet.exe with the restore option and give it the path to your solution file.


$ mono NuGet.exe restore MyApp.sln

Summary

We demonstrated the use of NuGet.exe and xamarin-component.exe, 2 command line tools that enable you to manually restore packages and components.

These tools can be used either on a build server or by developers to overcome Xamarin Studio’s problems with restoring dependencies.

iOS Build Types

Everyone around me, including me, always get confused by the different iOS build types and account types.

I compiled a short guide that explains each build type and account type and what they’re good for.

Terminology

Build Types

AppStore build

A build that can be uploaded to the appstore. It can only be installed through the appstore or iTunes Connect either as a regular app (after it is released) or through TestFlight.

I.e. to use this build you must upload it to iTunes Connect.

Ad-Hoc build

A build that can be installed using iTunes or XCode.
You usually use this to make testing easier or combined with an enterprise account (see below).

Account Types

Regular (or appstore) account

The apple account is used to sign and publish builds.
We use the “regular” or appstore account for publishing to appstore and testing internally.
When we build Ad-Hoc build using the regular account, the build can be installed only on devices that have their UDID’s registered in the account and there can only be up to 100 such devices.
We we build AppStore build using the regular account, the build should be uploaded to iTunes Connect. There it can be installed using TestFlight by testers registered in iTunes Connect or published to the appstore.

Enterprise account

An enterprise account is meant for in-house distribution of apps without the appstore.
The reason is that when you build an Ad-Hoc build then you have 2 options.
If you sign the build using an In-House provisioning profile then anyone that has the build can install it. You don’t need to register their UDID’s or register them in iTunes Connect. This is good for in-house distribution.
If you sign the build using an Ad-Hoc provisioning profile then you can only install the build on registered devices. But since this is an enterprise account, you can register up to 1000 devices.
You can still build an AppStore build using an enterprise account and publish it to the appstore.

Which Build/Account Should I Use?

You should probably use an enterprise account only if you’re an enterprise that want to distribute the app internally without uploading it to the appstore.

If your means of distribution is the appstore, you should use a regular account.

If you use a regular account and you want to…

  • Test internally – make sure every test device’s UDID is in the provisioning profile and create an Ad-Hoc build. Send this Ad-Hoc build any way you want to testers. Or, create an AppStore build and upload it to iTunes Connect. Then add the testers’ emails to the testers of the app (in iTunes Connect).
  • Test externally (beta) – create an AppStore build and add the emails of the beta users to iTunes Connect as external testers.
  • Publish – create an AppStore build and upload it to iTunes Connect. Test it through TestFlight. Once you’re satisfied All that’s left to do is send it to review.

If you use an enterprise account and you want to…

  • Test internally -make sure every test device’s UDID is in the provisioning profile and create an Ad-Hoc build using an Ad-Hoc profile.
  • Test externally (beta) – you can use iTunes Connect as above. You can also create an Ad-Hoc build and use other tools (such as HockeyApp) to distribute it to beta testers.
  • Publish – create an Ad-Hoc build using an In-House profile.

Align Library for Corona SDK

I’ve been playing around with Corona SDK. I like it – it is simple and robust. It is very easy to make a game and the learning curve is very smooth.

One thing I found myself doing again and again is aligning things next to each other. E.g. putting the player sprite on the ground image, putting 2 buttons next to each other, things like that. It is easy but after some time it gets cumbersome, all those calculations of height and width.

So I created a small library to help with aligning things.

I posted an example in the Corona forums and the library is available on github (with more examples).

Screen Shot 2014-04-25 at 7.39.13 PM

Who Am I – A Facebook Game, Part 3

This is the third part of ‘Who Am I – A Facebook Game’. If you didn’t already, check out part 1 and part 2.
This post’s code can be found on the whoami repository on github.

Where Were We?

In the first part we introduced Who Am I – a Facebook game that helps you get a better understanding of your personality through friends feedback.
In the second part we developed all the basic functionality of the game using Python and Flask.

In This Post

In this post we are going to register our game on facebook.
We’ll go over the steps needed to register a game and configure it.
While at it, we will introduce ngrok – a tool that will allow you to host the game on your computer.
We will then integrate our game with the facebook API so it can use the player’s facebook data such as her name, photo and friends list.
Finally we are going to create test users and test our game.
Continue reading

Online Diagram Software to draw Flowcharts, UML & more | Creately

“light” diagram tools usually belong to one of 2 types:

Structured Diagraming

These tools make it easy to draw some types of diagrams. For example, a class diagram tool will include such features as a class box with a dedicated area for the class name and another for its properties. With such a tool you will be able to link 2 class objects together with a line so that when you move one of the classes, the line automatically updates so the classes are still linked.
In general, these tools have some semantic understanding of your diagram which they use to make life easy for you.
But the downside for all this help is that you are very restricted to what the tool designers implemented.
If you want to do a different diagram or use a UML feature that is not implemented in the tool, you are out of luck.

Open Tools

These tools will let you do anything – paste clip art, draw lines and text wherever you want. You can create any type of diagram with these tools but doing anything a little complicated will be very hard.

creatly

creatly is a great tool for drawing diagrams.
It doesn’t have a learning curve at all – I just started using it. I didn’t even need to sign up – I used my google account (and you can use other accounts, e.g. facebook).
I found it very versatile and was able to create class diagrams as well as simple mock ups and other types of diagrams.
Whatever I needed was already there. You can drag a class box or a clip art or UI widget. If you hover over an object in the diagram you get a toolbar that lets you easily add text or link the object to other objects using a line or an arrow.
When I finished a drawing, I exported it into a PNG and then just closed the browser tab. The diagram was saved automatically.
This is what I like – my objective is to write a post and I need some diagrams to make the post clearer. creatly let me focus on getting the diagram done with 0 time spent in managing the application.
I can really appreciate the thought that went into designing this tool.
Try it!

Online Diagram Software to draw Flowcharts, UML & more | Creately.

Who Am I – A Facebook Game, Part 2

This is the second part of ‘Who Am I – A Facebook Game’. The first part can be found here.

Where Were We?

In the first part we introduced Who Am I – a Facebook game that helps you get a better understanding of your personality through friends feedback.
We talked a little about Python and Flask and then proceeded to create a simple hello world web application in Flask.

In This Post

The final code for this post can be found in the whoami repository on github.
In this post we are going to add the core game functionality into our application – we will create the player’s home page that shows her personality and the test pages that allows the player to define his personality and give feedback to her friends.
Initially I wanted to make the game a facebook game in this post but it got too long. So facebook will have to wait for the next post.
Continue reading