简体   繁体   中英

NS_SWIFT_NAME not working: 'swift_name' attribute has invalid identifier for parameter name

I am getting it everywhere, it's warning 'swift_name' attribute has invalid identifier for parameter name and NS_SWIFT_NAME is not propagated to swift so not working at all. I tried various names. I think maybe I have some configuration issue but where ?

- (instancetype)resizeByPadding    :(CGFloat) padding
    NS_SWIFT_NAME(resizeBy(padding :));

- (instancetype)addLeft    :(CGFloat) value
    NS_SWIFT_NAME(add(left :));

- (instancetype)addTop    :(CGFloat) value
    NS_SWIFT_NAME(add(top :));

- (instancetype)addRight    :(CGFloat) value
    NS_SWIFT_NAME(add(right :));

- (instancetype)addBottom    :(CGFloat) value
    NS_SWIFT_NAME(add(bottom :));

Cannot find any similar question maybe I am missing something obvious but error message didn't helped me.

Seems you have a custom to put some spaces before colon, which is rarely found both in Objective-C and Swift community.

And NS_SWIFT_NAME does not accept that sort of space.

Please try removing them:

- (instancetype)resizeByPadding:(CGFloat) padding
NS_SWIFT_NAME(resizeBy(padding:));

- (instancetype)addLeft:(CGFloat) value
NS_SWIFT_NAME(add(left:));

- (instancetype)addTop:(CGFloat) value
NS_SWIFT_NAME(add(top:));

- (instancetype)addRight:(CGFloat) value
NS_SWIFT_NAME(add(right:));

- (instancetype)addBottom:(CGFloat) value
NS_SWIFT_NAME(add(bottom:));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM