CMBatchedSensorManager referenced on a iOS 15 device

We have an app that takes data from the accelerometer of the iPhone and watchOS. Some updates ago we included the high-frequency accelerometer for the watchOS with the CMBatchedSensorManager framework.

We didn't test our app on iOS 16 or 15 devices, where that framework is unavailable, because the update was just for watchOS. We refer to that class just on a shared class, and was wrapped with an #if os(watchOS) condition.

In our iPhone app, we import the CoreMotion framework but CMBatchedSensorManager is not used.

Now, when you run the app on a device with iOS 15 you find this issue: dyld[17071]:

Symbol not found: (OBJC_CLASS$_CMBatchedSensorManager) Referenced from: '/private/var/containers/Bundle/Application/C3CC754F-1674-4CBD-AD83-93229DDCF38D/Spleeft.app/Spleeft' Expected in: '/System/Library/Frameworks/CoreMotion.framework/CoreMotion'

We need a solution to keep running our app on devices with iOS 15.0

Answered by CMDdev in 798362022

Are you sure you used the #if os(watchOS) condition everywhere you use CMBatchedSensorManager? I'm pretty sure that it should've removed all references.

Do you use the shared class somewhere in your iOS code? Maybe that's part of the issue - perhaps a method of that class that you use on iOS uses the CMBatchedSensorManager.

Are you sure you used the #if os(watchOS) condition everywhere you use CMBatchedSensorManager? I'm pretty sure that it should've removed all references.

Do you use the shared class somewhere in your iOS code? Maybe that's part of the issue - perhaps a method of that class that you use on iOS uses the CMBatchedSensorManager.

Like @CMDdev says, if #if os(watchOS) is not solving the problem there must be a reference leak somewhere.

For example code is like this:

var sensRec: CMBatchedSensorManager?
  init(text: String = “Hello, world!“) {
    #if os(watchOS)
      sensRec = CMBatchedSensorManager()
    #endif
    self.text = text
  }

This will cause that error because the line

var sensRec: CMBatchedSensorManager?

creates a reference where the linker cannot resolve on iOS 15/16

But if you changed your code to look like this:

#if os(watchOS)
  var sensRec: CMBatchedSensorManager?
#endif
  init(text: String = “Hello, world!“) {
    #if os(watchOS)
      sensRec = CMBatchedSensorManager()
    #endif
    self.text = text
  }

Then you have also masked any references from the binary that may have been causing the issue.


Argun Tekant /  DTS Engineer / Core Technologies

CMBatchedSensorManager referenced on a iOS 15 device
 
 
Q