3

I am trying to install rollout.io its simply it says put thus code in you ApppDelegate the problem is that it is in Objective-C. So i used a converter to try and change it to Swift but it doesn't work when i try to put the Objective-C import header into my code. Even when i try to convert it the Online converter doesn't even show the "import" part

Ive tried these all ready

Code:

import  Rollout
import rollout
import UIRollout

all of these fail.

i can get the bottom part in the swift eject but not the top"import ,Rollout/Rollout.h>" part

enter image description here

enter image description here

Leo
  • 23,601
  • 9
  • 64
  • 89

1 Answers1

6

Note:

The following will allow you to setup Rollout SDK in case your AppDelegate is in Swift.

Update:

Rollout SDK 1.1.0 has Swift interface for calling the setup, so all the following info is not relevant now.

The original answer:

1. Swift-ObjC Bridging Header

To call [Rollout setupWithDebug:] from Swift, you should have Objective-C Bridging Header set and <Rollout/Rollout.h> should be imported from it:

  1. In the build settings, check if SWIFT_OBJC_BRIDGING_HEADER is already set. If yes, go to step 4
  2. Create a C header (File -> New -> File... -> iOS -> Source -> Header File). Call it somehow, e.g. ObjC-Bridging-Header
  3. Go to the build settings and set SWIFT_OBJC_BRIDGING_HEADER to point to the file you've created (ObjC-Bridging-Header.h). A relative path is required in the setting if the file is not at the project's root - more details in this SO answer
  4. Go to the header and add the import line there:

    #import <Rollout/Rollout.h>

2. #if debug

In order to allow Rollout testing mode (for easy hot-patches testing) it's also required to translate #ifdef Debug from ObjC . This can be done by setting OTHER_SWIFT_FLAGS in build settings like this:

enter image description here

3. Call setup from AppDelegate.swift

Now you can add the following lines to application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?):

    #if DEBUG
        Rollout.setupWithKey("<rollout_key>", developmentDevice: true)
    #else
        Rollout.setupWithKey("<rollout_key>", developmentDevice: false)
    #endif
Community
  • 1
  • 1
silyevsk
  • 3,351
  • 3
  • 26
  • 27