Exclude whole category of Objective-C class

I know that it is possible to set __deprecated attribute to category.

Is it possible to exclude whole category of Objective-C class by, for example, exclude attribute?

__attribute__((unavailable)) (or UNAVAILABLE_ATTRIBUTE in Apple headers) might do what you want. There's also NS_SWIFT_UNAVAILABLE if you just want to mark things unavailable from Swift.

Did you try it?

I mark category interface in header as unavailable and still have category symbols in Swift.

Another option...

#if DEPLOYMENT_RUNTIME_SWIFT
// Swift should see nothing.
#else

@interface MyObject (CategoryName)
- (void)someCategoryMethod;
@end

#endif
1 Like
Terms of Service

Privacy Policy

Cookie Policy