Reputation: 11
I am a complete beginner when it comes to coding (except for web) but wanted to start with it. So I bought a philips hue set which I wanted to control via Swift2. I started a online Swift2 course which helped me to get started (still beginner) and so I hoped HUE will help me to learn coding Swift2 in a playful way.
But: The API provided by Philips is in Obj-C which absolutely confuses me. There should be a way to integrate it into a Swift project but as I said.. as a beginner I can't manage to do it (http://www.developers.meethue.com/documentation/apple-sdk).
After downloading the example I was able to run it on my lights which worked fine, but I am not able to understand nor change the code. I googled and tried to find an example where someone included it into Swift so that I can start playing with the lights and start using what I learned so far.
Because there is so little information out there I came here, hoping you guys could help me getting started - how would a project look like, so that I can use the obj-C parts (especially connecting to the bridge) in my swift project? Is there somewhere a demo out there I wasn't able to find? Sorry for my "unprofessional" question but it would mean a lot to me to get started with this :)
Thanks so much!
Upvotes: 0
Views: 319
Reputation: 5123
Swift and Obj-C are interchangeable, as apple says:
Objective-C and Swift files can coexist in a single project, whether the project was originally an Objective-C or Swift project. You can simply add a file of the other language directly to an existing project. This natural workflow makes creating mixed-language app and framework targets as straightforward as creating an app or framework target written in a single language. Reference
To create a header bridge file follow these steps
Once you have created your bridge file and hooked it up, you can place your Obj-C import statements in there (#import <HueSDK_iOS/HueSDK.h>
) and then use the Obj-C functions in swift.
If their docs are bad I would suggest doing a really quick intro to Obj-C, just so that you can easily translate the sample project to your new project.
Upvotes: 1