0

I'm trying to implement the HopperPlugin Objective-C protocol from the Hopper SDK in a Swift class.

The compiler fails with an "Type 'MyPlugin' cannot conform to protocol 'HopperPlugin' because it has requirements that cannot be satisfied" error.

I imported all the SDK types in the bridging header. I used XCode's "Refactor/Generate Missing Function Definitions" to generate all the stubs but one is missing because the Hopper API makes use of a pointer to an incomplete type for HopperUUID as follows:

@class HopperUUID;
…
@protocol HopperPlugin <NSObject>
…
- (HopperUUID *)pluginUUID;

I'm guessing here, but it seems like this is why I am failing to meet the HopperPlugin protocol requirements. I don't create an instance of this type myself - I'm meant to call HopperUUID! HPHopperServices.uuid(String!) to get one but this method is also not defined (XCode auto-completion shows all the other HPHopperServices functions but not this one). Apple's docos suggest it might get mapped to an OpaquePointer but no function is generated with that signature either.

How do I diagnose what's going wrong? I've made use of the XCode's refactor and auto-completion to implement and identify the functions Swift knows about. Those relating to the incomplete HopperUUID type are not defined. Is there a more verbose compiler output that is being hidden from me?

What do I need to do to successfully implement this protocol in Swift?

stiabhan
  • 381
  • 1
  • 5
  • The link doesn't lead anywhere. – matt Sep 30 '18 at 04:09
  • Check the generated header of HopperPlugin.h, compare the methods (including initializers) to the original HopperPlugin.h. You may find something lacking. – OOPer Sep 30 '18 at 04:28
  • I've taken a look at all the build artefacts. No mention of HopperUUID at all (apart from the precompiled header .pch files) and nothing obvious there. I don't see a file named HopperPlugin.h anywhere in my project - the only such file on my system is in the SDK and the path to the SDK is set in the XCode project settings. – stiabhan Sep 30 '18 at 04:42
  • If you do not know how to open the generated header in SDK, you should have said so. Good luck. – OOPer Sep 30 '18 at 04:48
  • I don’t know what I don’t know - that’s why I explained what I had checked I checked all the build artefacts but have no idea how to find/open the generated header you refer to. – stiabhan Sep 30 '18 at 05:05
  • 1
    Include `@OOPer` to send notification to me. Try Cmd-click on `HopperPlugin` in your Swift code. And try adding dummy `@interface` into `...-Bridging-Header.h`, `#import ` `@interface HopperUUID: NSObject` `@end` before `#import "Hopper.h"`. – OOPer Sep 30 '18 at 08:29
  • @OOPer Providing that minimal definition for the HopperUUID class interface does get things to compile. This looks like a workaround I can adopt and I can log a request to get the Hopper SDK fixed. – stiabhan Sep 30 '18 at 21:13
  • If I can be some help of you to create a nice app, I really am happy. Hope the SDK is fixed soon. – OOPer Oct 01 '18 at 01:12

0 Answers0