首页 > 解决方案 > `-fobjc-arc-exceptions` compiler flag does not have an effect in Xcode for iOS app

问题描述

I am trying to disable the exceptions in the compiler in Xcode 10.1 using -fobjc-arc-exceptions, but for some reason it does not take effect. My expectation is that the app won't stop running after throwing an exception. E.g.:

@try {
        [NSException raise:@"Testing" format:@"details: %@", self];
    } @catch (NSException *exception) {
        // do some stuff
    } @finally {
        // do some final stuff and continue as usual
    }

Based on http://clang.llvm.org/docs/AutomaticReferenceCounting.html#exceptions , A program may be compiled with the option -fobjc-arc-exceptions in order to enable these, or with the option -fno-objc-arc-exceptions to explicitly disable them, with the last such argument “winning”.

So I tried putting in Build Phases > Compiler Sources > all files, or Build Settings > Other C Flags, or Other Linker Flags..

My question is how to properly set this flag, and if my expectation is correct? I do understand that exceptions should not be recovered from.

标签: iosxcodeclangllvmllvm-clang

解决方案


推荐阅读