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

Allow custom env variables in Package.swift

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Package Manager
    • Labels:
      None
    • Environment:

      OS X 10.11

      Description

      Currently if you try something like this in your Package.swift

      if let _ = String.fromCString(getenv("TEST")) {
          let package = Package(name: "getenv_was_true")
      } else {
          let package = Package(name: "getenv_was_false")
      }
      

      it uses the else path whether TEST is set or not which I assume is due to the explicit environment parameter here:
      https://github.com/apple/swift-package-manager/blob/64f1b2f5bd30d1dabb59a63181243becdd8797bb/Sources/dep/Manifest.swift#L158

      I wrote a sample project for the issue:
      https://github.com/Memorion/getenvdemo

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            Memorion Bastian Rinsche
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: