Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Swift 3 and recommended project settings #4

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion Log.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0710;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = delba;
TargetAttributes = {
6D7C68021C89FBAB005782C9 = {
Expand All @@ -411,9 +411,11 @@
};
6DACCA391C89F89D001B63D9 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
};
6DACCA421C89F89E001B63D9 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
};
};
};
Expand Down Expand Up @@ -722,6 +724,7 @@
PRODUCT_NAME = Log;
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 2.1;
};
Expand Down Expand Up @@ -764,6 +767,7 @@
PRODUCT_NAME = Log;
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
Expand All @@ -789,6 +793,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "io.delba.Log-tvOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TVOS_DEPLOYMENT_TARGET = 9.1;
};
name = Release;
Expand Down Expand Up @@ -836,6 +841,7 @@
PRODUCT_NAME = Log;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
};
name = Release;
};
Expand Down Expand Up @@ -866,6 +872,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "io.delba.Log-OSXTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
};
name = Release;
};
Expand All @@ -885,6 +892,7 @@
PRODUCT_BUNDLE_IDENTIFIER = io.delba.Log;
PRODUCT_NAME = Log;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -904,6 +912,8 @@
PRODUCT_BUNDLE_IDENTIFIER = io.delba.Log;
PRODUCT_NAME = Log;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -915,6 +925,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "io.delba.Log-iOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -926,6 +937,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "io.delba.Log-iOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion Log.xcodeproj/xcshareddata/xcschemes/Log OSX.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Log.xcodeproj/xcshareddata/xcschemes/Log iOS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Log.xcodeproj/xcshareddata/xcschemes/Log tvOS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Log.xcodeproj/xcshareddata/xcschemes/Log watchOS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
6 changes: 3 additions & 3 deletions Source/Benchmarker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ internal class Benchmarker {

let durations = (0..<n).map { _ in duration { block() } }

let average = self.average(durations)
let standardDeviation = self.standardDeviation(average, durations: durations)
let average = self.average(durations: durations)
let standardDeviation = self.standardDeviation(average: average, durations: durations)
let relativeStandardDeviation = standardDeviation * average * 100

return (
Expand All @@ -71,4 +71,4 @@ internal class Benchmarker {
return sum + pow(duration - average, 2)
}
}
}
}
52 changes: 26 additions & 26 deletions Source/Formatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ public class Formatter: Formatters {
private var components: [Component]

/// The date formatter.
private let dateFormatter = NSDateFormatter()
private let dateFormatter = DateFormatter()

/// The formatter logger.
internal weak var logger: Logger!

/// The formatter textual representation.
internal var description: String {
return String(format: format, arguments: components.map { (component: Component) -> CVarArgType in
return String(component).uppercaseString
return String(format: format, arguments: components.map { (component: Component) -> CVarArg in
return String(component).uppercased()
})
}

Expand Down Expand Up @@ -96,8 +96,8 @@ public class Formatter: Formatters {

- returns: A formatted string.
*/
internal func format(level level: Level, items: [Any], separator: String, terminator: String, file: String, line: Int, column: Int, function: String, date: NSDate) -> String {
let arguments = components.map { (component: Component) -> CVarArgType in
internal func format(level: Level, items: [Any], separator: String, terminator: String, file: String, line: Int, column: Int, function: String, date: Date) -> String {
let arguments = components.map { (component: Component) -> CVarArg in
switch component {
case .Date(let dateFormat):
return format(date: date, dateFormat: dateFormat)
Expand All @@ -112,7 +112,7 @@ public class Formatter: Formatters {
case .Level:
return format(level: level)
case .Message:
return items.map({ String($0) }).joinWithSeparator(separator)
return items.map({ String($0) }).joined(separator: separator)
case .Location:
return format(file: file, line: line)
case .Block(let block):
Expand All @@ -137,9 +137,9 @@ public class Formatter: Formatters {

- returns: A formatted string.
*/
func format(description description: String?, average: Double, relativeStandardDeviation: Double, file: String, line: Int, column: Int, function: String, date: NSDate) -> String {
func format(description: String?, average: Double, relativeStandardDeviation: Double, file: String, line: Int, column: Int, function: String, date: Date) -> String {

let arguments = components.map { (component: Component) -> CVarArgType in
let arguments = components.map { (component: Component) -> CVarArg in
switch component {
case .Date(let dateFormat):
return format(date: date, dateFormat: dateFormat)
Expand Down Expand Up @@ -175,11 +175,11 @@ private extension Formatter {

- returns: A formatted date.
*/
func format(date date: NSDate, dateFormat: String) -> String {
func format(date: Date, dateFormat: String) -> String {
dateFormatter.dateFormat = dateFormat
return dateFormatter.stringFromDate(date)
return dateFormatter.string(from: date)
}

/**
Formats a file path with the specified parameters.

Expand All @@ -189,7 +189,7 @@ private extension Formatter {

- returns: A formatted file path.
*/
func format(file file: String, fullPath: Bool, fileExtension: Bool) -> String {
func format(file: String, fullPath: Bool, fileExtension: Bool) -> String {
var file = file

if !fullPath { file = file.lastPathComponent }
Expand All @@ -206,11 +206,11 @@ private extension Formatter {

- returns: A formatted Location component.
*/
func format(file file: String, line: Int) -> String {
func format(file: String, line: Int) -> String {
return [
format(file: file, fullPath: false, fileExtension: true),
String(line)
].joinWithSeparator(":")
].joined(separator: ":")
}

/**
Expand All @@ -220,11 +220,11 @@ private extension Formatter {

- returns: A formatted Level component.
*/
func format(level level: Level) -> String {
func format(level: Level) -> String {
let text = level.description

if let color = logger.theme?.colors[level] {
return text.withColor(color)
return text.withColor(color: color)
}

return text
Expand All @@ -237,11 +237,11 @@ private extension Formatter {

- returns: A formatted measure description.
*/
func format(description description: String?) -> String {
func format(description: String?) -> String {
var text = "MEASURE"

if let color = logger.theme?.colors[.Debug] {
text = text.withColor(color)
text = text.withColor(color: color)
}

if let description = description {
Expand All @@ -259,7 +259,7 @@ private extension Formatter {

- returns: A formatted average time and relative standard deviation.
*/
func format(average average: Double, relativeStandardDeviation: Double) -> String {
func format(average: Double, relativeStandardDeviation: Double) -> String {
let average = format(average: average)
let relativeStandardDeviation = format(relativeStandardDeviation: relativeStandardDeviation)

Expand All @@ -273,7 +273,7 @@ private extension Formatter {

- returns: A formatted average time.
*/
func format(average average: Double) -> String {
func format(average: Double) -> String {
return String(format: "%.3f", average)
}

Expand All @@ -284,11 +284,11 @@ private extension Formatter {

- returns: A formatted list of durations.
*/
func format(durations durations: [Double]) -> String {
var format = Array(count: durations.count, repeatedValue: "%.6f").joinWithSeparator(", ")
func format(durations: [Double]) -> String {
var format = Array(repeating: "%.6f", count: durations.count).joined(separator: ", ")
format = "[\(format)]"

return String(format: format, arguments: durations.map{ $0 as CVarArgType })
return String(format: format, arguments: durations.map{ $0 as CVarArg })
}

/**
Expand All @@ -298,7 +298,7 @@ private extension Formatter {

- returns: A formatted standard deviation.
*/
func format(standardDeviation standardDeviation: Double) -> String {
func format(standardDeviation: Double) -> String {
return String(format: "%.6f", standardDeviation)
}

Expand All @@ -309,7 +309,7 @@ private extension Formatter {

- returns: A formatted relative standard deviation.
*/
func format(relativeStandardDeviation relativeStandardDeviation: Double) -> String {
func format(relativeStandardDeviation: Double) -> String {
return String(format: "%.3f%%", relativeStandardDeviation)
}
}
}