 import Foundation
 
 extension NSURL {
+  var isDirectory: Bool {
+    var isDirectoryValue = ObjCBool(false)
+    NSFileManager.defaultManager().fileExistsAtPath(absoluteString, isDirectory: &isDirectoryValue)
+    return isDirectoryValue.boolValue
+  }
+
   var isSymbolicLink: Bool {
     return URLByResolvingSymlinksInPath!.absoluteString != absoluteString
   }

  /// - parameter frameworkName: The name of the framework.
  ///                            For example: "UIKit" or "XCTest".
  func isFrameworkMachOFile(frameworkNames: [String]) -> Bool {
    for name in frameworkNames {
      if lastPathComponent == "\(name).framework" {
        return true

    guard let components = pathComponents else {
      print("Couldn't generate components for some reason.")
      abort()
    }
    guard isDirectory else {
      return false
    }
    guard !isSymbolicLink else {
      return false
    }
    guard lastPathComponent == "Headers" else {
      return false
