Skip to content

Commit

Permalink
Merge pull request mac-cain13#376 from mac-cain13/cleanup
Browse files Browse the repository at this point in the history
Update some dependencies and fix warnings
  • Loading branch information
tomlokhorst authored Jan 12, 2018
2 parents 96728f9 + 6479311 commit c5273e4
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 38 deletions.
14 changes: 7 additions & 7 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@
"repositoryURL": "https://github.com/kylef/Commander.git",
"state": {
"branch": null,
"revision": "4c320a3507d621d27f89514eb576664becfee643",
"version": "0.6.1"
"revision": "e5b50ad7b2e91eeb828393e89b03577b16be7db9",
"version": "0.8.0"
}
},
{
"package": "Spectre",
"repositoryURL": "https://github.com/kylef/Spectre.git",
"state": {
"branch": null,
"revision": "e46b75cf03ad5e563b4b0a5068d3d6f04d77d80b",
"version": "0.7.2"
"revision": "e34d5687e1e9d865e3527dd58bc2f7464ef6d936",
"version": "0.8.0"
}
},
{
"package": "XcodeEdit",
"repositoryURL": "https://github.com/tomlokhorst/XcodeEdit",
"state": {
"branch": "release/2.0",
"revision": "f9ce2c414f69bd3d309938b75dd0c4af7a815dbe",
"version": null
"branch": null,
"revision": "6886b16eceb937056f756720c95191677a0f3543",
"version": "2.0.0"
}
}
]
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import PackageDescription
let package = Package(
name: "rswift",
dependencies: [
.package(url: "https://github.com/kylef/Commander.git", .upToNextMinor(from: "0.6.0")),
.package(url: "https://github.com/tomlokhorst/XcodeEdit", .branch("release/2.0"))
.package(url: "https://github.com/kylef/Commander.git", from: "0.8.0"),
.package(url: "https://github.com/tomlokhorst/XcodeEdit", from: "2.0.0")
],
targets: [
.target(
Expand Down
4 changes: 2 additions & 2 deletions ResourceApp/ResourceApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"$SRCROOT/../build/debug/rswift\" generate \"--import\" \"SWRevealViewController\" \"$SRCROOT\" > \"$SRCROOT/rswift.log\"";
shellScript = "\"$SRCROOT/../build/Debug/rswift\" generate \"--import\" \"SWRevealViewController\" \"$SRCROOT\" > \"$SRCROOT/rswift.log\"";
};
DEF559A61CA487D6009B8C51 /* R.swift */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -886,7 +886,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"$SRCROOT/../build/debug/rswift\" generate \"$SRCROOT/ResourceApp-tvOS\" > \"$SRCROOT/rswift-tv.log\"";
shellScript = "\"$SRCROOT/../build/Debug/rswift\" generate \"$SRCROOT/ResourceApp-tvOS\" > \"$SRCROOT/rswift-tv.log\"";
};
ED8FCF67313DC003391627B7 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
4 changes: 2 additions & 2 deletions Sources/RswiftCore/ResourceTypes/Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ struct Image: WhiteListedExtensionsResourceType {

let filename = url.lastPathComponent
let pathExtension = url.pathExtension
guard filename.characters.count > 0 && pathExtension.characters.count > 0 else {
guard filename.count > 0 && pathExtension.count > 0 else {
throw ResourceParsingError.parsingFailed("Filename and/or extension could not be parsed from URL: \(url.absoluteString)")
}

let extensions = Image.supportedExtensions.joined(separator: "|")
let regex = try! NSRegularExpression(pattern: "(~(ipad|iphone))?(@[2,3]x)?\\.(\(extensions))$", options: .caseInsensitive)
let fullFileNameRange = NSRange(location: 0, length: filename.characters.count)
let fullFileNameRange = NSRange(location: 0, length: filename.count)
let pathExtensionToUse = (pathExtension == "png") ? "" : ".\(pathExtension)"
name = regex.stringByReplacingMatches(in: filename, options: NSRegularExpression.MatchingOptions(rawValue: 0), range: fullFileNameRange, withTemplate: pathExtensionToUse)
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/RswiftCore/ResourceTypes/StringParam.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ extension FormatSpecifier : Unifiable {
// Convenience initializer, uses last character of string,
// ignoring lengt modifiers, e.g. "lld"
init?(formatString string: String) {
guard let last = string.characters.last else {
guard let last = string.last else {
return nil
}

self.init(formatChar: last)
}

init?(formatChar char: Swift.Character) {
let lcChar = Swift.String(char).lowercased().characters.first!
let lcChar = Swift.String(char).lowercased().first!
switch lcChar {
case "@":
self = .object
Expand Down Expand Up @@ -226,7 +226,7 @@ private func createFormatParts(_ formatString: String) -> [FormatPart] {
if let reference = referenceRegEx.firstSubstring(input: str) {
param = FormatPart.reference(reference)
}
else if let char = str.characters.first, let fs = FormatSpecifier(formatChar: char)
else if let char = str.first, let fs = FormatSpecifier(formatChar: char)
{
param = FormatPart.spec(fs)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/RswiftCore/Util/IgnoreFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class IgnoreFile {
if potentialPattern.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { return false }

// Check for commented line
if potentialPattern.trimmingCharacters(in: .whitespacesAndNewlines).characters.first == "#" { return false }
if potentialPattern.trimmingCharacters(in: .whitespacesAndNewlines).first == "#" { return false }

return true
}
Expand Down
12 changes: 6 additions & 6 deletions Sources/RswiftCore/Util/UtilExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ extension Sequence {

extension String {
var lowercaseFirstCharacter: String {
if self.characters.count <= 1 { return self.lowercased() }
let index = characters.index(startIndex, offsetBy: 1)
if self.count <= 1 { return self.lowercased() }
let index = self.index(startIndex, offsetBy: 1)
return self[..<index].lowercased() + self[index...]
}

var uppercaseFirstCharacter: String {
if self.characters.count <= 1 { return self.uppercased() }
let index = characters.index(startIndex, offsetBy: 1)
if self.count <= 1 { return self.uppercased() }
let index = self.index(startIndex, offsetBy: 1)
return self[..<index].uppercased() + self[index...]
}

Expand All @@ -54,7 +54,7 @@ extension String {
}

var fullRange: NSRange {
return NSRange(location: 0, length: characters.count)
return NSRange(location: 0, length: self.count)
}

var escapedStringLiteral: String {
Expand All @@ -79,6 +79,6 @@ extension String {
extension URL {
var filename: String? {
let filename = deletingPathExtension().lastPathComponent
return filename.characters.count == 0 ? nil : filename
return filename.count == 0 ? nil : filename
}
}
26 changes: 13 additions & 13 deletions Sources/rswift/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ struct EnvironmentKeys {

// Options grouped in struct for readability
struct CommanderOptions {
static let importModules = Option("import", "", description: "Add extra modules as import in the generated file, comma seperated.")
static let accessLevel = Option("accessLevel", AccessLevel.internalLevel, description: "The access level [public|internal] to use for the generated R-file.")
static let rswiftIgnore = Option("rswiftignore", ".rswiftignore", description: "Path to pattern file that describes files that should be ignored.")

static let xcodeproj = Option("xcodeproj", EnvironmentKeys.xcodeproj, flag: "p", description: "Path to the xcodeproj file.")
static let target = Option("target", EnvironmentKeys.target, flag: "t", description: "Target the R-file should be generated for.")

static let bundleIdentifier = Option("bundleIdentifier", EnvironmentKeys.bundleIdentifier, description: "Bundle identifier the R-file is be generated for.")
static let productModuleName = Option("productModuleName", EnvironmentKeys.productModuleName, description: "Product module name the R-file is generated for.")
static let buildProductsDir = Option("buildProductsDir", EnvironmentKeys.buildProductsDir, description: "Build products folder that Xcode uses during build.")
static let developerDir = Option("developerDir", EnvironmentKeys.developerDir, description: "Developer folder that Xcode uses during build.")
static let sourceRoot = Option("sourceRoot", EnvironmentKeys.sourceRoot, description: "Source root folder that Xcode uses during build.")
static let sdkRoot = Option("sdkRoot", EnvironmentKeys.sdkRoot, description: "SDK root folder that Xcode uses during build.")
static let importModules = Option("import", default: "", description: "Add extra modules as import in the generated file, comma seperated.")
static let accessLevel = Option("accessLevel", default: AccessLevel.internalLevel, description: "The access level [public|internal] to use for the generated R-file.")
static let rswiftIgnore = Option("rswiftignore", default: ".rswiftignore", description: "Path to pattern file that describes files that should be ignored.")

static let xcodeproj = Option("xcodeproj", default: EnvironmentKeys.xcodeproj, flag: "p", description: "Path to the xcodeproj file.")
static let target = Option("target", default: EnvironmentKeys.target, flag: "t", description: "Target the R-file should be generated for.")

static let bundleIdentifier = Option("bundleIdentifier", default: EnvironmentKeys.bundleIdentifier, description: "Bundle identifier the R-file is be generated for.")
static let productModuleName = Option("productModuleName", default: EnvironmentKeys.productModuleName, description: "Product module name the R-file is generated for.")
static let buildProductsDir = Option("buildProductsDir", default: EnvironmentKeys.buildProductsDir, description: "Build products folder that Xcode uses during build.")
static let developerDir = Option("developerDir", default: EnvironmentKeys.developerDir, description: "Developer folder that Xcode uses during build.")
static let sourceRoot = Option("sourceRoot", default: EnvironmentKeys.sourceRoot, description: "Source root folder that Xcode uses during build.")
static let sdkRoot = Option("sdkRoot", default: EnvironmentKeys.sdkRoot, description: "SDK root folder that Xcode uses during build.")
}


Expand Down
2 changes: 0 additions & 2 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,11 @@ lane :runalltests do
workspace: "ResourceApp.xcworkspace",
scheme: "ResourceApp",
sdk: "iphonesimulator",
destination: "name=iPhone SE",
clean: true
)
scan(
workspace: "ResourceApp.xcworkspace",
scheme: "ResourceApp-tvOS",
destination: "name=Apple TV 1080p",
clean: true
)
end
Expand Down

0 comments on commit c5273e4

Please sign in to comment.