SDK supports Swift?


#1

Can we use Swift to develop iOS app that can connect muse and get raw data?


#2

yes, if you want an example, i’m building a project that I’ve uploaded to github. the link is below.

i’m in the middle of getting started, so there’s not much right now. but it’s building and i can access the libMuse.a classes with swift. I had tried using it with OSX, but that lacks the ExternalAccessory headers.

i think this basically covers it.

here’s what I did:

  • create new project with swift.
  • make sure there’s a bridging header. if not, create one and set the bridging header variable under the target settings.
  • also in your target’s settings: you’ll have to set ENABLE_BITCODE=NO
  • make sure your folder structure matches the example’s: the libMuse.a should be at the root of your project. then drag the file into your xcode project.
  • for me, i needed to make sure the Muse.h was inside a “./Headers/Muse/” folder, along with the rest of the header files. then i dragged the Muse.h file into my project.
  • then I added #import "Headers/Muse/Muse.h to the bridging header.
  • i bundled other dependencies with the project using carthage. i’ve been running into a few bitcode problems. you may have to disable bitcode for your dependencies.
  • i also needed to add “-lc++” to OTHER_LDFLAGS under target settings
  • I added Synchronize as a carthage dependency (https://github.com/ide/synchronize) but i had to open the project in xcode and disable bitcode

problems i encountered:

  • could not compile with bitcode enabled: disabled bitcode and ensured it was disabled in my dependencies
  • from within the bridging header, the Muse.h header file couldn’t be found: fixed the location of Muse.h
  • the header’s dependencies couldn’t be resolved: the dependencies need to be in the same folder as Muse.h

#3

Hi Dcunit3d,
Have you made any progress in Bridging Swift and Objective C to use Muse lib? Thnks.


#4

If you would like, you can use my example. I managed to make it work for the most part, except disconnecting.

I am sorry for not having proper documentation.

MuseStatIos_Swift

The workaround for the disconnect function is to set a flag. For example:

var isConnected = False

When headband connects or disconnects you need to change value of a flag. It is not ideal solution, but it worked surprisingly fine.


#5

i have downed iOS sdk from muse development website, but it is a osx and i cant register,
so where can i get the newest iOS sky?