Non-public API _UIDeviceOrientationDidChangeNotification error for build after validation and archive upload

I have an app that has suddenly gotten a non-public API error after uploading the archive to TestFlight. The error is posted in full below, and has never occurred before.

I'm not using the _UIDeviceOrientationDidChangeNotification symbol but I do have two extensions that use UIDevice.orientationDidChangeNotification. However those extensions are not included in the target for the two watch extensions where the error occurs.

Has anyone seen this problem before or have some advice?

90338: Non-public API usage. The app references non-public symbols in Watch/watchkitappBeta.app/PlugIns/watchkitappExtensionBeta.appex/watchkitappExtensionBeta: _UIDeviceOrientationDidChangeNotification,The app references non-public symbols in Watch/watchkitappBeta.app/PlugIns/watchkitappExtensionBeta.appex/PlugIns/watchkitappWidgetExtensionBeta.appex/watchkitappWidgetExtensionBeta: _UIDeviceOrientationDidChangeNotification. If method names in your source code match the private Apple APIs listed above, altering your method names will help prevent this app from being flagged in future submissions. In addition, note that one or more of the above APIs may be located in a static library that was included with your app. If so, they must be removed. For further information, visit the Technical Support Information at http://developer.apple.com/support/technical/
Answered by BjornRuudNRK in 885270022

I figured out what caused this. I have SPM packages that are used by both the app target and the watch target. The packaged code had @available(watchOS, unavailable) annotations for the code that was not for watchOS. However that still gets compiled so the symbols are included in the target build. The correct approach is to use the #if !os(watchOS) ... #endif (or #if os() #else #endif) directive for code that must not be compiled for watchOS.

It is also possible to use a general package target in Package.swift with platform specific dependencies, where the dependencies are included with the condition: parameter.

Accepted Answer

I figured out what caused this. I have SPM packages that are used by both the app target and the watch target. The packaged code had @available(watchOS, unavailable) annotations for the code that was not for watchOS. However that still gets compiled so the symbols are included in the target build. The correct approach is to use the #if !os(watchOS) ... #endif (or #if os() #else #endif) directive for code that must not be compiled for watchOS.

It is also possible to use a general package target in Package.swift with platform specific dependencies, where the dependencies are included with the condition: parameter.

Non-public API _UIDeviceOrientationDidChangeNotification error for build after validation and archive upload
 
 
Q