Skip to content

Instantly share code, notes, and snippets.

@pepicrft
Created December 27, 2016 10:59
Show Gist options
  • Save pepicrft/a76b378af9726fec55b8f0d10db68b1e to your computer and use it in GitHub Desktop.
Save pepicrft/a76b378af9726fec55b8f0d10db68b1e to your computer and use it in GitHub Desktop.
#!/usr/bin/swift
import Foundation
print("Ensuring Swift-Package-Manager compatibility")
let fileManager = FileManager.default
let currentPath = fileManager.currentDirectoryPath
let podURL = URL(fileURLWithPath: currentPath).appendingPathComponent("${POD_NAME}/Classes")
print("Pod path: \(podURL.path)")
let sourcesURL = URL(fileURLWithPath: currentPath).appendingPathComponent("Sources")
print("Sources path: \(sourcesURL.path)")
_ = try? fileManager.removeItem(at: sourcesURL)
_ = try? fileManager.createDirectory(at: sourcesURL,
withIntermediateDirectories: true,
attributes: nil)
fileManager.enumerator(at: podURL, includingPropertiesForKeys: nil)?.forEach { element in
guard let fileURL = element as? URL else { return }
if !fileURL.path.contains(".swift") { return }
print("Symlinking: \(fileURL.path)")
let symTo = fileURL
let symFrom = sourcesURL.appendingPathComponent(symTo.lastPathComponent)
_ = try? fileManager.createSymbolicLink(at: symFrom, withDestinationURL: symTo)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment