Skip to content

[SR-5107] Working FileManager Swift 3 code no longer compiles in Swift 4 #4092

Open
@swift-ci

Description

@swift-ci
Previous ID SR-5107
Radar rdar://problem/32589382
Original Reporter aaroncrespo (JIRA User)
Type Bug
Environment

Xcode 9M136h

Additional Detail from JIRA
Votes 0
Component/s Compiler, Foundation
Labels Bug, Migrator
Assignee None
Priority Medium

md5: 9656be8f98655e1c73d7eb1b8b95239e

Issue Description:

The following FileManager usage needs changing between swift 4 and swift 3.

      enum AnError: Error {
        case creating
      }
      #if swift(>=4)
        var attributes = [FileAttributeKey: Any]()
        attributes[FileAttributeKey.modificationDate] = modifiedOverride
        guard FileManager.default.createFile(atPath: path.relativePath, contents: nil, attributes: attributes) else { //create
          throw AnError.creating
        }
      #else
        var attributes = [String: Any]()
        attributes[FileAttributeKey.modificationDate.rawValue] = modifiedOverride
        guard FileManager.default.createFile(atPath: path.relativePath, contents: nil, attributes: attributes) else { //create
          throw AnError.creating
        }
      #endif

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions