Skip to content

Commit

Permalink
Merge pull request #39 from sheagcraig/testing
Browse files Browse the repository at this point in the history
Update to Swift ~4~ 5 syntax.
  • Loading branch information
sheagcraig authored Oct 5, 2019
2 parents 1298c4d + 1fc124d commit ed87afc
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 38 deletions.
42 changes: 34 additions & 8 deletions yo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -195,23 +195,23 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 1100;
ORGANIZATIONNAME = "Durham Academy";
TargetAttributes = {
841717911ABCA0CE00150A32 = {
CreatedOnToolsVersion = 6.2;
LastSwiftMigration = 0800;
LastSwiftMigration = 1020;
};
841717A11ABCA0CE00150A32 = {
CreatedOnToolsVersion = 6.2;
LastSwiftMigration = 0800;
LastSwiftMigration = 1020;
TestTargetID = 841717911ABCA0CE00150A32;
};
};
};
buildConfigurationList = 8417178D1ABCA0CE00150A32 /* Build configuration list for PBXProject "yo" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -302,18 +302,27 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -341,25 +350,35 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
};
name = Debug;
};
841717AB1ABCA0CE00150A32 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -380,40 +399,47 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
};
name = Release;
};
841717AD1ABCA0CE00150A32 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.0.2;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
);
INFOPLIST_FILE = yo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MARKETING_VERSION = 2.0.2;
PRODUCT_BUNDLE_IDENTIFIER = "com.github.sheagcraig.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
841717AE1ABCA0CE00150A32 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.0.2;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
);
INFOPLIST_FILE = yo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MARKETING_VERSION = 2.0.2;
PRODUCT_BUNDLE_IDENTIFIER = "com.github.sheagcraig.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -434,7 +460,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.sas.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/yo.app/Contents/MacOS/yo";
};
name = Debug;
Expand All @@ -452,7 +478,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.sas.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/yo.app/Contents/MacOS/yo";
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
24 changes: 10 additions & 14 deletions yo.xcodeproj/xcshareddata/xcschemes/yo.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "1100"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "841717911ABCA0CE00150A32"
BuildableName = "yo.app"
BlueprintName = "yo"
ReferencedContainer = "container:yo.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -39,17 +48,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "841717911ABCA0CE00150A32"
BuildableName = "yo.app"
BlueprintName = "yo"
ReferencedContainer = "container:yo.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -71,8 +69,6 @@
ReferencedContainer = "container:yo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
2 changes: 1 addition & 1 deletion yo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele

// If notification is activated (i.e. user clicked the action button) the app will relaunch.
// Test for that, and if so, execute the option tucked away in the userInfo dict.
if let notification = (aNotification as NSNotification).userInfo![NSApplicationLaunchUserNotificationKey] as? NSUserNotification {
if let notification = (aNotification as NSNotification).userInfo![NSApplication.launchUserNotificationUserInfoKey] as? NSUserNotification {
let task = Process()
// It's safe to just open nothing, so this is the default.
task.launchPath = "/usr/bin/open"
Expand Down
14 changes: 7 additions & 7 deletions yo/CommandLine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,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 @@ -301,7 +301,7 @@ public class CommandLine {
}

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

/* The argument contained nothing but ShortOptionPrefix or LongOptionPrefix */
Expand All @@ -310,9 +310,9 @@ public class CommandLine {
}

/* Remove attached argument from flag */
let splitFlag = flagWithArg.split(by: argumentAttacher, maxSplits: 1)
let flag = splitFlag[0]
let attachedArg: String? = splitFlag.count == 2 ? splitFlag[1] : nil
let splitFlag = flagWithArg.split(separator: argumentAttacher, maxSplits: 1)
let flag = String(splitFlag[0])
let attachedArg: String? = splitFlag.count == 2 ? String(splitFlag[1]) : nil

var flagMatched = false
for option in _options where option.flagMatch(flag) {
Expand All @@ -332,9 +332,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
4 changes: 2 additions & 2 deletions yo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.0.0</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2.0.0</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>LSUIElement</key>
Expand Down
2 changes: 1 addition & 1 deletion yo/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 yo/StringExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ 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(self[curIdx..<i])
s.append(String(self[curIdx..<i]))
curIdx = self.index(after: i)
numSplits += 1
}
}

if curIdx != self.endIndex {
s.append(self[curIdx..<self.endIndex])
s.append(String(self[curIdx..<self.endIndex]))
}

return s
Expand All @@ -85,7 +85,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 @@ -113,7 +113,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

0 comments on commit ed87afc

Please sign in to comment.