Latest1.0.1
Homepagehttps://github.com/ladeiko/ViperMcFlurrySwiftFix
LicenseCUSTOM
Platformsios 9.0, requires ARC
DependenciesSwiftSelfAware
FrameworksUIKit
Authors

Purpose

Contains fix enabling using of ViperMcFlurry (https://github.com/rambler-digital
solutions/ViperMcFlurry) from Swift language ("moduleInput" problem) interacting with
modules written in Objective-C.

Installation

Cocoapods

Just add this to your Podfile

pod 'ViperMcFlurrySwiftFix'

And run:

pod install

How it works

Demo application contains two viper modules Root and Test. Router of Root module opens Test module using ViperMcFlurry methods:

import ViperMcFlurry

class RootRouter: RootRouterInput {

    weak var transitionHandler: RamblerViperModuleTransitionHandlerProtocol!

    func showTest() {
        transitionHandler.openModule!(usingFactory: TestModuleConfigurator()) { (sourceModuleTransitionHandler, destinationModuleTransitionHandler) in

            let sourceViewController = sourceModuleTransitionHandler as! UIViewController
            let destinationViewController = destinationModuleTransitionHandler as! UIViewController

            sourceViewController.present(destinationViewController, animated: true, completion: nil)

            }.thenChain { (moduleInput) -> RamblerViperModuleOutput? in
                // This code without ViperMcFlurrySwiftFix will crash, because
                // moduleInput will check only Obj-C version of property and returns nil.
                // The fix checks both Obj-C and Swift properties.
                (moduleInput as! TestModuleInput).configure()  // FIX WORKS HERE!!!
                return nil
        }
    }

}

Without fix moduleInput property will not find value inside Obj-C runtime, because Swift properties do not
land there. So, first of all value is checked in normal Obj-C property, then in Swift properties using Swift reflection.

Latest podspec

{
    "name": "ViperMcFlurrySwiftFix",
    "version": "1.0.1",
    "summary": "Fix allows using ViperMcFlurry from Swift code (see Demo application).",
    "homepage": "https://github.com/ladeiko/ViperMcFlurrySwiftFix",
    "license": {
        "type": "CUSTOM",
        "file": "LICENSE"
    },
    "authors": {
        "Siarhei Ladzeika": "[email protected]"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/ladeiko/ViperMcFlurrySwiftFix.git",
        "tag": "1.0.1"
    },
    "source_files": "Classes/**/*.{swift}",
    "frameworks": "UIKit",
    "requires_arc": true,
    "dependencies": {
        "SwiftSelfAware": []
    },
    "pushed_with_swift_version": "3.2"
}

Pin It on Pinterest

Share This