iOS SDK Hue Philips with Swift

2019-04-12 20:48发布

问题:

I tried to import iOS SDK in Objective C for Hue.

I followed instructions here : https://github.com/PhilipsHue/PhilipsHueSDK-iOS-OSX

I added the HueSDK_iOS.framework to my project, I added all Lumberjack files and I created the .h with the import line.

After, I used in my code :

var phHueSdk : PHHueSDK = PHHueSDK()
var searching : PHBridgeSearching = PHBridgeSearching()

I have this errors :

Undefined symbols for architecture armv7k: "_OBJC_CLASS_$_PHHueSDK", referenced from: type metadata accessor for __ObjC.PHHueSDK in InterfaceController.o "_OBJC_CLASS_$_PHBridgeSearching", referenced from: type metadata accessor for __ObjC.PHBridgeSearching in InterfaceController.o ld: symbol(s) not found for architecture armv7k clang: error: linker command failed with exit code 1 (use -v to see invocation)

I found many solutions for this problem like add files to the compile sources for example. It doesn't work.

UPDATE :

This problem is solve when you add your SDK to Link Binary in Build Phases of your project WatchKit Extension

New problem :

ld: file is universal (4 slices) but does not contain a(n) armv7k slice: ... clang: error: linker command failed with exit code 1 (use -v to see invocation)

I work on watchOS. Maybe the SDK doesn't support watchOS

回答1:

Right, it's named HueSDK_iOS.framework for a reason: iOS and watchOS are two different operating systems, with two different architectures.

Instead, either have your watch app talk to your phone app (recommended), or ditch the SDK completely and have your watch app send http/json to read and write the bridge JSON directly, using NSURLSession and NSJSONSerialization.