Archive for July, 2016

Recompile your Xamarin iOS projects to Android – Proof of concept

My first mobile programming experience was, unfortunately, using Jquery Mobile. I won’t go into too much detail, but it definitely wasn’t great. HTML on mobile devices definitely wasn’t ready at the time; it is not now either, but it’s at least bearable and jqm did not make that experience better.

After that I did some native work; it was my first brush with Objective C / iOS. I promised someone I would make that code open source but I would need to stamp it with a lot of warnings as the code (to me anyway) is absolutely ghastly when I read it now. It was kind of a side project which I did in the summer because I wanted to make something nice; the app turned out well but there was no marketing so you can’t even find it in Google anymore. I did learn a lot though; cramming a lot of learning into a very short time worked well for me. iOS turned out to be nice to code for and it thought me a lot about the API, transitions, animations etc.

I continued working native on both Android & iOS, far preferring iOS at that moment (at the time of writing that is still the case); the projects were usually little apps and games which with lower budgets. Clients were really trying to figure out mobile still.

Fast forward a year, I got in touch with more long term mobile development; I was asked to develop the mobile applications on Android + iOS for a fintech startup. This would be a project of at least months to a year. The previous developers were gone (… no reasons given) and I was allowed to start from scratch, not using the code of the previous coders.

As we suddenly now had a bunch of clients lined up next to this one and I was the only coder, I had to find some way of doing this while we gathered stability to hire more developers and in some way that I would not burn out.

I was very fast at doing projects for iOS by that time, but my Android skills were lacking. It took me far too much time to do both of them natively at the same time, so I, early on, picked Xamarin to do the development. It would at least save me from doing double work on the core of the system; most of the logic could be reused and the code still compiles to the respective native platforms while the frontends are really platform specific.

As I was working on the fintech startup, I had to delegate work for other clients to a freelancer for the time being. I would lay the groundwork in the evenings while he would build the actual app and while I worked fulltime on the fintech apps.

That turned out to be hard; even the apps I was doing focused 100% on were quite hard to do on both platforms at the same time.

So I took a week off to think how to fix this without driving myself and the freelancer mental. The latter basically already happened and we were to blame for that.

One of the options was to just drop Android; for most clients, Android was an afterthought anyway. They designed everything for iOS and then said something like ‘yeah, and that then also for Android!’.

But I went for another solution, at least I decided to see how far I could get; on the laptop I brought were my projects for Xamarin iOS and the projects by my colleague as well. I decided, lead by these projects solely, to see if I could get them to compile and run on Android ‘well enough’ to give to clients.

Locking myself up for a few weeks to get that done was a lot of fun and in the end I hoped it would help clients.

And it did; the LoB (Line of Business) projects we had could be recompiled without issues. The more consumer focused ones could also but were not sell-able that way. Great for prototypes however to show how it will look if you would run it on Android functionally, and, as a practical side effect; clients without an iPhone or no interest in getting their UDID or jumping through Apple hoops could now immediately test the app at the same time as their colleagues.

We tried to get investment for the project for a short while as we noticed that especially Microsoft shops were very interested in it; the fact that they could dev LoB applications in C# on client and server for all platforms (we were going to create a Windows mobile version) by writing one frontend was attractive to them. Unfortunately we didn’t have the time to pursue it and just left it.

After Xamarin Forms emerged, our developers started using that and my proof-of-concept remains what it was; a proof-of-concept. After some legal fixes, I can now finally release the source code. Don’t mind the code too much; it was rapidly written as people were desperately waiting for me. Here you go; hope it helps someone.

 

Ignoring files in Webpack

People tend to whine a lot about the documentation of Webpack; while I agree that it could be better, the thing is open source so if you want to help out just do it! One question however seems to be very poorly answered on the internet and my colleagues (and others) keep asking it; how do you simply ignore files?

You might have seen tons of warnings like “You may need an appropriate loader to handle this file type.” popping up when you run Webpack and you might want to get rid of them without doing what Webpack suggests; add a specific loader for all of them.

While this might mean you need more studying of how to use Webpack, often people get blocked for hours or even days(!) by searching for a quickfix(-and-we’ll-change-it-when-needed); that quick fix is;


npm install --save-dev ignore-loader

after which you can add;


loaders: [
{test: /\.(jpe?g|png|gif|svg|map|css|std|indent|html|txt)$/i,
loader: 'ignore-loader'},