[swift-evolution] Proposal Idea : Library (third party) Importable Checking

davesweeris at mac.com davesweeris at mac.com
Sat Jan 16 13:46:59 CST 2016


I would suggest extending the existing @available syntax rather than using #imported. Either way, though, I like it.

> On Jan 14, 2016, at 09:22, Jo Albright via swift-evolution <swift-evolution at swift.org> wrote:
> 
> This is a thought from a current problem I am running into (and have ran into in the past).
> 
> If you want to write any code using a library, you must have that library imported into the file. Totally cool with this for most cases.
> 
> Situation :
> 
> Building a third party library that can be used by others to simplify working with server APIs. I want to give the developer an option to use another third party library within mine. However, I don’t want my library to depend on the other library.
> 
> Possible Solution :
> 
> Add a system that does two things. 1) Checks for a library and if found imports it into file. 2) Checks if library is imported and allows source kit to parse conditional scope.
> 
> @importable ThirdPartyLibrary // would check if library is added to project and import it
> 
> if #imported(ThirdPartyLibrary) {
>     
>     // would check if library is imported before source kit parses scope
>     
>     // if library is not imported
>     // scope would remain unparsed
>     // scope could be removed as if it were a comment
>     
> }
> 
> Thanks.
> 
> Designer . Developer .  Nerd 
> Jo Albright
> 
> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160116/89290530/attachment.html>


More information about the swift-evolution mailing list