Skip to content

Commit

Permalink
Add UIKit import to generated file
Browse files Browse the repository at this point in the history
Add UIKit import to generated file to avoid build errors
  • Loading branch information
Noah McCann authored and Noah McCann committed Jan 21, 2015
1 parent b08ae70 commit 65f18dd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions R.swift/func.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ func writeResourceFile(code: String, toFolderURL folderURL: NSURL) {

// MARK: Code generator functions

func swiftImports() -> String {
return "import UIKit"
}

func swiftImageStructWithAssetFolders(assetFolders: [AssetFolder]) -> String {
return distinct(assetFolders.flatMap { $0.imageAssets })
.reduce("struct image {\n") {
Expand Down
5 changes: 4 additions & 1 deletion R.swift/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ let findAllStoryboardURLsInDirectory = filterDirectoryContentsRecursively(defaul

inputDirectories(NSProcessInfo.processInfo())
.each { directory in
// Imports
let imports = swiftImports()

// Storyboards
let storyboards = findAllStoryboardURLsInDirectory(url: directory)
.map { Storyboard(url: $0) }
Expand All @@ -37,6 +40,6 @@ inputDirectories(NSProcessInfo.processInfo())

// Write out the code
let code = [imageStruct, segueStruct, storyboardStructs, validateAllStoryboardsFunction]
.reduce("struct R {") { $0 + "\n" + indent(string: $1) } + "}\n"
.reduce("\(imports)\n\nstruct R {") { $0 + "\n" + indent(string: $1) } + "}\n"
writeResourceFile(code, toFolderURL: directory)
}

0 comments on commit 65f18dd

Please sign in to comment.