Search code examples
swiftpixate

How to initialize Pixate Freestyle with Swift


How do I initialize Pixate Freestyle on iOS using Swift?

The documentation say to do

int main(int argc, char *argv[])
{
    @autoreleasepool {
        [PixateFreestyle initializePixateFreestyle];
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}

How do I do that with Swift?


Solution

  • In AppDelegate.swift, comment out or remove:

    //@UIApplicationMain
    

    Create a main.swift that contains:

    import Foundation
    import UIKit
    
    // Override point for customization after application launch.
    PixateFreestyle.initializePixateFreestyle()
    UIApplicationMain(C_ARGC, C_ARGV, nil, NSStringFromClass(AppDelegate))
    

    For XCode 6.3 and higher replace the UIApplicationMain line with:

    UIApplicationMain(Process.argc, Process.unsafeArgv, nil, NSStringFromClass(AppDelegate))
    

    And for Cocoapod-based installs (at least) remember to create (and configure in the target Build Settings) a bridging header with the correct import line:

    #import <PixateFreestyle/PixateFreestyle.h>