3

Is there any preprocessor macro that tells the Objective-C compiler that the header is being included from Swift (inside a Framework)? I want to conditionally make available some methods to Objective-C, but not to Swift.

This is a follow-on to this question.

Community
  • 1
  • 1
Ricardo Sanchez-Saez
  • 9,466
  • 8
  • 53
  • 92

2 Answers2

0

Answer by @mattt:

Use the NS_SWIFT_UNAVAILABLE macro (available only on Xcode 7 and up).

Ricardo Sanchez-Saez
  • 9,466
  • 8
  • 53
  • 92
0

Here a nice explanation about some macro's in objc to work with swift.

https://academy.realm.io/posts/altconf-nikita-lutsenko-objc-swift-interoperability/

Like mentioned you have the NS_SWIFT_UNAVAILABLE but also NS_SWIFT_NAME for example which allows you to change the signature of your functions for swift.

Saren Inden
  • 3,450
  • 4
  • 32
  • 45