Why does my Swift bundle get the wrong principal class?

落爺英雄遲暮 提交于 2019-12-11 12:13:00

问题


I made a bundle target, and its Info.plist file specifies that a very specific class (let's call it PrincipalClass) should be its principal class. This class was written in Swift and has the @objc attribute. The Info.plist file is correctly copied over to the bundle, and I have cleaned and rebuilt the project multiple times already.

However, when I load the bundle from my Swift framework, its principal class is a different class (let's call it NotPrincipalClass). It was not marked @objc, and in fact, it should be internal to the bundle. I checked bundle.bundleURL in the debugger, and the Info.plist file in the bundle does say that it should be PrincipalClass; but when I check bundle.infoDictionary, the NSPrincipalClass attribute reads NotPrincipalClass as a string! (The info dictionary also contains several keys that were not specified by the Info.plist file, like DTCompiler and such.)

If I entirely remove NotPrincipalClass, I get another internal class instead, which is still totally not my principal class.

I checked the build logs thoroughly and I saw no mention of NotPrincipalClass, except when it got compiled.

What could cause this? What can I do to solve it?


回答1:


Somehow, using its qualified name instead ("PlugInNamespace.PrincipalClass") solved the problem, but this has me very skeptical because I have another plugin that does not requires this.



来源:https://stackoverflow.com/questions/28228296/why-does-my-swift-bundle-get-the-wrong-principal-class

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!