Uploaded image for project: 'Swift'
  1. Swift
  2. SR-138

Foundation objects are not bridged on Linux as they are on OS X.



    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Compiler, Foundation
    • Labels:
    • Environment:

      OS X 10.11.1, Ubuntu 15.10


      Foundation in this build does include NSString but there's lots a caveats associated with it. It's not bridged to String as it is on OS X yet and I suspect (but haven't verified yet,) that most other Foundation objects that are bridged on OS X are not yet bridged on Linux. So casting as in the example below will fail:


      3> let foo: NSString = "foo"
       foo: Foundation.NSString = \{
       Foundation.NSObject = \{}
       _cfinfo =
      \{ info = 1920 pad = 0 }
      _storage = "foo"
       4> let bar = foo as String
       repl.swift:4:11: error: cannot convert value of type 'NSString' to type 'String' in coercion
       let bar = foo as String

      While on OS X, it will do as expected:

      3> let foo:NSString = "foo"
       foo: NSString = "foo"
       4> let bar = foo as String
       bar: String = "foo"

      In order for the Linux version of Swift-repl to recognize Foundation, it needs to be invoked as follows:

      %: swift -lFoundation <rest of the parameters>

      This tells Swift that you're using Foundation and to link (-l) with the Foundation shared library. However, this is not needed on OS X.

      Feel free to contact me if you have any questions,


          Issue Links



              • Assignee:
                millenomi Lily Vulcano
                babt Bill Abt
              • Votes:
                6 Vote for this issue
                14 Start watching this issue


                • Created: