我最终看到了Core Foundation(毕竟NSBundle是基于CFBundle的)源代码,并找出问题出在哪里。所以..
负责收集info.plist内容的功能是CFBundleGetInfoDictionary。这被称为任何时候理论上包含在plist中的信息被请求。
望着CFBundle.c的CFBundleGetInfoDictionary检查是否执行捆扎的_infoDict场被初始化,如果它不是,它初始化:
if (!bundle->_infoDict) bundle->_infoDict = _CFBundleCopyInfoDictionaryInDirectoryWithVersion(CFGetAllocator(bundle), bundle->_url, bundle->_version);
通过调用我的的CFBundle该功能我没有任何运气,所以我猜想在_CFBundleCopyInfoDictionaryInDirectoryWithVersion中肯定发生了一些错误。
看着source code,我注意到,根据捆绑包 - >_version,使用不同的路径搜索信息plist。在这种情况下,版本取决于用于设置捆绑的dir结构。确切的说,我的版本是,因为,在函数_CFBundleURLLooksLikeBundleVersion(包初始化期间使用)规定,捆绑与资源 DIR是这样的:
// check for existence of "Resources" or "Contents" or "Support Files"
// but check for the most likely one first
// version 0: old-style "Resources" bundles
// version 1: obsolete "Support Files" bundles
// version 2: modern "Contents" bundles
// version 3: none of the above (see below)
// version 4: not a bundle (for main bundle only)
因此,要完成这个故事, Info的基本URL。的plist在_CFBundleCopyInfoDictionaryInDirectoryWithVersion基于版本0
infoURLFromBase = _CFBundleInfoURLFromBase0;
被定义为初始化:
#define _CFBundleInfoURLFromBase0 CFSTR("Resources/Info.plist")
SOOOO ......我已经把我的资源的Info.plist目录和不在外面,现在它可以工作。
我想我做了所有这一趟旅行,因为这些东西可能写在文档的某处,但我找不到它:(