Swift – Google Analytics

I really wanted a simple way to add Google Analytics to my iOS (swift) app without subclassing the way they recommend. Swift makes this easy with Extensions. All you have to do add GA to your swift app (I highly recommend using cocoapods) and add this extension to your code base.

Extensions are essentially a category, if you’re coming from objective-c. From there, it’s as simple as adding this code in your viewDidLoad method.

I won’t cover adding Cocoapods to a Swift project since it’s been covered many times.

, , ,

Powered by WordPress. Designed by Woo Themes