user3635384
user3635384

Reputation: 63

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"

Upvotes: 5

Views: 2900

Answers (2)

Ana Paula
Ana Paula

Reputation: 9507

Here's how I made it work on my Swift project(following Google Cast guide for iOS):

  • I've downloaded Google Cast iOS Sender SDK and I pasted it inside my project's root folder
  • I've set the Other Linker Flags in Build Settings to: -ObjC -lc++
  • I've added the following framework libraries (linked, not embedded):

    1. Accelerate.framework
    2. AudioToolbox.framework
    3. AVFoundation.framework
    4. CoreBluetooth.framework
    5. CoreGraphics.framework
    6. CoreText.framework
    7. Foundation.framework
    8. MediaAccessibility.framework
    9. MediaPlayer.framework
    10. MediaToolbox.framework
    11. QuartzCore.framework
    12. SystemConfiguration.framework
    13. UIKit.framework
  • Still under Linked framework libraries I've added GoogleCast.framework clicking on + -> Add Other... ->GoogleCast.framework

  • I've added in the Build Phases of target a new entry in the Copy Bundle Resources section. I selected Add Other GoogleCast.framework -> Resources -> GoogleCastResources.bundle

I have not added any Objective-C bridging header and it worked great!

Upvotes: 0

A.W.
A.W.

Reputation: 3021

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

Upvotes: 2

Related Questions