Decoding Developer Data using Swift/Obj-C SDK

I'm trying to decode a .fit file using the Swift SDK. It's generally all working, apart from decoding Developer Data.

I can decode the Field Descriptions and the Developer Data ID messages without any problems.

However, when I attempt to retrieve the developer data form the Session or Record messages, I'm unable to retrieve the data.

I"m basing my Swift code on the CS code showing in the Fit Cookbook.

My code is:

        for record in listener.messages.getRecordMesgs() {

            for devField in record.getDeveloperFields() {

                let thisField:FITDeveloperField = devField as! FITDeveloperField //Convert 'Any' to 'FITDeveloperField'

                print(thisField.getValueFor(0)) // Works

                print(thisField.getUnits()) // No function

                print(thisField.getName()) // No function

            }

        }

Any ideas where I'm going wrong? It seems like some of the functions I'd expect aren't available in the Swift SDK.

Thanks

Stuart

  • Take a look at FITFieldDescriptionMesg which is a property of FITDeveloperField. There are properties in FITFieldDescriptionMesg for name and units. If they return values will depend on if they were encoded in the file or not. LMK how if that solves the issue.

  • Hi Ben,
    Thanks for the reply.

    I've added a call to the 'definition' property of the FITDeveloperField. However, at this point, I get an EXC_BAD_ACCESS crash.

    Code is here:

    for record in listener.messages.getRecordMesgs() {

         for devField in record.getDeveloperFields() {

              let thisField:FITDeveloperField = devField as! FITDeveloperField //Convert 'Any' to 'FITDeveloperField'

               print(thisField.getValueFor(0)) // Works

               let definition = thisField.definition // Thread 1: EXC_BAD_ACCESS (code=1, address=0x72059ba4ee0) crash

               print(thisField.getUnits()) // No function

               print(thisField.getName()) // No function

          }

     }

    I'm using the sample 'DeveloperData.fit' file that is provided as an example in the sdk - it looks like this has the FITFieldDescriptionMesg encoded in the file

    I appreciate that the Swift sdk is just a wrapper on the C++ code, so I suspect this may be something to do with the Swift -> Objective-C -> C++ bridge.

    Any ideas as to how to work around this?

    Thanks & Regards

    Stuart

  • I had a work around in mind, but it did not pan out. We are going to fix this by providing the SDK that you really want. This is really an Objective-C SDK that is usable from Swift. We plan to get rid of the Objective-C part all together. No ETA at this time, but it is being worked on. 


  • Thanks, Ben, that's great.

    Regards

    Stuart