I am starting a new Cocoa Swift Project that is incorporating the PubNub SDK via CocoaPods with the following Podfile:
target 'myProject' do
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
pod 'PubNub', '~>4.0'
pod 'Alamofire', '~> 1.3'
end
target 'myProjectTests' do
end
In my auto-generated bridging header I have the import for PubNub as:
#import <PubNub/PubNub.h>
And my AppDelegate.swift file:
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
var client:PubNub?
func applicationDidFinishLaunching(aNotification: NSNotification) {
let config = PNConfiguration( publishKey: "Your_Pub_Key", subscribeKey: "Your_Sub_Key")
client = PubNub.clientWithConfiguration(config)
client?.addListener(self)
client?.subscribeToChannels(["Your_Channel"], withPresence: false)
client?.publish("Swift + PubNub!", toChannel: "demo", compressed: false, withCompletion: nil) }
func client(client: PubNub!, didReceiveMessage message: PNMessageResult!) {
println(message)
}
func applicationWillTerminate(aNotification: NSNotification) {
// Insert code here to tear down your application
}
}
The project fails to build due to compiler errors on use of undeclared type PubNub. I've checked the build settings and the Swift Compiler - Code Generation section shows it's pointed to the bridging header file of the target (auto-populated).
Using Xcode 6.4 and pods version 0.38.2