Skip to content

Commit

Permalink
enable hardened runtime, update to swift 5, add swift argument parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyberbeni committed Oct 9, 2020
1 parent 44c8371 commit 67943aa
Show file tree
Hide file tree
Showing 6 changed files with 187 additions and 32 deletions.
6 changes: 3 additions & 3 deletions Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ struct Settings {
}

enum DefaultNavigationApp: Double {
case chooseFromAvailableApps = 0.0
case maps = 1.0
case googleMaps = 2.0
case waze = 3.5
case googleMaps = 2.0
case maps = 1.0
case chooseFromAvailableApps = 0.0

private static let key = "defaultNavigationApp"
private static let defaultValue: DefaultNavigationApp = .chooseFromAvailableApps
Expand Down
61 changes: 55 additions & 6 deletions SettingsGenerator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 52;
objects = {

/* Begin PBXBuildFile section */
75393D5B20B4BD95005D36DA /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75393D5A20B4BD95005D36DA /* main.swift */; };
75393D6620B4C97C005D36DA /* MultiValueParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75393D6520B4C97C005D36DA /* MultiValueParser.swift */; };
75393D6820B4C998005D36DA /* Parser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75393D6720B4C998005D36DA /* Parser.swift */; };
7568B8642530D2BC00A34E96 /* ArgumentParser in Frameworks */ = {isa = PBXBuildFile; productRef = 7568B8632530D2BC00A34E96 /* ArgumentParser */; };
75D1FA8A20B4D31C0013E90B /* Printer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D1FA8920B4D31C0013E90B /* Printer.swift */; };
75D1FA8D20B4D37A0013E90B /* PrintableObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D1FA8C20B4D37A0013E90B /* PrintableObject.swift */; };
75D1FA8F20B4D5990013E90B /* MultiValueObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D1FA8E20B4D5990013E90B /* MultiValueObject.swift */; };
Expand Down Expand Up @@ -48,6 +49,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
7568B8642530D2BC00A34E96 /* ArgumentParser in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -140,8 +142,12 @@
buildRules = (
);
dependencies = (
7568B8682530D3B600A34E96 /* PBXTargetDependency */,
);
name = SettingsGenerator;
packageProductDependencies = (
7568B8632530D2BC00A34E96 /* ArgumentParser */,
);
productName = SettingsGenerator;
productReference = 75393D5720B4BD95005D36DA /* SettingsGenerator */;
productType = "com.apple.product-type.tool";
Expand All @@ -153,7 +159,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0930;
LastUpgradeCheck = 0930;
LastUpgradeCheck = 1200;
ORGANIZATIONNAME = "Benedek Kozma";
TargetAttributes = {
75393D5620B4BD95005D36DA = {
Expand All @@ -167,8 +173,12 @@
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 75393D4E20B4BD94005D36DA;
packageReferences = (
7568B8622530D2BC00A34E96 /* XCRemoteSwiftPackageReference "swift-argument-parser" */,
);
productRefGroup = 75393D5820B4BD95005D36DA /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -197,6 +207,13 @@
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
7568B8682530D3B600A34E96 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
productRef = 7568B8672530D3B600A34E96 /* ArgumentParser */;
};
/* End PBXTargetDependency section */

/* Begin XCBuildConfiguration section */
75393D5C20B4BD95005D36DA /* Debug */ = {
isa = XCBuildConfiguration;
Expand Down Expand Up @@ -224,6 +241,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -249,7 +267,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MACOSX_DEPLOYMENT_TARGET = 10.14.4;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -284,6 +302,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -303,7 +322,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MACOSX_DEPLOYMENT_TARGET = 10.14.4;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand All @@ -314,20 +333,26 @@
75393D5F20B4BD95005D36DA /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = V63P53K235;
ENABLE_HARDENED_RUNTIME = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14.4;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
75393D6020B4BD95005D36DA /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = V63P53K235;
ENABLE_HARDENED_RUNTIME = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14.4;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -353,6 +378,30 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
7568B8622530D2BC00A34E96 /* XCRemoteSwiftPackageReference "swift-argument-parser" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/apple/swift-argument-parser";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 0.3.1;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
7568B8632530D2BC00A34E96 /* ArgumentParser */ = {
isa = XCSwiftPackageProductDependency;
package = 7568B8622530D2BC00A34E96 /* XCRemoteSwiftPackageReference "swift-argument-parser" */;
productName = ArgumentParser;
};
7568B8672530D3B600A34E96 /* ArgumentParser */ = {
isa = XCSwiftPackageProductDependency;
package = 7568B8622530D2BC00A34E96 /* XCRemoteSwiftPackageReference "swift-argument-parser" */;
productName = ArgumentParser;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 75393D4F20B4BD94005D36DA /* Project object */;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"object": {
"pins": [
{
"package": "swift-argument-parser",
"repositoryURL": "https://github.com/apple/swift-argument-parser",
"state": {
"branch": null,
"revision": "92646c0cdbaca076c8d3d0207891785b3379cbff",
"version": "0.3.1"
}
}
]
},
"version": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "75393D5620B4BD95005D36DA"
BuildableName = "SettingsGenerator"
BlueprintName = "SettingsGenerator"
ReferencedContainer = "container:SettingsGenerator.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "75393D5620B4BD95005D36DA"
BuildableName = "SettingsGenerator"
BlueprintName = "SettingsGenerator"
ReferencedContainer = "container:SettingsGenerator.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "$(SRCROOT)/Root.plist"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "$(SRCROOT)/Settings.swift"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "75393D5620B4BD95005D36DA"
BuildableName = "SettingsGenerator"
BlueprintName = "SettingsGenerator"
ReferencedContainer = "container:SettingsGenerator.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
46 changes: 24 additions & 22 deletions SettingsGenerator/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,29 @@
//

import Foundation

let argCount = CommandLine.argc

if argCount != 3 {
print("Usage: 'settingsGenerator path_to_plist path_to_output'")
exit(-1)
import ArgumentParser

struct SettingsGenerator: ParsableCommand {
@Argument(help: "Path for the settings.bundle plist", completion: .file())
var plistPath: String

@Argument(help: "Path for the output file", completion: .file())
var outputPath: String

func run() throws {
let inputUrl = URL(fileURLWithPath: plistPath)
let outputUrl = URL(fileURLWithPath: outputPath)

let dictionary = NSDictionary(contentsOfFile: inputUrl.path)
guard let preferences = dictionary?["PreferenceSpecifiers"] as? NSArray
else {
throw NSError(domain: "SettingsGenerator", code: -1, userInfo: [NSLocalizedDescriptionKey: "Invalid input path"])
}

MultiValueParser.parse(preferences)

Printer.shared.writeToFile(outputUrl)
}
}

let plistPath = CommandLine.arguments[1]
let inputUrl = URL(fileURLWithPath: plistPath)
let outputPath = CommandLine.arguments[2]
let outputUrl = URL(fileURLWithPath: outputPath)

let dictionary = NSDictionary(contentsOfFile: inputUrl.path)
let preferences = dictionary?["PreferenceSpecifiers"] as? NSArray

if preferences == nil {
print("Invalid file path")
exit(-1)
}

MultiValueParser.parse(preferences!)

Printer.shared.writeToFile(outputUrl)
SettingsGenerator.main()

0 comments on commit 67943aa

Please sign in to comment.