Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(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>`
// 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:
#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
@interface STFU_UIAccessibilityLoader : NSObject
@implementation STFU_UIAccessibilityLoader
static Boolean
IsAccessibilityEnabled(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(""));
if (accessibilityDomain != NULL) {
Boolean enabled = CFPreferencesGetAppBooleanValue(CFSTR("ApplicationAccessibilityEnabled"),
accessibilityDomain, NULL);
return enabled;
return false;
static BOOL
LoadAccessibilityFramework(NSString *sdkRoot)
NSString *frameworkPath = [sdkRoot stringByAppendingPathComponent:ACCESSIBILITY_PATH];
NSBundle *bundle = [NSBundle bundleWithPath:frameworkPath];
return [bundle load];
- (void)STFU_loadActualAccessibilityBundle:(NSBundle *)bundle
didLoad:(BOOL *)didLoad
if (bundle.executablePath == nil) {
// No need to actually load this bundle which only contains localized resources.
*didLoad = YES;
} else {
[self STFU_loadActualAccessibilityBundle:bundle
+ (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,
method_getTypeEncoding(swizzledMethod))) {
method_exchangeImplementations(originalMethod, swizzledMethod);
Copy link

tianyouhui commented Apr 4, 2014

Sorry, but how to make and use this file?

Copy link

alloy commented May 16, 2014

@tianyouhui Sorry about that, gists don’t deliver notifications for comments :-/ You only need to include this source file in your project, it will automatically do its work from +[STFU_UIAccessibilityLoader load].

Copy link

roywang2011 commented Jun 18, 2014

I included this file in my project,but i got a error: can't find this file.I still puzzled about how to use and make this file.

Copy link

janck001 commented Jul 11, 2014

@RoyWangChina , I met the same problem, but has been resolved, is to directly add STFU_UIAccessibilityLoader.m files to the project can be

Copy link

Royvonne commented May 31, 2015

hi~ i met this problem in xcode6.3, my app run in ios8 is perfect, but in ios7 it would crash!! can u help me? thanks~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment