What is a non-fragile ABI?

前端 未结 2 1475
走了就别回头了
走了就别回头了 2020-12-29 15:34

It may seem implied that everyone knows what a \"Non Fragile ABI\" is - considering the frequency and matter-of-fact-nature to which it is referred to - within Xcod

2条回答
  •  执笔经年
    2020-12-29 15:59

    After some poking around, one of the best summaries / pieces of advice on the subject is the following…

    The non-fragile ABI allows for things like changing the ivars of a superclass without breaking already compiled subclasses (among other things). It's only supported on 64-bit on the Mac though, because of backwards compatibility concerns which didn't allow them to support it on existing 32-bit architectures.

    It goes on to say, basically.. that if Xcode, which often is configured to build for the "Active Architecture Only", aka 64-bit only.. one may run into issues when switching to a "Release" scheme, which is usually set to build for both (63bit/32bit) architectures, aka "Universal"..

    You may you want to use ARC on the Mac, I'm pretty sure you'll have to drop 32-bit support to do so. You can change the targeted architectures in the build settings for your target in Xcode.

    In my own experience, I believe that what the non-fragile ABI benefits us with is an abbreviated syntax, and patterns such as…

    //  source.h  - readonly public properties.  
    @interface SuperClassy : NSObject
    @property (readonly) NSArray *cantTouchThis;
    @end
    // source.m  set readonly properties, internally.  
    @implementation SuperClassy
    // look, no @synthesize… just use _ivarName.
     -(void) touchIt:(NSArray*)a { _cantTouchThis = a; }    
    @end
    int main(int argc, const char * argv[]) {
        SuperClassy *it = [SuperClassy new];
        // you cannot set it.cantTouchThis = @[anArray].
        [it touchIt:@[@"cats"]];  
        // but you can via a method, etc.
        NSLog(@"%@", it.cantTouchThis);
    }
    

    NSLOG ➜ ( cats )

提交回复
热议问题