Swift: A new approach for iOS and OSX applications

If you have been paying attention to Apple this year you will have noticed they released a new programming language at WWDC called Swift. Swift is an innovative new programming language for building iOS and OSX applications. Apple says it makes writing code interactive and fun, and the syntax is concise yet expressive, and that apps will run lightning-fast.

Any Objective-C developer will tell you that developing applications on the iOS stack is not as easy as it could be. Swift aims to solve that with a more modern and powerful language. Swift supports all the features you would expect for a modern programming language. Building Swift apps is pretty easy and Apple does a great job explaining how to get started with Swift development in the iOS developer library.

Sign up for AppDynamics Mobile EUM

AppDynamics supports any Swift based application and this blog is a crash course in how to monitor Swift applications with the AppDynamics iOS agent. AppDynamics Mobile End User Experience Management provides everything you need to understand the end users experience on iOS and Android mobile applications in production. If you haven’t already, you will need to sign up for a free trial of AppDynamics Mobile End User Experience Management to get a key.

Download the AppDynamics iOS agent

The AppDynamics iOS agent is extremely easy to integrate into any existing Objective-C or Swift based application. The first thing you will need is to download the iOS agent and get an EUM key from the getting started wizard in the controller. See our detailed information in the iOS agent documentation in the AppSphere Community.

Expose AppDynamics iOS agent with an objective-c bridging header

In order to expose the AppDynamics SDK to a Swift based application you simply need to configure an Objective-C bridging header. The easiest way to do that for an existing Swift app is to simply create a new Objective-C file in the project.

Update the build settings for the swift compiler to reference the objective-c bridging header:

Next, just add the import for the AppDynamics iOS Agent (ADEUMInstrumentation) to the objective-c bridging header which will expose the public methods to the Swift application:

#import < ADEUMInstrumentation/ADEUMInstrumentation.h >

Finally initialize the AppDynamics iOS Agent with your application key in the AppDelegate.swift with a call to the exposed library ADEumInstrumentation.initWithKey( “XX-XXX-XXX-XXX” ).

Make sure to link the libraries the AppDynamics iOS Agent depends on (libsqlite3, libz, SystemConfiguration, CoreTelephony):

Now that we have a completely instrumented application we can click run in Xcode and see our application Swift Weather application running live in iOS Simulator.

The power of monitoring

Now that our application is fully instrumented with the best mobile performance management solution available in the market you can start to explore the full power of AppDynamics. Through the AppDynamics Mobile End User Experience dashboard you can fully understand how your application is performing for your real users around the world.

With visibility into network requests from mobile apps to the server-side with snapshots that correlated the server-side interaction to make sure the backend is never a black box.

With Crash Analytics that feature crash trends and snapshot you can get a clear understanding of what are the most impactful crashes and all the code details (symbolicated stack traces) to resolve issues as fast as possible.

AppDynamics makes it easier to gather intelligence about your users and better understand your demographics with mobile analytics that include custom timers and metrics to understand your users and business better than you thought possible.

In high-production environments where release cycles are measured in hours or minutes — not days or weeks — there's little room for mistakes and no room for confusion. Everyone has to understand what's happening, in real time, and have the means to do whatever is necessary to keep applications up and running optimally.

DevOps is a high-stakes world, but done well, it delivers the agility and performance to significantly impact business competitiveness.