NSBundle principalClass return value differs on Mojave and HighSierra

Originator:cetkovsky
Number:rdar://45696097 Date Originated:October 31 2018
Status:Open Resolved:
Product:macOS Product Version:10.14
Classification:SDK Reproducible:
 
An app built in Objective-C supports third-party plug-ins. The plug-in is written in Xcode 7.3.1 and is written in a mix of Objective-C and Swift 2.2.

The third-party app loads the plug-ins via calls like:
bundle = [NSBundle bundleWithPath:]
class = [bundle principalClass]

On High Sierra, the principalClass call returns the main class of the plug-in. On Mojave, it returns nil. Both on exactly the same app and plug-in binaries.

Based on my understanding of the official documentation (https://developer.apple.com/documentation/foundation/nsbundle/1409048-principalclass?language=objc), there are two ways how the principalClass is determined.
- The principal class name is specified manually in the info.plist file. As the plug-in did not have it specified here, this step should not apply.
- The principal class is the first one listed on the ld command line when linking. As the exactly same plug-in binary was used on both High Siera and Mojave, "the first one listed on the ld command line" was the same so the returned principal class should be the same on both versions.
 
Somehow, the principalClass call returned different value on High Sierra and Mojave. Personally, I do not see any reason why it should behave differently, as the documentation has not changed and the logic sounds to be dependent solely on what happened while compiling the plug-in not how the world context while running it.

Expected Results:
- Generally, the same result should be returned on both Mojave and High Sierra (either nil or a class).
- From a backward compatibility perspective, keep returning a class on Mojave.

Actual Results:
nil on Mojave, a class on High Sierra

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!