FitSDK on iOS with Apple Silicon M1

Hi,

There are problems when using the library libFitSdkCppiOS.a with XCode on an Apple Silicon M1. 

It is not possible to run an iOS app on the XCode simulator, if that library is included, and the following message will appear

"libFitSdkCppiOS.a(FitDecode.o), building for iOS Simulator, but linking in object file (libFitSdkCppiOS.a(FitDecode.o)) built for iOS, file 'libFitSdkCppiOS.a' for architecture arm64"

It is possible to run the app on a real iPhone, but not on the simulator.

The library libFitSdkCppiOS.a should be recompiled and restructured using the new Apple XCFramework.

An additional question. Are there any plans for a Swift FitSDK version? To use the current library developers need to use an Object C wrapper  and then call the wrapper functions in Swift. Not optimal.

Thank you.

  • The existing Objective-C SDK is nearing its end of life, or more accurately it has reached its end of life. The encode and decode classes are written in Objective-C, but all the message classes are straight out of the C++ SDK. So, it works in Objective-C projects, but it takes some extra work, as you mentioned, to get it to work with Swift.

    Coming soon, to replace this SDK, is a new Objective-C SDK. Under the hood, this SDK leverages the encoder and decoder classes from the C++ SDK but wraps them in Objective-C classes. Any reference to a C++ header file is kept in the .mm files so Swift never sees them. All of the message classes are written in Objective-C, and all of the unit tests and example code is written in Swift. There are also a few utility classes written in Swift that condense decoding a FIT file in to 4-5 lines of code. This SDK was implemented as a Swift Package, but initially it will not be published anywhere and it will need to be added to the project as a local package. There are instructions in the SDK for how to do that.

    The next release of the FIT SDK will contain both versions of the Objective-C SDK. Then in the following release we will be removing the older Objective-C SDK. The ETA for this is soon.

    If you still want to use the older SDK, the SDK includes the Xcode project file and all of the source code. So, you can try rebuilding the library and see if it runs on the M1 processor, or instead of using the library you can pull the source code directly into your project.

    Right now, there are no plans in the next year for a Swift SDK.

  • If what you are after is reading fit files from an app, I had the same issue for an app, so I published a swift package that wrap the sdk.

    https://github.com/roznet/FitFileParser

    It does not use the c++ version but the c version of the sdk for speed and compatibility with swift and is self contained so an easy standard package import.

    It also has a few example app https://github.com/roznet/fit-sdk-swift and it's used in production open source app https://github.com/roznet/connectstats 

  • If you're after decoding and encoding in Swift, you can take a look at FitDataProtocol, tho not as speedy as 's version (which I didn't use since I need to encode it as well)