Skip to content

Commit

Permalink
Fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Nooba committed Feb 18, 2021
1 parent 05d4864 commit 1746641
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
7 changes: 4 additions & 3 deletions XCAssetPacker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
4A56D1461DE5B573000B40D8 = {
CreatedOnToolsVersion = 8.1;
DevelopmentTeam = D92MT22EX5;
LastSwiftMigration = 0900;
LastSwiftMigration = 1220;
ProvisioningStyle = Automatic;
};
4AD71E7B1EA4CCBA00016A1A = {
Expand All @@ -210,6 +210,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = 4A56D13E1DE5B573000B40D8;
Expand Down Expand Up @@ -375,7 +376,7 @@
DEVELOPMENT_TEAM = D92MT22EX5;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -385,7 +386,7 @@
DEVELOPMENT_TEAM = D92MT22EX5;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
9 changes: 4 additions & 5 deletions XCAssetPacker/CommandLine/CommandLineKit/CommandLine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public class CommandLine {
*/
public var maxFlagDescriptionWidth: Int {
if _maxFlagDescriptionWidth == 0 {
_maxFlagDescriptionWidth = _options.map { $0.flagDescription.characters.count }.sorted().first ?? 0
_maxFlagDescriptionWidth = _options.map { $0.flagDescription.count }.sorted().first ?? 0
}

return _maxFlagDescriptionWidth
Expand Down Expand Up @@ -306,8 +306,7 @@ public class CommandLine {
continue
}

let skipChars = arg.hasPrefix(longOptionPrefix) ?
longOptionPrefix.characters.count : shortOptionPrefix.characters.count
let skipChars = arg.hasPrefix(longOptionPrefix) ? longOptionPrefix.count : shortOptionPrefix.count
let flagWithArg = arg[arg.index(arg.startIndex, offsetBy: skipChars)..<arg.endIndex]

/* The argument contained nothing but ShortOptionPrefix or LongOptionPrefix */
Expand Down Expand Up @@ -338,9 +337,9 @@ public class CommandLine {
}

/* Flags that do not take any arguments can be concatenated */
let flagLength = flag.characters.count
let flagLength = flag.count
if !flagMatched && !arg.hasPrefix(longOptionPrefix) {
let flagCharactersEnumerator = flag.characters.enumerated()
let flagCharactersEnumerator = flag.enumerated()
for (i, c) in flagCharactersEnumerator {
for option in _options where option.flagMatch(String(c)) {
/* Values are allowed at the end of the concatenated flags, e.g.
Expand Down
2 changes: 1 addition & 1 deletion XCAssetPacker/CommandLine/CommandLineKit/Option.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class Option {

internal init(_ shortFlag: String?, _ longFlag: String?, _ required: Bool, _ helpMessage: String) {
if let sf = shortFlag {
assert(sf.characters.count == 1, "Short flag must be a single character")
assert(sf.count == 1, "Short flag must be a single character")
assert(Int(sf) == nil && sf.toDouble() == nil, "Short flag cannot be a numeric value")
}

Expand Down
10 changes: 5 additions & 5 deletions XCAssetPacker/CommandLine/CommandLineKit/StringExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ internal extension String {
var isNegative: Bool = false
let decimalPoint = self._localDecimalPoint()

let charactersEnumerator = self.characters.enumerated()
let charactersEnumerator = self.enumerated()
for (i, c) in charactersEnumerator {
if i == 0 && c == "-" {
isNegative = true
Expand All @@ -75,7 +75,7 @@ internal extension String {

let doubleCharacteristic = Double(Int(characteristic)!)
return (doubleCharacteristic +
Double(Int(mantissa)!) / pow(Double(10), Double(mantissa.characters.count - 1))) *
Double(Int(mantissa)!) / pow(Double(10), Double(mantissa.count - 1))) *
(isNegative ? -1 : 1)
}

Expand All @@ -92,7 +92,7 @@ internal extension String {
var numSplits = 0

var curIdx = self.startIndex
for i in self.characters.indices {
for i in self.indices {
let c = self[i]
if c == by && (maxSplits == 0 || numSplits < maxSplits) {
s.append(String(self[curIdx..<i]))
Expand All @@ -118,7 +118,7 @@ internal extension String {
*/
func padded(toWidth width: Int, with padChar: Character = " ") -> String {
var s = self
var currentLength = self.characters.count
var currentLength = self.count

while currentLength < width {
s.append(padChar)
Expand Down Expand Up @@ -146,7 +146,7 @@ internal extension String {
var currentLineWidth = 0

for word in self.split(by: splitBy) {
let wordLength = word.characters.count
let wordLength = word.count

if currentLineWidth + wordLength + 1 > width {
/* Word length is greater than line length, can't wrap */
Expand Down
2 changes: 1 addition & 1 deletion XCAssetPacker/ImageProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct ImageProperties {


static var typesForSuffixes: [(String, ImageType)] {
return ImageType.all.flatMap { (type) in
return ImageType.all.compactMap { (type) in
if let suffix = type.suffix {
return (suffix, type)
} else {
Expand Down
5 changes: 3 additions & 2 deletions XCAssetPacker/SwiftGeneration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ extension String {

self.enumerateSubstrings(in: startIndex..<endIndex, options: .byWords) { (substring, substringRange, _, stop) in
guard var substring = substring else { return }

if let firstCharacterOfWord = substring.characters.popFirst() {

if substring.count > 0 {
let firstCharacterOfWord = substring.removeFirst()
var firstLetterOfWord = String(firstCharacterOfWord)
firstLetterOfWord = isFirstLetter ? firstLetterOfWord.lowercased() : firstLetterOfWord.uppercased()
adaptedText += firstLetterOfWord + substring
Expand Down

0 comments on commit 1746641

Please sign in to comment.