ios - Get Unresolved Identifier for MMWormhole in Watch InterfaceController.swift -


my apple watch project in swift. have used cocoapods install mmwormhole, , created bridging header described in these links:

http://bencoding.com/2015/04/15/adding-a-swift-bridge-header-manually/

how call objective-c code swift

when created bridging header, target iphone app, , watch extension.

the bridging header.h, have this:

#import "mmwormhole.h" 

in iphone app view controller, have this:

import uikit import foundation   let wormhole = mmwormhole(applicationgroupidentifier: "group.cocosharedata", optionaldirectory: "wormhole") 

and there no complain.

however, in watch interface controller, have this:

import watchkit import foundation  ...  override func willactivate() {         // method called when watch view controller visible user         super.willactivate()         let wormhole = mmwormhole(applicationgroupidentifier: "group.cocosharedata", optionaldirectory: "wormhole") } 

and complains "use of unresolved identifier mmwormhole".

i try use #import "mmwormholeclient.h" nothing can resolve problem.

i try when creating bridging header, target on iphone app. still... doesn't work.

i make pod 'mmwormhole', '~> 1.2.0' in podfile target watchextension. still not identified mmwormhole in watch interfacecontroller

am missing ?

here project: https://www.dropbox.com/s/tsajeoopnghyl1g/mytestcocodata.zip?dl=0

here answer. after few days of struggle , code mentor:

problems are:

1) objective-c bridge has set correct path , header search path both ios & watchext can use 2) podfile in mmwormhole must target both ios & watchext.  3) code in mmwormhole npm page not correct.  move instantiation of mmwormhole out , class variable. 

here brief step step:

objective c bridge

  • add app groups both iphone app & watch ext
  • add objective c
  • target on both
  • build settings: set *.h in relative path both ios & watch ext. set *.h relative path. e.g. ../mmwormholetest/mmwormholetest/mmwormholetest-bridging-header.h
  • add header search path: ${prods_root}/headers , recursive both ios 7 watch ext

mmwormhole

  • cocoa pods it.
  • set pod 'mmwormhole', '~> 1.2.0’ target both ios & watch ext in podfile
  • set #import “mmwormhole.h” in bridging header file.
  • in both viewcontroller & interfaceocontroller, set wormhole class scope variable. e.g. var wormhole:mmwormhole!
  • instantiate mmwormhole in viewdidload , awakewithcontext in watchext, set listener in awakewithcontext , , use self.lable.settext because of closure. e.g. self.label.settext(messageobject! as! string)
  • no need register receiver shown in other mmwormhole examples in stack overflow.

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -