Setting up simple Continuous Integration server for iOS application

CI tutorial

Intro

In this blog post I will show how to set up a Continuous Integration server for iOS applications. It will run our Unit Tests and confirm that builds aren’t corrupted.
We will use:

  • TeamCity as our CI server – it provides really good (and official!) support for iOS projects, integration with AppCode and easy to use interface.
  • xctool as a replacement for Apple’s xcodebuild – it eases a lot of pains connected with building an application.
  • git as our VCS – you can easily follow this post even if you use a different VCS, but from now on I will assume that you use git

Installation

TeamCity

  1. Download TeamCity for Mac OS X from https://www.jetbrains.com/teamcity/download/
  2. Unpack the downloaded package with tar xfz <name of package>.tar.gz
  3. Run TeamCity server with one default agent with script sh <TeamCity home>/bin/runAll.sh start
  4. Open http://localhost:8111/ in your browser.
  5. Select Proceed on the welcome page:
    TeamCity welcome screen
  6. Select one of the available databases.1 Select Proceed when you are ready.
    TeamCity database tutorial
  7. Wait for TeamCity to finish the initialization.
  8. Read and accept the license agreement and then select Continue:
    TeamCity License
  9. Create your administrator account for TeamCity:
    TeamCity Create account
    Now your basic setup is ready. You can fill in the remaining data, but it is not necessary to continue.

xctool

The easiest way to install xctool is to use homebrew. Just type in your terminal brew install xctool and you are done. If you don’t use homebrew, I highly recommend you to start.

Build script

Why build script?

We will use a custom build script instead of built-in TeamCity tools. Although those tools are much easier to use, a custom script has few deciding advantages:

  • much more flexible – we are not restricted to running XCTests and builds. We can add Acceptance Tests and UI tests later on.
  • agnostic of your CI server – if you ever decide to use different technology than TeamCity you will be able to reuse it.
  • goes with the source files – you can run it on your local machine2 and changes to it doesn’t require you to go through the web page.

My build script

  1. Copy the script below to the main folder of your project and replace APPLICATION_NAME and TEST_SCHEME_NAME with your application data. Don’t forget to remove my footnotes from the build script :).
  2. Add executable permissions to your script with chmod +x SCRIPT_NAME.
    # Clean repository, DerivedData folder and simulator
    git reset --hard3
    git clean -fd4
    rm -rf ~/Library/Developer/Xcode/DerivedData/APPLICATION_NAME*5
    xcrun simctl erase all6

    # Unit tests
    xctool \
    -scheme TEST_SCHEME_NAME \7
    -workspace APPLICATION_NAME.xcworkspace \8
    -destination "platform=iOS Simulator,name=iPhone 6,OS=8.3" \9
    -sdk iphonesimulator \
    -reporter junit:test-results/TEST-UnitTests.xml \10
    -reporter pretty \11
    clean test

Adding a project to TeamCity

