Last active
July 7, 2019 13:53
-
-
Save ricardopereira/158c9c8c3b238f885fe5f3e9abe48cab to your computer and use it in GitHub Desktop.
Generate Input and Output Filelist to use in projects with Carthage frameworks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/swift sh | |
import Foundation | |
import Path // mxcl/Path.swift ~> 0.16 | |
print("Current Directory:", Path.cwd) | |
extension Array where Element == Entry { | |
var frameworks: [Path] { | |
return directories.frameworks | |
} | |
} | |
extension Array where Element == Path { | |
var frameworks: [Path] { | |
return filter({$0.string.hasSuffix(".framework")}) | |
} | |
} | |
let carthage = Path.cwd/"Carthage/Build/iOS" | |
func filelist(_ file: Path, with prefix: String) throws { | |
var inputList: [String] = [] | |
try carthage.ls().frameworks.forEach { entry in | |
if let filename = entry.components.last { | |
inputList.append(prefix + filename) | |
} | |
} | |
if !inputList.isEmpty { | |
try inputList.sorted().joined(separator: "\n").write(to: file) | |
print(file, "created") | |
} | |
} | |
try filelist(Path.cwd/"Carthage/input.xcfilelist", | |
with: "$(SRCROOT)/Carthage/Build/iOS/") | |
try filelist(Path.cwd/"Carthage/output.xcfilelist", | |
with: "$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment