Skip to content

Commit

Permalink
Add version flag and migrate to Xcode 9.3 / Swift 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Johennes committed Apr 9, 2018
1 parent 219405b commit 8b80087
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
8 changes: 7 additions & 1 deletion SwiftGenStrings.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0920;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = com.kayak;
TargetAttributes = {
4E530E1F1D0177F2002689B0 = {
Expand Down Expand Up @@ -316,12 +316,14 @@
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;
Expand Down Expand Up @@ -371,12 +373,14 @@
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;
Expand Down Expand Up @@ -408,6 +412,7 @@
4E530E281D0177F2002689B0 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_BUNDLE_IDENTIFIER = SwiftGenStrings;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
};
Expand All @@ -416,6 +421,7 @@
4E530E291D0177F2002689B0 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_BUNDLE_IDENTIFIER = SwiftGenStrings;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
};
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>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0920"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -56,7 +55,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
7 changes: 7 additions & 0 deletions SwiftGenStrings/CommandLineArguments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class CommandLineArguments {
}

private(set) var showUsageAndExit: Bool = false
private(set) var showVersionAndExit: Bool = false
private(set) var routine: String = "NSLocalizedString"
private(set) var outputDirectory: String? // STDOUT
private(set) var filenames: [String] = []
Expand All @@ -48,6 +49,8 @@ class CommandLineArguments {
switch flag {
case .help:
self.showUsageAndExit = true
case .version:
self.showVersionAndExit = true
case .routine(let routine):
self.routine = routine
case .outputDirectory(let outputDirectory):
Expand All @@ -63,6 +66,7 @@ class CommandLineArguments {
private enum CommandLineArgument {

case help
case version
case routine(String)
case outputDirectory(String)
case filenames([String])
Expand All @@ -77,6 +81,9 @@ private enum CommandLineArgument {
case "-h", "--help":
argument = .help
arguments = []
case "-v", "--version":
argument = .version
arguments = []
case "-s":
guard arguments.count >= 2 else {
throw CommandLineArgumentError.missingRoutine
Expand Down
8 changes: 8 additions & 0 deletions SwiftGenStrings/main.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation

let version = "0.0.1"
let usage = """
SwiftGenStrings files
SwiftGenStrings [-s <routine>] [-o <outputDir>] files
Expand All @@ -8,6 +9,8 @@ SwiftGenStrings [-h|--help]
OPTIONS
-h|--help
(Optional) Print help.
-v|--version
(Optional) Print version.
-s routine
(Optional) Substitute routine for NSLocalizedString, useful when different macro is used.
-o outputDir
Expand Down Expand Up @@ -36,6 +39,11 @@ if args.showUsageAndExit {
exit(0)
}

if args.showVersionAndExit {
print(version)
exit(0)
}

let collectionErrorOutput = LocalizedStringCollectionStandardErrorOutput()
let finalStrings = LocalizedStringCollection(strings: [], errorOutput: collectionErrorOutput)

Expand Down

0 comments on commit 8b80087

Please sign in to comment.