Get unresolved identifier for MMWormhole in Watch InterfaceController.swift

My Apple Watch project is in Swift. I used CocoaPods to install MMWormhole, and I created the bridge 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 bridge header, I aimed it at my iphone application and also looked at the extension.

Modification of header.h, I have this:

#import "MMWormhole.h"

In my application for viewing iPhone applications, I have the following:

import UIKit
import Foundation 

let wormhole = MMWormhole(applicationGroupIdentifier: "group.cocoShareData", optionalDirectory: "wormhole")

and no complaint.

However, in my watch interface controller, I have the following:

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 he complains about "Using an unauthorized MMWormhole identifier."

#import "MMWormholeClient.h", .

, iphone. ... .

pod 'MMWormhole', '~ > 1.2.0' podfile WatchExtension. MMWormhole WatchController

- ?

: https://www.dropbox.com/s/tsajeoopnghyl1g/MyTestCocoData.zip?dl=0

+3
1

. :

:

1) The Objective-C bridge has to set the correct path and header search path so both IOS & WatchExt can use
2) The PodFile in MMWormhole must target for both iOS & WatchExt. 
3) The code in MMWormhole npm page is not correct.  Move the instantiation of MMWormhole out and be a class Variable.

:

C

  • iPhone App Watch Ext
  • C
  • : *.h iOS, Watch Ext. *.h. .. /MMWormholeTest/MMWormholeTest/MMWormholeTest -Bridging-header.h
  • : ${PRODS_ROOT}/, IOS 7 Watch Ext

MMWormhole

  • Cocoa .
  • pod 'MMWormhole', '~ > 1.2.0 iOS Watch Ext
  • #import "MMWormhole.h" .
  • ViewController, InterfaceOController, . var wormhole: MMWormhole!
  • MMWormhole ViewDidLoad awakeWithContext WatchExt, awakeWithContext self.lable.setText - . self.label.setText(messageObject! as! String)
  • , MMWormhole .
+1

Source: https://habr.com/ru/post/1584525/