I've definitely wanted a feature like this. I hesitate to mention this because it might be a bug, but you can actually you can do this now. Just add<br><br>@objc<br>@available(*, unavailable)<br><br>and it won't be callable from Swift, while still getting bridged. (I'm not sure you need @objc but it serves as light documentation anyway.) The buggy part is the fact that it doesn't get bridged with the NS_UNAVAILABLE attribute. (It doesn't make much sense to have unavailable code in non-public APIs though so it may be correct behavior.) I use it a lot when porting code over to Swift to make sure people don't use the same old methods and classes they're used to using while providing a way to point them to the newer API by adding a message to the availability attribute.<br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 12, 2016 at 8:40 AM Andrew Bennett via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">+1 I've had similar issues, I've had to provide weaker Objective-C interface because my strong swift interfaces were incompatible with Objective-C.<div><br></div><div>I've considered whether @objc(foo) implies public(objc) (in most cases), and if you'd need private(objc) if it did, but I think your proposal is more consistent/clear.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 12, 2016 at 9:51 AM, Kevin Ballard via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I could really use some feedback on this proposal. This is something that annoys me every time I write a pure-Swift API with an Obj-C wrapper (which, coincidentally, I'm doing again right at this moment). I'd really like to have some graceful way of handling this in Swift so the Obj-C compatibility API is not exposed to Swift clients, but this proposal can't move forward without community support.<br>
<span><br>
-Kevin Ballard<br>
<br>
On Tue, Dec 15, 2015, at 11:18 AM, Kevin Ballard wrote:<br>
</span><div><div>> When writing ObjC code, there's a macro NS_REFINED_FOR_SWIFT (or __attribute__((swift_private))) that mangles the name when imported into Swift. The intention here is to hide an API from normal Swift usage (but still make it callable) so that a better Swift API can be written around it.<br>
><br>
> But there's no facility for doing this in reverse. You can expose Swift APIs to ObjC, but the API has to be ObjC-compatible. Which means that if you have a non-ObjC-compatible API, you have to write a separate API to expose it to ObjC, and this separate API now shows up in the Swift API too.<br>
><br>
> I think the simplest way to fix this is to allow for a modifier public(objc) (following the syntax of private(set)). The only thing this modifier does is ensure the declaration gets added to the generated header as if it were public (or—for apps—internal). If the declaration is not marked as @objc then it would emit an error (it could imply @objc but it feels weird to me to have an access control modifier do that). If the declaration is already public (but not internal, so the same source can be used in apps and libraries) it will emit a warning.<br>
><br>
> Armed with this new modifier, I can start to write code like<br>
><br>
> class MyClass: NSObject {<br>
> func foo<T>(x: T) { ... }<br>
> }<br>
><br>
> extension MyClass {<br>
> @objc(foo) public(objc) private func __foo(x: AnyObject) { ... }<br>
> }<br>
><br>
> When used on a property that already has private(set), the public(objc) modifier will only apply to the getter (e.g. the private(set) takes precedence for the setter).<br>
><br>
> Alternatives:<br>
><br>
> * Add a new attribute @export_objc that has the same behavior.<br>
><br>
> * Change the @objc attribute to take an optional second argument, which may be the token "exported", as in @objc(foo,exported). When using the "exported" token, the selector portion is required. We could possibly support an empty selector to indicate the default, as in @objc(,exported), but that looks odd.<br>
><br>
> My preference is for public(objc) as proposed as it matches more closely with the intended behavior, which is "this API is private in Swift and public in ObjC".<br>
><br>
> -Kevin Ballard<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</div></div></blockquote></div><br></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=W77bTy6YRdHySgTK0Dy8RU-2F4RANwbXKARV3F91EwXPoDhSJ0V-2F1knGIyGwHvSiJE2MvxbqxS-2F1VF49NDVo-2F316PWI-2BgM0zh6EIhIUxjV-2Bfd0wR1o3K09gnC2R8XJWCTkQdFifp5-2FqCUB1G89Jok-2FbfjrP2ABuAGo6fQOJF-2B9B1HnWgfec4jPJe1oaKNeDJgo-2ByHeoy8jIOddnw-2F7qXnwkPioHzgbgJm1v3VOLmuoCl8-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>