Cannot find executable for CFBun
2020-06-16 本文已影响0人
穷小子
问题描述
Xcode Console 中有 异常 Log
Cannot find executable for CFBundle 0x1091d6170 </var/containers/Bundle/Application/FD1F2321-FD82-4CE0-AB57-18DA99C37DFD/XXX.app/XXX.bundle> (not loaded)
问题排查
经分析,Console 中 异常 Log 的都是通过 CocoaPods resource_bundles 方式生成的 资源Bundle。
而在查询这些Bundle时代码调用方式如下
NSURL *bundleURL = [[NSBundle mainBundle] URLForResource:(NSString *)bundleName withExtension:@"bundle" subdirectory:nil];
bundle = [NSBundle bundleWithURL:bundleURL];
if (![bundle isLoaded]) {
[bundle load];
}
删除 [bundle isLoaded] 及 [bundle load] 后经测试不再打印异常 Log
问题分析
@property (readonly, getter=isLoaded) BOOL loaded;
Summary
The load status of a bundle.
Declaration
@property(readonly, getter=isLoaded) BOOL loaded;
Discussion
YES if the bundle’s code is currently loaded, otherwise NO.
- (BOOL)load;
Summary
Dynamically loads the bundle’s executable code into a running program, if the code has not already been loaded.
Declaration
- (BOOL)load;
Discussion
You can use this method to load the code associated with a dynamically loaded bundle, such as a plug-in or framework. Prior to OS X version 10.5, a bundle would attempt to load its code—if it had any—only once. Once loaded, you could not unload that code. In macOS 10.5 and later, you can unload a bundle’s executable code using the unload method.
You don’t need to load a bundle’s executable code to search the bundle’s resources.
This method initializes the principal class in the bundle. To add code you want executed after loading, override the initialize class method of the principal class.
Returns
YES if the method successfully loads the bundle’s code or if the code has already been loaded, otherwise NO.
由Apple 文档可知,You don’t need to load a bundle’s executable code to search the bundle’s resources.
Resources 包含以下类型
1、Nib Files Store the Objects of Your Application’s User Interface
2、String Resources Containing Localizable Text
3、Images, Sounds, and Movies Represent Pre-rendered Content
4、Property Lists and Data Files Separate Data from Code
5、iOS Supports Device-Specific Resources