It is no secret the mobile application market is continuing to grow at impressive rates with over 25% of the internet now being consumed from mobile devices. If you are only doing business on the web you are leaving a massive audience behind. The audience just got a bit easier to reach on the iOS platform that drives distribution to Apple devices like iPhones, iPads, and the new iWatch.
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.
Dive into your first Swift application
For this example we will use an open-source Swift application called Swift Weather. The application is straightforward: it uses your geolocation to show you the current weather using the openweathermap.org api. It uses Swift, CocoaPods, and the excellent AFNetworking library as the foundation for the application all available via GitHub. Clone the code from GitHub and get started immediately by signing up for a free trial of AppDynamics Mobile End User Experience Management.
Clone the project from GitHub: git clone https://github.com/JakeLin/SwiftWeather
Install the project dependencies with CocoaPods: pod install
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.
Congratulations your app is completely monitored with AppDynamics Mobile EUM!
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.
Check out our white paper on best practices for going live with a mobile application or find out more about AppDynamics Mobile EUM.
Interested in trying AppDynamics Mobile RUM? Check out our FREE trial!