Profiling with Signposts
Signposts provide a powerful option for logging your app’s runtime resource usage. When
viewed in Xcode’s Instruments, signpost logs allow you to model your app’s performance over
time. These profiles help you find bottlenecks and other anomalies in your code. Beginning in
version 7.1, Mobile SDK add signposts in heavily used portions of its code so you can profile its performance in your
app. Mobile SDK
signposts are available for Swift and Objective-C apps.
In debug profiles, enabling signposts requires a single flip of an Xcode switch. For production profiles in apps that use CocoaPods, you make a few changes to the Podfile and then rebuild.
Using Signposts in Debug Builds
In Mobile SDK libraries, signposts are pre-configured for Debug builds. However, Xcode profile schemes default to Release builds. Let’s change that.
To profile a debug build:
- In the Xcode taskbar, click the scheme name and select Edit Scheme.
- Select Profile.
- Set Build Configuration to Debug.
Using Signposts in Production Builds
To profile a production build with Mobile SDK
signposts, you don’t edit the default profile scheme. If you’ve already tinkered with
default settings, however, verify them as follows:
- In the Xcode taskbar, click the scheme name and select Edit Scheme.
- Select Profile.
- Make sure that Build Configuration is set to Release.
If you created your project “manually”, without using forceios or CocoaPods, your configuration is ready to run. Skip to Running a Signpost Profile Build.
If you used forceios to create your app, CocoaPods controls the settings for Mobile SDK pods. To
profile a production build of a Mobile SDK app that uses CocoaPods:
- Edit the following section of your app’s Podfile.
1# Comment the following if you do not want the SDK to emit signpost 2# events for instrumentation. Signposts are enabled for non release version of the app. 3 post_install do |installer_representation| 4 installer_representation.pods_project.targets.each do |target| 5 target.build_configurations.each do |config| 6 if config.name == 'Debug’ 7 config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'DEBUG=1','SIGNPOST_ENABLED=1'] 8 config.build_settings['OTHER_SWIFT_FLAGS'] = ['$(inherited)', '-DDEBUG', '-DSIGNPOST_ENABLED'] 9 end 10 end 11 end 12 end- Change if config.name == 'Debug' (as shown here) to if config.name == 'Release'.
- Remove the '$(inherited)', 'DEBUG=1' and '-DDEBUG' settings.
1# Comment the following if you do not want the SDK to emit signpost 2# events for instrumentation. Signposts are enabled for non release version of the app. 3 post_install do |installer_representation| 4 installer_representation.pods_project.targets.each do |target| 5 target.build_configurations.each do |config| 6 if config.name == 'Release’ 7 config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['SIGNPOST_ENABLED=1'] 8 config.build_settings['OTHER_SWIFT_FLAGS'] = ['-DSIGNPOST_ENABLED'] 9 end 10 end 11 end 12 end - Important: Close your workspace.
- In the Terminal app, switch to your workspace directory and run: pod update
- Reopen your workspace in Xcode.