2

I'm trying to add the SocketRocket framework to my Swift project using pods and I haven't been able to get the import to work on the Swift side.

I added the following entry to the Podfile:

pod 'SocketRocket', '0.2.0'

And ran pod install.

Then added the bridging header with:

#import <ScoketRocket/SRWebSocket.h>

In my ViewController, Xcode doesn't find the header file:

import SRWebSocket 

fails. I really hope to get this done through pods instead of manually adding the files to the project.

Thanks.

x89a10
  • 681
  • 1
  • 8
  • 23
  • I'm not sure even I should be adding the import or not. When I add the source manually, I can add the SRWebSocketDelegate protocol to my ViewController without the import. But not if I add through pods. – x89a10 Feb 27 '15 at 21:52

2 Answers2

2

Is there a typo ?

#import <ScoketRocket/SRWebSocket.h>

ScoketRocket/SRWebSocket.h

Lucas
  • 1,135
  • 1
  • 9
  • 20
0

You have to import modules by their module name and not their header name:

import SocketRocket

If you use that in your view controller, then you wouldn't even need an import in the bridging header. Module Imports work with CocoaPods since >= 0.36 with frameworks support, which you have explicitly enable by putting the following in your Podfile:

use_frameworks!

You can still use SocketRocket with older versions of CocoaPods and without this directive from Swift, by adding the import statement to the bridging header like you already figured out. If you do that, you don't need a further import statement in your view controller. The bridging header makes imports available for the whole Swift module.

marius
  • 7,766
  • 18
  • 30