Now that we have everything installed and the build script is committed into our project we can finally configure our first task in TeamCity.

  1. Open http://localhost:8111/ in your browser and log in to your previously created account.
  2. Select Create Project:
    TeamCity getting started
    If you already created any project you need to select Administration/Projects/Create project.
  3. Fill in Name and Project ID12 fields and select Create:
    TeamCity New project
  4. The next thing we need to do is to create a build configuration. Select Create build configuration:
    TeamCity project settings
  5. Fill in Name and Build configuration ID12 fields and select Create:
    TeamCity Creating build configuration
  6. Next step is to configure the VCS for your project:
    TeamCity Version Control System

      a) Select git as type of your VCS.
      b) Type in the name for your VCS configuration.
      c) Type in your VCS ID12.
      d) Type in the URL for your repository.
      e) Change master to the name of the branch you want to test (but leave refs/heads/).
      f) Select the appropriate Authentication method. The easiest ones to configure are Anonymous (if your project is public) or Password (if it is private).
      g) You can test if the configuration is correct now.
      h) When you are ready, select Create.

  7. Next we need to add steps to our configuration. From the left menu select Build Steps:
    TeamCity Configuration Menu
  8. And then Add build step:
    TeamCity Build Steps
  9. From the list of available build steps select Command Line:
    TeamCity Build Steps Selection
  10. In the Custom script section, type in sh SCRIPT_NAME to run your script every build and select Save:
    TeamCity command line
  11. Now we have Continuous Integration up and running but we can’t see the results of the tests. Select Build Features13 from the left menu:
    TeamCity Configuration Menu
  12. And then Add build feature:
    TeamCity Build Features
  13. From the popup menu select XML report processing (you may need to scroll – it is at the bottom of the list):
    TeamCity Build Feature Selection
  14. And from the Report type select Ant JUnit:
    TeamCity Build Feature XML Type
  15. In Monitoring rules we type test-results/*.xml, to tell the parser to take all results from the test-results folder. After that select Save:
    TeamCity Build Feature JUnit parser
  16. Test if everything is working with Run command in the right upper corner of the page:
    TeamCity Run

Summary

In this post we were able to run a simple Continuous Integration server that will run Unit Tests every time you make a commit to git. But this is not over!. There are few more things worth adding:

  • Make our server notify us by email about build results
  • Change the authentication method to use deploy key instead of our credentials
  • Set up production database
  • Add Acceptance Tests step
  • Make our server automatically start after reset
  • Separate Agent and HTTP server
  • Set up automatic sending builds to our testers and/or clients

We will add them in future posts.

______________________________________________________

  1. For evaluation you can select Internal, but TeamCity‘s advice is to change it as soon you want to move to production.  

  2. TeamCity can do that for you also through integration with AppCode 

  3. Reset git repository before build. This step is not mandatory. 

  4. Clean git repository before build. This step is not mandatory. 

  5. Remove DerivedData folder for your application. This step is not mandatory. 

  6. Erase the simulator before running tests. This step is not mandatory and can be dangerous if you have more than one agent, but it solved few problems with builds. 

  7. Default scheme is named after your project and it contains test target. 

  8. Skip this part if you don’t use workspaces. 

  9. You can specify here on which simulator you want to test your application. You can remove this line if you want to use the default one. 

  10. Redirect test results in jUnit format to folder test-results. We will use them later to display test results in CI. 

  11. Display test results to console. Useful for debugging. 

  12. ID can contain only alpha-numeric characters and underscores, is restricted to 80 characters, starts with a Latin letter and must be unique across all other similar IDs. 

  13. Build Features are commands that are executed after the build is finished. 

The iPad after 5 years – a revolution that has evolved and an “iPad killer” is still non-existent

The history of iPad and comparison review


Tablets as a device existed for many years before the release of the first iPad, but Steve Jobs have made a tablet, that has become an icon of the media, the Internet revolution and the beginning of the so-called post-PC era.

iPad – new techno wheel?

Apple has not invented tablets, and Steve Jobs did not invent the wheel. He gave it wheels and set it on a good, asphalt road – Apple changed the function of the tablet computer as a shortcut to the Internet. And it all started with a question – why do we need a computer keyboard? It could be replaced with a good touch screen, the optimal screen size and well refined virtual keyboard – and by 2010 … no one offered such a solution.

iPhone or iPad – the chicken or the egg?

Apple created the basis for today’s rapidly growing mobile market by issuing the first touchscreen smartphone in mid-2007. The world quickly became fixated on the new device, especially after the release of the famous iPhone 3G. When the success of the iPhone has already been well-established, Steve Jobs decided to issue a second child of Apple, which was to conquer the world. It turns out, however, that the iPad was planned as the first device but during the development of the intuitive computer without a keyboard, Jobs came to a conclusion that he must get people to “wear” it with them, and mobile phones already filled our pockets … It was so inseparable for us as our home keys. That is why the iPhone, not the iPad, was first introduced to the market.

Mobile revolution of the first iPad

The success and rapid strengthening of a dominant position by the iPhone made Jobs introduce the tablet – the iPad in the US appeared on 3 April 2010. This month it’s been (only) five and so much in the market has already happened, as if a whole era has passed. But let us go back to the past… After 80 days, Apple has sold 3 million iPads – a result many companies can only dream of. A 10 inch tablet had only a 1 GHz processor and 256 MB of RAM and the 5th version of iOS.

The iPad – only a fancy gadget?

However, many people from the very launch have had their doubts, which appeared in the internet on various websites. “Actually, why do we need a tablet?” – such questions were asked… Is it just a trendy gadget, too weak in performance and too limited in functionality compared to laptops or PCs? At the time, those doubts were justified – the smartphone was more handy and portable, while the desktop more efficient and better at home. The tablet attacked laptop positions, defended by first netbooks, and later ultrabooks. However Jobs, who was a genius and creative marketer quickly managed to drag users to his side:

The iPad versus other mobile devices

The iPad quickly killed netbooks, which were an interesting concept, but they were not so innovative and had an ill-fitting hardware for their operating system. Windows Vista was a failure, and the programs on a Windows XP often were lagging, so the only advantage of the netbooks were their lower prices, causing them to initially be a good-seller, but as producers felt the fever of gold, they started upping the price tag. This proved to be deadly for netbooks. The pricing policy also crashed the offensive invented by Intel’s ultrabook. Although this time it was supposed to not only be supermobile, but also efficient and elegant hardware tablet and laptop at the same time; It he has not won the market. Although ultrabooks were nice, efficient and well-designed, they costed around 1000 EUR. At this price the whole campaign was absolutely counterproductive. Unfortunately Windows 7, which was never developed as a mobile system wasn’t smooth enough either. Although the intention was good, the execution of this project and the pricing policy proved to be a failure. The same is happening with Google Chromebooks. And from the start, other producers of tablets haven’t made nothing better – still no iPad killer.

iPad – the secret of Apple’s first success

How did the Apple tablet do it? At the beginning it was cool and a big novelty – it was like an iPhone without the option of ringing – as elegant, but larger, more visible, with extended multimedia usage. Faithful Apple users where buying the first iPad from the start. iPads quickly spread not only in the US – in pubs, on the streets, even in parliaments, where politicians of different options liked to show up with the iPad.

The end of Jobs era

At the end of 2011, Steve Jobs passed away due to his ongoing sickness. Although Apple has lost a genius, the future was not a grim sight – quite the contrary … With time it got wings. The new boss, Tim Cook, was focusing not on revolution, but evolution, opening up more to the needs of customers that have never been in Apple’s stables. Along the way, however, there was a small failure – iPad 3, which came out shortly after the passing of Jobs had more powerful components, but also overheated a bit. This, and it still had the flaws of its predecessors – was heavy (weighing 650 grams), had a big and uncomfortable to hold screen, a size that did not allow to fit it in a jacket pocket, a too limited system back then and too few free-value applications… Those that were good unfortunately costed dearly.

The beginning of Cook era in Apple

Tim Cook in late 2012 made a small evolution and introduced what was missing in the iPad. When it appeared on the market it become a key success of Apple, which finally convinced me (and many others) to the Apple tablet – a nearly 8-inch iPad mini launched together with an improved iPad 4. Jobs had his opinions – a smartphones should have a 3.5-inch screen and tablet should have a 10-inch screen – because these were according to him, the optimum size of such devices. But even a genius might be wrong – it turned out that the smaller iPad mini attracted a wide interest, as users were willing to buy a device with different diagonals.

iPad mini – Apple’s bullseye?

iPad mini was the first Apple tablet with just the right size – it fits into every pocket of a jacket and wide pants. It could therefore be carried as an iPhone, while keeping the original iPad as a more classic home device. It was definitely lighter (approx 340 grams) than the current iPad (approx. 650 grams). You could easily hold it in one hand for long time without feeling fatigue. This is perhaps the first time Apple has dropped the price of tablets below known psychological barriers. But the iPad mini was not perfect – it lacked the Retina display and the latest processor at the time (in fact it was an iPad 2 in a smaller package).

iPad Air and iPad mini Retina – two perfect tablets on the market

But in late 2013 Apple quickly sent to the market 2 new key models of the iPad – a very thin 10-inch iPad Air and an even thinner iPad mini 2 with the latest 64-bit processor A7, a new iOS7 system with a lot of changes and the expected Retina with resolution higher than full HD, creating this time the ideal tablet, which began to sell very well. At the same time the price of first-generation iPad mini has fallen significantly – Apple finally wasn’t as expensive as before.

More Apps is the power of Apple?

Tim Cook came out with a different crowd of tablet users who didn’t buy Apple’s tablet before because of a too steep price, a bulky design or a lack of an intermediate diagonal. As if that was not enough, Cook took off the fee for the famous office suite applications by Apple – polished iWork suite of tools, which includes Pages, Numbers, Keynote, iPhoto and iMovie. Suddenly, they were offered for free. In the meantime a number of applications (also free) in AppStore increased exponentially, increasing the functionality of the Apple tablet.

5 best features of today’s iPad mini, which make this tablet great

Since the release of the first iPad Air and iPad Mini Retina, Apple has had virtually no competition, because the iPad also got rid of its biggest drawbacks – large dimensions, heavy weight, steep price and expensive programs.

Here are the 5 most important advantages of the iPad, which largely make this the best equipment currently as a tablet PC. First, the format of 4: 3 instead of widely used 16: 9 (4: 3 is ideal for reading Internet) and 2048×1536 Retina display, giving a pixel density of 326ppi – both of these solutions provide clarity and convenience of reading the Internet, newspapers and e-books on the iPad. The second is minimum weight – you can hold iPad mini Retina easily only with one hand for a long time without the feeling of a tired arm. Another thing is the battery, which operates several hours in heavy use, and is able to withstand even a few days on hold. The next thing is the largest number of applications on the AppStore, on Google Play there are many apps, but they are largely still stretched smartphone applications. And then there’s also the system – polished, fast, intuitive and not a laggy iOS. And last but not least – the elegance of execution – if we take any iPad in hand, you can easily see and feel it’s a premium device.

Cons of iPad?

Cons of iPad? Some can be found… It still has a non-removable battery, lack of ability to copy-paste, no AMOLED screen… Besides, Apple could add a dialer on the iPad as Samsung did with Note, but I guess Apple won’t do this, because it certainly would hurt iPhone sales. The iPad can still lose a bit of weight, but by the time of the revolution of flexible screens hits us, it is a minor thing to change…

Perfect can’t change quickly?

Recent models do not sell as well as some would like. Others immediately began to prophesize the twilight of popularity of the iPad, but I think just the opposite. These sales declines can be easily explained – the first market saturation – the fact that iPads are now very reliable and the first iPad Air and iPad mini are the devices in which nothing is missing and their users have no need to replace them. Even so, Apple still is selling now two times more tablets than (the second big player) Samsung.

iPad – ideal tablet PC after 5 years

After 5 years of development, we have an ideal tablet PC to day, which still is being chased by competition and still is uncatchable. While Samsung smartphones have chased out Apple, in tablets Apple still governs and splits. Looking at the mobile tablet market it will not change soon – thanks to the phenomenal movement with the iPad mini, Apple has removed the last defects and gave to the world an almost perfect device (in my opinion). Its perfection is indicated by the latest iPad mini 3, which is almost a copy of the older brother and its main novelty is… well, a fingerprint reader.

Evolution of the iPad – from a fancy gadget to a useful tool

The iPad has evolved from an elegant and snobbish fashion gadget towards a highly refined and useful tool for everyday use. Checking and sending emails, reading newspapers and online news, writing documents with a comfortable, not lagging keyboard (as in Android), watching TV stations through the net, creating presentations, keeping a notebook, journal and organizer – all of this is more intuitive than on any PC or other tablets. And it all fits within our pocket…

iPad – the best internet and magazine reader?

The iPad made the first revolution, but it is the consistent evolution that made it the leader of tablets despite a tough competition. Today, virtually most magazines and newspapers is issued on the iPad, furthemore there are publishers who decided to go only online. The iPad becomes a basic tool for reading magazines, newspapers and the Internet as the Amazon Kindle step by step is displacing paper books with e-books.

Still no iPad killer on horizon…

After 5 years, competition is still searching for an iPad killer. Looking at what is happening on the market, only Samsung would have the chance to catch up the iPad, but it requires focusing on their Achilles heel – on improving the software and the Android system (but that’s for Google to work on). Unfortunately, I have the impression that recently Samsung and Google instead of fighting using prices with the perfect Apple tablet, they want to sell their new products as more expensive… It came to an absurd situation, where Apple wins sometimes in the category of price / quality….

In see no iPad killers on the horizon. The “evolution of the revolution” in case of the iPad proved to be the ultimate bullseye. I wonder what the iPad will become in the next 5 years?

Rewarding employees basing on fair KPIs

Giving raises rewarding employees in IT

Our company is based on people – they are the most valuable asset we possess. Taking care of various aspects of the employment in order to make them satisfied is what basically makes us live and breathe.

One of these aspects is the absolute necessity to attain fair performance reviews combined with adequate salary settings. E.g. If a peer gets promoted regardless of not respecting assigned work, demotivation can spread like a disease within any team, or even the whole organization.

There are various approaches to salary setting. Let’s name the two most common:

1. Let the human nature do its work and do nothing – wait for employees to ask for a rise.

The drawback is that you would be relying mostly on the employee’s self-esteem and confidence as the catalyst for the whole issue. This can easily lead to an unfair setting and promotions of wrong people, simply because they might have a strong character. Others might end up on the other side of the rope, feeling unappreciated despite fulfilling their tasks more than adequately.

2. As the boss, periodically sit down and review the salaries on your own, basing it on a mixture of self-elaborated performance opinion and gut feeling.

This method is better, but not good enough. One of the vulnerabilities is promoting people who are maybe not the top performers but know how to show off in front of you. This is especially risky within IT where clear KPIs are not easy to set up.

We have concluded a different method, based on something along the lines of crowdsourcing, and been practicing it for quite some time now – we have learned that the team members’ performance review provided by a single person is always subjective and unfair, obviously. On the other hand, the studies show that the output created by combining multiple reviews together produces a result that is very close to the truth.

We utilized this by having our team members provide numeric reviews for each other. Each review answers a question: how much value does this person give to the company, in comparison to others? We combine these reviews by using algorithmic methods within Nomtek Logic (http://logic.nomtek.com) and use the output as an important indicator that helps to achieve an optimal salary setting. This approach secures a satisfactory level of fairness and is used in addition to a more standard and detailed performance review methods like this open question survey (http://www.surveygizmo.com/s3/630017/Employee-Performance-Review).

Naturally, the task of reducing of all of the person’s output to some number may seem as dehumanizing, however in this world it’s a necessary evil and has to be performed by each and every company.

We are aware that the system is not perfect… It has its exploits, it might not be as efficient within larger enterprises, but in a moderate team size, where personal attachment between each member is present, from our experience, such input is improving the quality of performance data drastically and thus, our developers happily participate in this task and take responsibility for their and their peers’ future, and in the end, this is what this system should do, right?

Nomtek Logic

By being a mobile development agency we probably are mostly associated with fulfilling contracts regarding apps for other companies, which is almost entirely true, we won’t deny it. But today I have the pleasure to stress the word “almost”.

We would like to present for the first time our most precious piece of fully enterprise software for efficient administrating of business processes – Nomtek Logic.

______________________________________________________

Nomtek Logic Corporate management tool

Genesis – A bit of backstory

Why did we create Nomtek Logic? Well, for the most obvious of reasons – because we needed it ourselves…

With a considerable amount of clients, subcontractors and suppliers, tangled in uncountable contracts of various nature, things tend to get messy… And they might get messy very quickly. But does it have be this way? Why do decision makers in your business have to drown in formalities which distract them? Why not make it simple? Those were the questions that made us search for a solution. The first natural reaction was to look for a ready-product that would somehow manage the issues we were starting to experience. Unfortunately we didn’t find anything that would suit our needs in an adequate manner – the found tools were either too complex or were missing particular features required in our case. Thus, we decided to create something on our own, which would be tailored to our needs, and yet simple in use.


What Nomtek Logic actually is?

It’s an online software tool which has two key ideological roles:

  • Limit bureaucracy within service companies and agencies via automation of repetitive management tasks and increased transparency.
  • Drive important processes in order to free decision makers from administrative driving and let them focus on their core function – making decisions.


Currently supported processes

Order Tracking

Supported types of Orders:

  • Fixed price with multiple milestones
  • Pay per Time, Pay per Sprint, Pay per Point, Material billing
  • Change Requests
  • Billed just once, weekly, monthly or in a custom way
  • Other:
    • Price calculation can be specified in an external spreadsheet

All active Orders within the company can be easily reviewed.

Deliverable tracking

The system ensures that responsible persons report the client’s acceptance of deliverables within Nomtek Logic and reminds them of overdue actions via notifications on either e-mail or other supported channels (e.g. Hall)

Automated invoicing

The system collects all information for all supported Order types and acceptances required for invoicing from the right people in the right time. Then it generates the invoice and sends it to the client.

Invoice Status and Vindication

  • The user can list all active invoices for a particular Client (e.g. incomplete or not covered), all unpaid invoices in the company or all invoices from a certain month.
  • The user can generate a nice e-mail with all invoices and payment details for a specific client.
  • The system can register incomplete/partial payments from clients and already paid amounts can be moved across invoices.
  • The system will remind about unpaid invoices when the due date expires and allows to define an additional payment term.

KPIs

You can check your total revenue in each month and your total unpaid invoices before and after due date.

General features:

  • VAT EU support
  • Multiple currency support
  • Multiple bank account support
  • Integration with Infakt for Invoice generation
  • Notification channels:
    • e-mail
    • Hall (corporate instant messenger)
    • Possibility to integrate with other channels
  • Unlimited number of users
  • User roles with access restrictions

Preview

Nomtek Logic Screenshot client dashboard Nomtek Logic Screenshot client details editing Nomtek Logic Screenshot invoice editing

______________________________________________________

Although the product is somewhat early in development, it fully supports all of the aforementioned features and this makes it ready for public usage. However, at this stage, we would like to keep its distribution controlled to some extent, so we’re refraining from traditional “buy and sell” methods, but this does not disallow anyone from asking us on how to obtain access. On the contrary! Send us a message and we’ll talk over the integration of Nomtek Logic for your company.

Scanning rooms with an iPhone

About a month ago I worked on a prototype project which would allow users to measure their rooms using an iPhone. It was a very interesting experience and I would like to share what I have learned. First question which comes to mind is – is it even possible? Answer – yes, it’s possible and was done before (look at Roomscan app on the AppStore).

As usual with this kind of task, before writing the first line of code, I started with some research on the subject. Turns out this topic is quite often picked up by a variety of people on different sites. Almost all of them are told that it’s not possible or very hard to accomplish. Don’t be discouraged by this, just as I wasn’t. I just told myself, that there is no learning without trying and picked up the first physics book that I was able to find. Yes, physics! You will see why…

 

Gathering data

As most of you know, the iPhone can detect its movement. What you probably didn’t know, is that it has three sensors to do so. First and most important is the accelerometer – it measures the acceleration affecting the device in a 3D space.

iPhone accelerometer axis graph

Source

The second one is the gyroscope which detects the rotation of the device, relative to the gravity.

iPhone Gyroscope

Source

Last but not least is the magnetometer, detecting magnetic direction the phone is facing in relation to the real world north direction.

iPhone magnetometer

Source

 

Calculating distance

The data from those sensors is easily accessible with the Core Motion framework. So where is the problem? Well, first of all we can get the acceleration, the rotation and the direction, but not the distance. So how to transform the data we have to the data we need?

At this point, we cannot proceed without some basic knowledge of physics. What is acceleration and how to derive distance from it? Acceleration is a vector (a vector is a mathematical entity which has a value and a direction in a 3D space – x, y, z coordinates) which describes velocity changes in a given time and can be described with the formula below:

acceleration = velocity change / time change

If the acceleration is constant or time change is very small we can say:

velocity = acceleration * time

Now we have the velocity which gets us one step closer to getting the distance. Velocity is also a vector – it describes the rate at which an object changes its position.

velocity = distance traveled / time of travel

Again if the velocity is constant or time of travel is very small we can say:

distance traveled = velocity * time

 

If the initial velocity is equal to zero then:

distance traveled = (acceleration * time) * time

And if not then:

distance traveled = initial velocity * time + (acceleration * time) * time

Simple? Maybe… But we have to remember that those formulas are 100% accurate only if time between measurements is infinitely small, which in real life isn’t possible. Core Motion maximum sampling frequency may vary between the devices but should be in a range of 50 – 100 measurements per second. It’s not much, but it’s enough to get some usable data.

Ok. We have displacement (vector of distance) but its x, y, z coordinates are in the coordinate system of the device, which changes when we rotate the device (z axis is always pointing from the screen).

This type of data is useless, unless we transform it to the world’s coordinates system. To do so we need the data from the other two sensors – gyroscope and magnetometer. To make this kind of transformation we can use a rotation matrix (you can find more information on the subject here). Fortunately, we don’t have to calculate the matrix manually, as it’s already done by the Core Motion framework. Our only job is to use it to transform the initial displacement vector.

At this point, if we were living in a perfect world, we would get a perfect displacement vector, which means we would be able to accurately reproduce the device’s movement. Unfortunately, inaccuracy of motion sensors comes into play.

 

Boosting data accuracy

Don’t give up yet, as there is hope! Instead of using raw data from the sensors, if we pass it through a well selected virtual filter, we can get some nice results. A low pass filter will smooth out the data we receive and a high pass filter will cut out the noise from our measurements.

Accelerometer data diagram with and without low pass filter

Accelerometer data diagram with and without low pass filter; Source.

With filtered data we get much better results – not perfect but usable. To get the best results I tried a lot of different approaches. In the end I chose LERP (a kind of a linear interpolation which takes a previous data point into account when calculating the next one) for its simplicity and rather fine results.

xValue = oldXValue * lerpFactor + newXValue * (1 – lerpFactor)

After about a week of research I was able to receive results with about 20 – 40 cm of measurement error which in my opinion is bearable. With a better filter the measurement error can be further decreased by a meaningful amount. Here are some screens from my app – the curved lines are paths I walked with the app turned on.

Basic room scanning app result

I walked through my room from corner to corner touching each one (green points). It’s clearly visible that I didn’t walk in straight lines (because I had to bypass furniture). The last two corners I touched twice in the same spot but the green points are misplaced. It happened because of the device’s inaccuracy.

 

Conclusion

So is indoor distance measurement usable for real life applications or is it just a meaningless feature? It depends on how would you like to use it and what level of accuracy you require. I’ll leave it for everyone to decide on their own.

PS. I was working on iPhone 5. iPhone 6 and 6+ have a new generation of motion sensors. Can’t say without testing, but it’s possible that distance can be measured with a much better accuracy on the new devices.

Poland scores second as the best country for education in the world!

There is a common knowledge among the Poles that our level of provided education is mostly adequate, but on a personal note, I never expected that we actually would be indexed as the nation which has the second best education on the whole globe.

According to OECD “Better Life” index, Poland is right after Finland (the undisputed leader), with the highest score in “Education”.

OECD Education Poland second best

SOURCE: http://www.oecdbetterlifeindex.org/#/00005000000

How OECD gathers data can be found here.

I won’t deny that one of Nomtek’s key selling points was, that “we provide the best talent available” and we wrote about Wroclaw being one of the most potent Polish cities when it comes to human ingenuity, going as far as branding it the “Polish silicon valley” (whole article here), but what OECD gave us, is proof of what we believed in, and that’s, for lack of a better term, awesome!

As a marketer, it fills me with great pride and joy that I can back this claim with such strong evidence. After all, how often does one get a chance to work with people, who have the potential to become the best in something in the whole world?

Adjusting your app to iOS 8

Apps under iOS 8

I’m sure most are aware that recently Apple launched a new version of the iPhone operating system – the iOS 8. For those who did not have the chance to catch the latest news – the launch happened yesterday. ;)

Instead of simply spreading the news around, we decided to go swiftly with a step further and briefly analise what opportunities and potential problems the new OS may create for existing apps.

Our first and foremost advice before reading further:


Do a quick test of your app ASAP! If anything, it might be crashing under iOS 8.


After you verified the above, which is after all the most important issue, we can continue with the subject. :) The core of our analysis was to pinpoint potential problems in our own existing apps and share the knowledge found in the process, as well as to give a bit of advice. Generally, please treat the cases we included here as “areas of required extra attention”. Here we go…

  • So far, the graphics had to be delivered in two versions – for Non-Retina (1x), and Retina (2x) display. Now the iPhone 6+ comes with a higher screen resolution than any iPhone before (iPhone6: 750×1334, iPhone6+: 1080×1920) and the highest Pixel Per Inch ratio from all portable “iDevices” – 401 PPI.
    This forced Apple to add a new standard for graphical resolution in applications – they called it “3x”. This is why we had to add new high resolution graphics to make sure that our app looks perfect on the new iPhone. It was little tricky though… Generally, before showing anything to the user, the image is rendered with a resolution of 1242×2208 (3x) and then downscaled to fit the screen. Because of this, we had to use the graphics with a resolution of 1242×2208.
    This link provides some useful information on how to prepare graphics for the new iOS: http://www.paintcodeapp.com/news/iphone-6-screens-demystified

  • The new iOS means a new iOS Compiler for developers… And all compilers differ more or less. With the new one our code couldn’t be compiled without errors or, in worst circumstances, the app crashed during run, which renders it useless.
    If you took our advice at the beginning of this article and verified that your app is indeed crashing, the case presented below might be somewhat helpful.

    The new compiler does not generate iVars automatically when overriding fields, but a fast solution to add @synthesize fixed those issues.

    Foo.h:
    @interface Foo : NSObject
    @property (strong,nonatomic,readonly) NSString *description;
    @end
     
    Foo.m:
    @implementation Foo
    @synthesize description = _description; //Required in iOS8
    - (instancetype)init
    {
    	self = [super init];
    	if (self) {
       	_description = @"FooBar";
    	}
    	return self;
    }
    @end
     	
    //Second example
    FooOperation.h:
    @interface FooOperation : NSOperation
    @property (assign, nonatomic, getter = isExecuting) BOOL executing;
    @end
     
    FooOperation.m:
    @implementation FooOperation
    @synthesize executing = _executing;
    - (instancetype)init
    {
    	self = [super init];
    	if (self) {
        	_executing = YES;
    	}
    	return self;
    }
    @end


  • Another issue was discovered when we noticed that some of our views are not looking good when compiled with the new compiler. Sometimes the margins were wrong, and sometimes the size wasn’t correct. The reason for this was, that the custom UICollectionViewCell (created via XIB) does not have a specified ContentView (visible in e.g. UITableViewCell) in the view browser. Thus, if we wish to use AutoresizingMask in a view (when we’re not using e.g. AutoLayout) it is impossible to turn those on within Interface Builder (IB). A solution is to do it via following code:
    - (void)awakeFromNib
    {
        [super awakeFromNib];
        self.contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    }

    What is strange, is that the behavior of the view differs in iOS 7 and iOS 8. The latter has AutoresizingMask turned on and the former has not. This causes the views not to rescale properly:


There were some other, minor inconveniences the update caused to our other applications, but those seem to be specific to said apps, rather than iOS 8 itself.

But the iOS 8 isn’t all about issues and problems. It’s important to remember what the actual merit behind upgrading any system is – the novelties… Yes, each update is designed to bring something new to our phone: make it faster, more reliable, expand its functions and make more pleasurable to work with. Let’s focus on what can the new system offer.

The Looks

As with every commercial OS from Apple’s shipyard, it would be awkward to start with anything other than the aesthetics, especially with the complete redesign of the iOS 6 to iOS 7 Apple served us last time. However, this time Apple decided not to make another 180 degree turn. In fact the changes are very subtle…

  • The “Today” screen received an overhaul, mainly through the addition of Widgets and some customizability features.

While the visual novelties cannot be branded as something stellar, the support for app Widgets is definitely a great addition to have and will allow applications to serve with additional content.

New functionality

Most of the new functionality supported by the new iOS is directly interconnected with either the iPhone 6 or the Apple Watch, since those devices hold the necessary hardware to facilitate the said new features. It’s not hard to understand the reasoning behind the design – Apple has always looked more into the future, focusing most, if not all, effort in software support on products they have just shipped or are just about to ship.

  • Widgets – Although we mentioned them in “The Looks” section let’s not forget that those are a part of functionality, probably even more than a part of aesthetics. Having a widget basically provides for an additional screen which can be filled with app’s content – your content, thus providing the app with more popularity and usage time if utilised correctly. A more elaborate medical reminder, a stock auction monitor? The possibilities just improved vastly.
  • ApplePay – A service similar to PayPal with a bit extended credit card management and shared card data between different other services – e.g. all cards added to an iTunes account are instantly available for other transactions. Since the iPhone 6 will allow for NFC payments, it is only natural that its operating system has to have something more elaborate in the payment service area. We’re very positive that this will be a great addition to enhancing future apps – a unified payment solution without the need to search for additional providers, middle-man nor a requirement for users to register at a billion other services. We can’t think of an easier way to turn your app into a mobile shop.
  • Custom keyboard support – This is a groundbreaking functionality if looked at closer. The original iOS keyboard, although branded as outdated by some, was sort of iconic for the iPhone and iPad products. Since Apple is opening a new niche path for developers, we can foresee the Swipe system developed for iOS even at this point. SwiftKey already grabbed the opportunity: http://swiftkey.com/en/keyboard/ios/

To bring some perspective to the whole topic, we can say that the direction Apple is taking with the new iPhone is definitely towards functionality instead of simple riding on brand awareness. How will this pave the company’s or the product’s future is yet to be seen, although personally, we have high hopes. From our point of view, new functionality equals new challenges and paths to explore.

How channel-based IM tools optimize work efficiency

Hello fellow programmers!

In this short text I explain just one argument why is it worth to use a channel-based Instant Messaging service within a company, like HipChat, Slack or an old and good IRC. The reason is notifications.

Every day we get many notifications from ticket management systems, social networks and numerous other tools. Some of them are more interesting, others are less. Of course we should avoid receiving spam i.e. notifications that don’t bring us any value – those are expensive time eaters. We should really take care and make sure we are not receiving notifications that we don’t need.

When used properly, notifications are very helpful. Here’s a list of some interesting notifications that we have already configured within Nomtek or are going to configure them soon:

  • someone has submitted some code and continuous integration tests have failed
  • someone commented upon an issue within the issue tracker
  • a client did not pay on time – it is necessary to send a reminder
  • a particular programmer will soon have no tasks assigned and should be assigned a new project
  • someone has retweeted one of our tweets
  • there is a new big deal on our radar

Traditionally, companies would use e-mail for those things.

Emails need to be clicked to see the content. IM by nature do not require to get inside, as long as we are looking at the right channel.

Clicking an email in reality is time costly. You may say it’s a simple action but in reality, if it takes 2 seconds more than optimal time, it is a big difference, especially if we would like to deal with many notifications and communicating with others is a big part of our daily work.

With IM channels, you may not want to look at particular channel, like for example a Marketing channel, if you are not interested at the moment. Notifications can be easily directed to channels with services like ifttt.com. It is enough if one person configures a notification and then all interested people can join the channel and take benefits.

Of course we can imitate IM channels within our e-mail clients by creating folders and filters (mark as read and move to folder). This may be a good alternative for one user but it will not be so for organizations, as it is normally too difficult to force the whole organization to use the same configuration of folders/filters.

Getting access to information faster often brings more value than we previously thought. Before purchasing my first MacBook I would never complain about my laptop’s launching time – I considered it to be pretty good. The first MacBook I’ve had was waking up much faster and then I discovered that for this simple reason the computer can be used in numerous new situations in which I would not bother with more traditional PC, for example during a car trip to my customer’s site.

Software RnD organizations exist where checking out a code repository in order to start the project takes 2 hours and no one cares about it, so why would I care about 2 seconds? That’s why:
Our short term memory has its limits. When we put additional tasks or information into our short term memory or need to keep the information for a bit longer, some part of the context that was residing there gets kicked out or fades away, even if the new task are just two additional moves of our hand. Any disruption of this form removes our ability for deeper insight and better decision making. From this perspective every time or effort improvement related to communication tools is a huge step, especially in cases when our work is brain-intensive and we communicate a lot with people and systems. We can unlock more brain power by limiting the number of clicks and time delays. Making better use of the last few parts of our short term memory should give us a lot of extra power.

This is why I would suggest to every software organization to pay more attention to communication tools that are used. In particular, I would recommend to use more sophisticated IM tools created for business and to deliver notifications as instant messages to channels within those IM services.

First impressions from Swift programming language

Hello fellow programmers!

A language for a programmer is his/her ultimate medium of expression, we are spending thousands of hours editing the code, thinking in the code (sometimes even dreaming in the code :) ). So it’s no surprise that introduction of new programming language from Apple was the most exciting event for us at the WWDC conference this year.

After spending some time on analysing this new programming language we have a few spots that we want to share with you. We are really excited about Swift. It looks like a much cleaner language then Objective-C. Below is our list where + means pros, - cons and +/- something in between ;).


General

+ no need for semicolons

+/- ranges – Although we really enjoy the addition of ranges, the syntax for it is a bit confusing. It is really easy to miss one additional dot character.


Error handling

+/- assertions – We are not sure about the decision of disabling them in the production code. Although you should eliminate situations like that in the production code, if you happen to forget to do that, they can provide you with a nicely formatted feedback.

- no exceptions – We don’t see any easy way to control exceptional flow of your application. Was it a design decision?


Variable and constants

+ var for declaring variables

+ let for declaring constants

+ tuples – You can use them with optionals and enums for error handling

+ type inference

+ optionals – Really good protections against nils, the motivation for such a solution has a good explanation here: http://deanzchen.com/the-best-design-decision-apple-made-for-swift


Operators

+/- == for equals, === for identity check – getting used to this change can be painful at start. Also to define your own equals you need to use operator overloading.

+/- operator overloading – you can override an operator for your types, but you do it by a global function


Functions

+ there is no visible distinction between a function, a method and closure – you can now do a lot of functional programming stuff (functions are first class citizens – you can have a function as a parameter to another function, you can return a function from another function, hooray!)

+/- functions with more than one argument – We find the new syntax of calling methods and functions a bit confusing and inconsistent. The first parameter without a label, next parameters with labels (unless it is an initializer and you haven’t specified other rules with # and _ characters)


Classes

+ automatic imports

+ default values for properties

+ is – shorter than isKindOfClass and still self-explanatory

+ as, as? – really simple and safe (because of the optional mark) type casting

+ AnyObject, Any

+ generics – welcome type safety in collections :)

+ subscripts – nice syntactic sugar

+ override annotation – the compiler can warn you about accidentally overridden methods

+/- only properties, no instance variables – if you override your getters and setters you don’t have access to the instance variable. Probably you need to declare an another property to store your value (or is it an instance variable then, like in C#?)

- class keyword for static (type) functions – why not one keyword for classes, structs and enums?

- no access modifiers – this is the most problematic issue with Swift right now. You can still use conventions (underscore in the name for private methods), but it is nice to have some mechanism to control that. We heard that it will eventually have it (https://devforums.apple.com/thread/227288).

- no (or bugged) method overloading – right now you can write functions with the same names and different parameter types, but at runtime only the first one will be used (for all types)


Structs and enums

+ value types – structs seem to be excellent for little domain types (http://en.wikipedia.org/wiki/Value_object)

+ enums – you can encapsulate all your switches in one place

- mutating – it seems to be really weird to have immutable structure which sometimes is mutable

- array – it is really hard to understand when two arrays are no longer the same

- static for static (type) functions – why not one keyword for classes, structs and enums?


Summary

As you can see we identified much more pros than cons. Readability and clarity of Swift is much higher than Objective-C, it looks that it will be a real joy to write applications in this new programming language. The biggest pros for us, except elegance and clarity is incorporation of functions as first class citizens. It looks that learning functional programming paradigms was not in vein – now we will be able to use at least some functional programming idioms in Swift :D. Also we love the way Apple tackled the nil problem – optional values is a bold decision that should greatly improve reliability and maintainability of iOS applications. And last but not least: let and var keywords for constancy and variable declarations, finally there is a language that doesn’t assume by default that you want a variable. In fact, the opposite is true: what you want is usually just a constant and now we have a very nice way to express this by the let word. Also there is a beautiful symmetry here: when you want a variable you have to declare it with var. So there is no default, you always have to use var or let, two 3 letter words that will indent the name of your constants or variables by exactly the same number of characters.

Kudos to language designers. Thank you!