user3635384 user3635384 - 3 months ago 56
Swift Question

No such module error while importing GoogleCast framework in Swift project

I am developing an ios application using swift. Downloaded the google cast frame work from the below link mentioned.
https://developers.google.com/cast/docs/downloads
Added this frame work in the application and imported like this:
import GoogleCast
But I am getting an error saying that "No Such module Google Cast"

Answer

I got something working in Swift.
I did not need to import anything.

Did you follow instructions from https://developers.google.com/cast/docs/ios_sender

And also configure Objective-C bridging header.
https://developer.apple.com/library/ios/documentation/swift/conceptual/BuildingCocoaApps/MixandMatch.html

I put the location of file GoogleCast.h here

enter image description here

I tested this sample code:

    class ViewController: UIViewController, GCKDeviceScannerListener {

    var scanner = GCKDeviceScanner()!;


    func deviceDidComeOnline(device: GCKDevice!) {
        println("device found - \(device.friendlyName)");
    }


    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        //scanner = GCKDeviceScanner();


        println(scanner)
        scanner.addListener(self)

        scanner.startScan()
    }
}

I run this on an Iphone 5s from Xcode and it found my ChromeCast device:

device found - AW

Comments