My Apple Watch project is in Swift. I have used CocoaPods to install MMWormhole, and I created the bridging header as described in these links:
http://bencoding.com/2015/04/15/adding-a-swift-bridge-header-manually/
How to call Objective-C code from Swift
When I created the bridging header, I target it to my iphone app, and also watch Extension.
The bridging header.h, I have this:
#import "MMWormhole.h"
In my iPhone app View Controller, I have this:
import UIKit
import Foundation
let wormhole = MMWormhole(applicationGroupIdentifier: "group.cocoShareData", optionalDirectory: "wormhole")
and there is no complain.
However, in my watch Interface Controller, I have this:
import WatchKit
import Foundation
...
override func willActivate() {
// This method is called when watch view controller is about to be visible to user
super.willActivate()
let wormhole = MMWormhole(applicationGroupIdentifier: "group.cocoShareData", optionalDirectory: "wormhole")
}
And it complains about "Use of unresolved identifier MMWormhole".
I even try to use #import "MMWormholeClient.h" but nothing can resolve this problem.
I also try when creating the bridging header, just target on the iphone App. But still... doesn't work.
I also make pod 'MMWormhole', '~> 1.2.0' in the podfile target for WatchExtension. but still not identified MMWormhole in the Watch interfaceController
Am I missing something ?
here is my project: https://www.dropbox.com/s/tsajeoopnghyl1g/MyTestCocoData.zip?dl=0
Here is my answer. After few days of struggle and help from a code mentor:
Problems are:
Here is the brief step by step:
Objective C Bridge
MMWormhole