Saturday, August 31, 2013

Run iPhone or iPad application in emulator


If you have an iOS app which you would like to send to a customer to see your progress you can do that easily, and without sending him the source code.

The customer needs to have a Mac and XCode installed with the same same version of the SDK you target in your app.

On the development machine:

1. Get simplaunch:

2. In Xcode, make sure compilation target is set to  “[ProjectName]\iPhone [x] Simulator”

     Compile your app (Project\Build or Command+B or RightWinKey+B)

3. Click on “Organizer” button (it’s in the right top of the XCode window)

4. Click the “Projects” tab and make sure your project is selected in the list from the left (it has the dot on the right of the name)

5. Click the arrow after the “Derived Data” path

6. Navigate to Build\Producs\Debug-iphonesimulator

7. Drag the [AppName].app on the “Simulator Bundler” icon on desktop

8. It will generate the bundled app is in the same folder with the source app

This is the app you can send to your customer.

On the customer machine, the customer needs to unarchive the file and run the app from inside (double-click it).


More info:

Friday, August 30, 2013

Android native development startup


#1. Download JDK 6
Java 7 is not officially supported by the Android SDK at this time. Please use the latest version of the Java 6 JDK.

For a 64 bit dev, note that the following trio is required:
  • 64-bit OS
  • 64-bit JDK
  • 64-bit Eclipse

#2.  Add the path to JDK (for example 'C:\Program Files\Java\jdk1.6.0_45\bin') to PATH environment variable.

#3. Download ‘Eclipse Standard’ from
It is not an installer but a .zip archive. Extract its content to a folder like D:\Eclipse

#4 Run eclipse.exe.
It will ask you to select a Workspace. By default it gives a location in C:\Users
Better choose something like D:\Eclipse\Workspaces\MyWorkspace

#5. Install ADT plugin for Eclipse (Android Development Tools)

#6. You might need to install platforms and packages
Emulator runs best using Intel image, so make sure it is selected for all platforms images you install (if available)


Keyboard shortcuts:

Copy and paste:

Thursday, August 29, 2013

PCL libraries overview

This is very good article on the PCL architecture and different ways to implement a PCL library:
Important quote:
“The code to use your library should also be simple.  That means the project referencing your library shouldn’t have to manage hooking up the platform specific part of your library with the portable part.  One way to do this is to have an initialize method in your platform specific part of your library which passes references to platform specific implementations down to the portable part of your library.  Here’s an example of what this could look like"
“For consumers of your library, it will be easier if the portable part of your library connects to the platform specific part with no action required on their part.  You can do this by having the portable part load the platform-specific part by calling Assembly.Load(), and using reflection to get the functionality it needs.  For an example of how to do this, see  the Portable Class Libraries Contrib project.  The code which handles this functionality is in the Source\Portable.Runtime\Adaptation folder.  The Reactive Extensions (Rx) also use this method to connect their portable System.Reactive.Core assembly with the platform-specific System.Reactive.PlatformServices assembly. “
A simple example of PCL is PCL Storage:
The project consists of a PCL project (platform independent) called PCLStorage.Abstractions and specific platform projects called PCLStorage.[PlatformName]
PCLStorage.Abstractions is referenced by all platform implementation projects (the PCLStorage.[PlatformName] projects).
It contains definitions of interfaces which platform implementations implement.
namespace PCLStorage
    public static class FileSystem
        public static IFileSystem Current { get; }

    public interface IFileSystem
        IFolder LocalStorage { get; }
        IFolder RoamingStorage { get; }

        Task<IFile> GetFileFromPathAsync(string path);
        Task<IFolder> GetFolderFromPathAsync(string path);

    public enum CreationCollisionOption
        GenerateUniqueName = 0,
        ReplaceExisting = 1,
        FailIfExists = 2,
        OpenIfExists = 3,

    public interface IFolder
        string Name { get; }
        string Path { get; }

        Task<IFile> CreateFileAsync(string desiredName, CreationCollisionOption option);
        Task<IFile> GetFileAsync(string name);
        Task<IList<IFile>> GetFilesAsync();

        Task<IFolder> CreateFolderAsync(string desiredName,
            CreationCollisionOption option);
        Task<IFolder> GetFolderAsync(string name);
        Task<IList<IFolder>> GetFoldersAsync();

        Task DeleteAsync();

    public enum FileAccess

    public interface IFile
        string Name { get; }
        string Path { get; }

        Task<Stream> OpenAsync(FileAccess fileAccess);
        Task DeleteAsync();

    public static class PortablePath
        public static char DirectorySeparatorChar { get; }
        public static string Combine(params string[] paths);
    public static class FileExtensions
        public static async Task<string> ReadAllTextAsync(this IFile file)
        public static async Task WriteAllTextAsync(this IFile file, string contents);

So when developer installs PCLStorage from NuGet for a specific project on a specific platofrm, NuGet manager will add as reference to the project the PCLStorage.Abstractions.dll PCL and the PCLStorage.[PlatformName].dll implementation.

In code, here’s how PCLStorage library is used:

public async Task PCLStorageSample()
    IFolder rootFolder = FileSystem.Current.LocalStorage;
    IFolder folder = await rootFolder.CreateFolderAsync("MySubFolder",
    IFile file = await folder.CreateFileAsync("answer.txt",
    await file.WriteAllTextAsync("42");

FileSystem.Current is instantiating the platform specific IFileSystem.

This code resides in a file in PCLStorage.dll PCL which is linked to other PCLStorage.[PlatfortmName].dll projects

PCLStorage.dll is not used besides just for holding files to be linked (it is not used as reference by any projects)

Why use ‘AppName.Droid’ for Xamarin Android apps and not ‘AppName.Android’


It looks like the if you use “Android” you end up having to use `global::Android` a lot.

So even if “Android” might look better than “Droid”, use “Droid”

Monday, August 26, 2013

Xamarin iOS app setup intro (Visual Studio)

To make the Visual Studio build iOS apps, you need to install Xamarin Studio on the Mac and possibly update your XCode version. Follow the requirements and instructions from
After all setup is done, in Visual Studio create a iOS \ Universal app.
Make sure you have Solution Platforms combo-box available in the standard command bar, otherwise click on the overflow button and choose Add\Remove buttons, and choose Solution Platforms. This combo-box should show iPhone and iPhoneSimulator options.
To connect to the mac machine, I am using VNC viewer:
In Visual Studio, running the app you might get an error on the mac: “The simulated application quit.” and an option to switch SDK.
Here’s the things I did to make it work:
- make sure you have Application name (‘HelloWorld_App1’), Identifier (‘com.helloworldapp’), Version (1) and Deployment Target (6.1) set.
- if you get the error, right click and select to dock the simulator.  I was able to select ‘Reset settings’ from the menu just before the error dialog appeared. If not try to delete ~/Library/Application Support/iPhone Simulator directory on your Mac

Other info on the iOS setup: