Xcode5中ios7模拟器出现 Cannot find executable for CFBundle ... > (not loaded) 的解决办法
2014-09-16 14:59
549 查看
(If you too like to live dangerously) this will get rid of the following error message when running on the iOS Simulator: `Cannot find executable for CFBundle <CertUIFramework.axbundle>`
STFU_UIAccessibilityLoader.m
Raw
STFU_UIAccessibilityLoader.m
Raw
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 | // When the `accessibility inspector' is enabled on the iOS Simulator the private `UIAccessibility'// framework is loaded. In turn it will try to load a list of bundles amongst which is one that has// only resources, no executable. This leads to `CFBundleLoadExecutableAndReturnError' logging this// offending error message.//// This code omits the `SDK_ROOT/System/Library/AccessibilityBundles/CertUIFramework.axbundle'// bundle from ever being attempted to load.//// This code is available under the MIT license: http://opensource.org/licenses/MIT// #import <Foundation/Foundation.h>#import <objc/runtime.h>#import <dlfcn.h> #define ACCESSIBILITY_PATH @"/System/Library/PrivateFrameworks/UIAccessibility.framework"#define APP_SUPPORT_PATH @"/System/Library/PrivateFrameworks/AppSupport.framework/AppSupport"#define COPY_PREFS_NAME "CPCopySharedResourcesPreferencesDomainForDomain" typedef CFStringRef (*CopyAppSupportPrefs)(CFStringRef); @interface UIAccessibilityLoader : NSObject// STFU compiler.- (void)loadActualAccessibilityBundle:(NSBundle *)bundle didLoad:(BOOL *)didLoad loadSubbundles:(BOOL)loadSubbundles;@end @interface STFU_UIAccessibilityLoader : NSObject@end @implementation STFU_UIAccessibilityLoader static BooleanIsAccessibilityEnabled(NSString *sdkRoot){ NSString *frameworkPath = [sdkRoot stringByAppendingPathComponent:APP_SUPPORT_PATH]; void *appSupport = dlopen([frameworkPath fileSystemRepresentation], RTLD_LAZY); CopyAppSupportPrefs CopyPrefs = (CopyAppSupportPrefs)dlsym(appSupport, COPY_PREFS_NAME); if (CopyPrefs != NULL) { CFStringRef accessibilityDomain = CopyPrefs(CFSTR("com.apple.Accessibility")); if (accessibilityDomain != NULL) { Boolean enabled = CFPreferencesGetAppBooleanValue(CFSTR("ApplicationAccessibilityEnabled"), accessibilityDomain, NULL); CFRelease(accessibilityDomain); return enabled; } } return false;} static BOOLLoadAccessibilityFramework(NSString *sdkRoot){ NSString *frameworkPath = [sdkRoot stringByAppendingPathComponent:ACCESSIBILITY_PATH]; NSBundle *bundle = [NSBundle bundleWithPath:frameworkPath]; return [bundle load];} - (void)STFU_loadActualAccessibilityBundle:(NSBundle *)bundle didLoad:(BOOL *)didLoad loadSubbundles:(BOOL)loadSubbundles;{ if (bundle.executablePath == nil) { // No need to actually load this bundle which only contains localized resources. *didLoad = YES; } else { [self STFU_loadActualAccessibilityBundle:bundle didLoad:didLoad loadSubbundles:loadSubbundles]; }} + (void)load;{ char *sdkPath = getenv("IPHONE_SIMULATOR_ROOT"); if (sdkPath != NULL) { @autoreleasepool { NSString *sdkRoot = [NSString stringWithUTF8String:sdkPath]; if (IsAccessibilityEnabled(sdkRoot) && LoadAccessibilityFramework(sdkRoot)) { Class loader = object_getClass(objc_getClass("UIAccessibilityLoader")); SEL originalSel = @selector(loadActualAccessibilityBundle:didLoad:loadSubbundles:); SEL swizzledSel = @selector(STFU_loadActualAccessibilityBundle:didLoad:loadSubbundles:); Method originalMethod = class_getInstanceMethod(loader, originalSel); Method swizzledMethod = class_getInstanceMethod(self, swizzledSel); if (originalMethod != NULL && swizzledMethod != NULL) { if (class_addMethod(loader, swizzledSel, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod))) { method_exchangeImplementations(originalMethod, swizzledMethod); } } } } }} @end |
相关文章推荐
- Xcode5中ios7模拟器出现 Cannot find executable for CFBundle ... axbundle> (not loaded) 的解决办法
- Xcode5中ios7模拟器出现 Cannot find executable for CFBundle ... axbundle> (not loaded) 的解决办法
- Cannot find executable for CFBundle 解决办法
- Cannot find executable for CFBundle 0x8aa6ac0 (not loaded)IOS7
- Cannot find executable for CFBundle 解决办法
- #error#错误原因:Cannot find executable for CFBundle 0x8ad60b0 (not loaded)
- Cannot find a valid baseurl for repo: core 错误解决办法
- Cannot find executable for CFBundle XXX
- VS2013出现“cannot find one or more components .Please reinstall the application”解决办法
- Cannot find executable for CFBundle
- Cannot find executable for CFBundle
- AndroidStudo编译时出现“Error:Execution failed for task ‘:app:mergeDebugResources‘. > Some file cru'”,解决办法
- 编译Android系统AIDL模块出现couldn't find import for class错误的解决办法
- Cannot find a valid baseurl for repo: core 错误解决办法
- 关于Grails在输入命令出现Regression in verifier for <init> method call from inside of a branch的BUG解决办法
- Error: cannot find a valid baseurl for repo: rpmfusion-free 解决办法
- Cannot find executable for CFBundle
- 虚拟机中出现 Cannot find a valid peer process to connect to 问题的解决办法
- iOS simulator Cannot find executable for CFBundle
- Cannot find executable for CFBundle "CertUIFramework.axbundle"错误方法