Apple just came out with the new programming language Swift . According to Apple, Swift will make it a lot easier and more fun to develop apps for both iOS and OS X. That’s in contrast to the current language, Objective-C, which is somewhat antiquated and considered by many to be difficult to use. Although Swift is easier to use, we are sure that there will be issues like crashes, slow request, errors and so on as we already know it from Objective-C and other languages. We also know that business will ask for usage statistics. This is the reason why we immediately investigated Swift and can now show you how easy it is to add proper tracking to your app in just 4 steps.

Step 1: Add Lib to your Swift Project

Once you have a Swift application, including the Mobile iOS Agent into the application project is very simple. First you add the iOS Agent static library  and header files to your project. Just a drag and drop exercise 🙂

Adding dynaTrace agent libraries to SWIFT project
Adding dynaTrace agent libraries to SWIFT project

Step 2: Add Bridging Header

The next step required to use the agent in your Swift project is to add a bridging header to your project. Create a new header file in your Swift project, and add imports to all of the Agent header files that you will be using.

Adding bridging header file to SWIFT project
Adding bridging header file to SWIFT project

Step 3: Change the Build Settings

Define in the Build Settings of the Swift Compiler where this bridging header lives on your hard drive:

Configure "Objective-C Bridiging Header" in the project settings
Configure “Objective-C Bridiging Header” in the project settings

Finally, set the Defines Module property to “Yes”.

Set "Defines Module" in the project setings
Set “Defines Module” in the project setings

Step 4: Run the App and Investigate the Data

As the latest version of the agent does automatic instrumentation we get the following data without doing anything else.

Swift App Visits

Swift App Visits

Crash Reports from the Swift App

Crash Reports from the Swift App

Requests Slowing Down the iOS 8 App

Requests Slowing Down the iOS 8 App

Thanks to our iOS development team especially, Allen Schuerholz, for making Swift monitoring that easy and available a week after the official announcement of the new language.

Conclusion

Swift is a new language which is easier to read and this will hopefully help people to create more robust apps for iOS. In case the issues still happen to be in the app, with Dynatrace you have a monitoring solution that can help you gathering the right information.