Installing the iOS libraries

Install the iOS libraries so that your customers can provide detailed information about bugs and crashes that happen with your app.

Before you begin

Be sure that you meet the following requirements before you begin this procedure:
  • If you are using MobileFirst Quality Assurance SDK version 3.2.0, or later, you must build your project using Xcode version 7.0, or later.
  • If you are creating a Swift app, you must have OSX 10.9.4 or later and Xcode 6.0 (all releases) or later.

About this task

The examples show mobile apps that are written in Objective-C and Swift.

Procedure

  1. Create an app in Xcode Project.
    Important: If you are using Xcode 7.x on iOS 9 and the MobileFirst Quality Assurance iOS SDK version 2.4.1 or earlier, you must set the Enable Bitcode setting to No in the Xcode Build Settings.
  2. Start Xcode and load the app project into Xcode. Your project folder that is similar to the following example for a Swift app is displayed:
    Swift app in Xcode project folder.
  3. Download and extract the SDK.
    1. Download the most recent version of the MobileFirst Quality Assurance iOS client libraries. For more information about downloading these libraries, see iOS SDK for download.
    2. After you download the MobileFirst Quality Assurance iOS SDK, extract the contents of the compressed file to your file system. A file folder that is named Q4M.framework is created.
    3. In the Xcode Project Navigator, create a Frameworks group. To create a group, right-click the iOS app project and select New Group.
    4. Drag the MobileFirst Quality Assurance SDK for iOS Q4M.framework folder into the Frameworks group in the Navigator tree. In the Choose options window, select Create groups, and check the box for your project name as the target. The Production framework is added to the project.
      Frameworks folder in app project.
    5. Copy the Q4M.framework folder into the root folder of your app project.
  4. Add the required libraries to your Xcode project.
    1. In the Xcode Project Navigator, click your project and then click Build Phases.
    2. Click Link Binary With Libraries.
    3. Add Dependency Libraries. Under Link Binary With Libraries, click + and add the following frameworks:
      • AssetsLibrary.framework
      • AudioToolbox.framework
      • AVFoundation.framework
      • CoreData.framework
      • CoreLocation.framework
      • CoreMedia.framework
      • CoreMotion.framework
      • CoreTelephony.framework
      • CoreText.framework
      • CoreVideo.framework
      • MediaPlayer.framework
      • QuartzCore.framework
      • Security.framework
      • SystemConfiguration.framework
      After the libraries are added successfully, they also appear in the Xcode project tree inside the Frameworks folder.
      Add dependency libraries in Objective-C.
  5. Set Linker Flags. Set the Other Linker flags for Debug and Release to -ObjC:
    1. In the Xcode Project navigator, click your project and then click Build Settings.
    2. In the Search field, enter Other Linker Flags.
    3. Under Other Linker Flags, add a row for Debug and then enter -all_load -ObjC.
    4. Under Other Linker Flags, add a row for Release and then enter -all_load -ObjC.
    Tip: If you cannot use the -ObjC flag or Xcode cannot find the MobileFirst Quality Assurance Library, you can load specific libraries by using the -force-load flag:
    -force_load $(PROJECT_DIR)/Libraries/Q4M.framework/Q4M

    If your project uses a different directory structure, you must modify the path.

  6. Objective-C only: Add the following import statement to the AppDelegate.m and ViewController.m files: #import <Q4M/MQALogger.h>
  7. Swift only: Add an Objective-C bridging header for the MobileFirst Quality Assurance SDK for iOS. The MobileFirst Quality Assurance SDK for iOS is written in Objective-C. Therefore, to reference the SDK from your Swift projects, you must add a bridging header to your project. The bridging header imports Objective-C header files into your Swift project.
    1. Right-click the project root node, and select New File.
    2. In the Choose Template window under iOS, click Source, and then click the Header File template.
      Header file template.
    3. Name the file MyProject-Bridging-Header.h, where MyProject is the name of your Swift project, and check the MQASampleAppiOSSwift target. For example, name the file MQASampleAppiOSSwift-Bridging-Header.h.
      Bridging header file.
    4. Click Create to save the file in the root of your project. The file is created.
      Bridging header file content.
    5. In the new bridging header file, add the following import statement for the bridging header file: #import <Q4M/MQALogger.h>.
      Bridging header file import statement.
    6. In the Xcode Project Navigator, click Build Settings, and search for Objective-C Bridging Header.
      Build settings for Objective-C Bridging Header.
    7. Under Swift Compiler - Code Generation, set the value of Objective-C Bridging Header to the path of the bridging header. The path is relative to the root of your project. For example, if the project MQASampleApp is at /user/example/MQASampleApp, then the path is /user/example/MQASampleApp/MQASampleApp-Bridging-Header.h. If you saved your file in the root of the project, then you can use environment variable to set the path by entering ${SRCROOT}/MyProject-Bridging-Header.h.
      Bridging header path that uses environment variable.
      Relative path for bridging header path.
    8. Save and build the app to verify that the path is correct.
  8. Modify the headers by adding the MobileFirst Quality Assurance header to the precompiled ProjectName_Prefix.pch header file for your project.
    Note: In Xcode version 6.x, newly created Objective-C projects do not have a precompiler header file.
  9. From the Project Navigator, click your project and then select Info to verify the following settings in your project information:
    Bundle version
    MobileFirst Quality Assurance uses the value from this field to determine when to send a new build notification to testers. When you upload a new build to MobileFirst Quality Assurance, ensure that you increment this number.
    Tip: If you are directly editing the Info.plist file, look for the CFBundleVersion field instead.

    The string in the Bundle version field is restricted to numbers and the period (.) character. Because this restriction is an Xcode requirement, most applications follow this convention and do not require changes.

    The following examples show valid bundle version strings:
    • 1.0
    • 1.7.5
    • 2
    Bundle version strings cannot contain letters or other characters. The following examples show invalid versions:
    • 1.0a
    • 2.beta
    • Latest
    Bundle versions string
    This field contains a string representation of your version number. The string does not have the same restrictions as the Bundle version field.
    Tip: If you are directly editing the Info.plist file, look for the CFBundleShortVersionString field instead.

    For more information about version tracking, see App version numbers.

  10. Add logging calls to your code by replacing any instance of the NSLog method with one of the following MobileFirst Quality Assurance logging methods:
    • MQALog
    • MQAExtendedLog
    Both of these methods log activities to the debug console and the IBM MobileFirst Quality Assurance server. Your iOS SDK is installed.
  11. Configure MobileFirst Quality Assurance to start a new session with every time you log on by continuing with Starting an iOS session.