Skip to content

Commit

Permalink
Adding a Makefile and fixing Swiftlint
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle LeNeau committed Oct 30, 2018
1 parent fc8cc3f commit 4ac5291
Show file tree
Hide file tree
Showing 26 changed files with 1,600 additions and 1,619 deletions.
37 changes: 27 additions & 10 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
disabled_rules:
- trailing_whitespace
- force_cast
- function_body_length
- type_body_length
- file_length
# Allow force-casting (e.g. `x as! UICollectionViewCell`).
# We may want to re-enable and address this rule.
- force_cast
# Allow `TODO` and `FIXME` comments.
- todo
# Allow the use of `let _ = <optional>`
- unused_optional_binding
# Allow the use of parantheses when calling methods with trailing completion closures
- empty_parentheses_with_trailing_closure
# We use enum "namespaces" which leads to nesting violations
- nesting
# Re-evalature to shorten functions up
- function_body_length
# Allow declaring operators without extra whitespace, like so: `func ==(_ lhs, ...)`
- operator_whitespace

variable_name:
opt_in_rules:
# Prefer checking `isEmpty` over `count > 0`
- empty_count

file_length:
warning: 600
error: 1000
line_length: 150
trailing_comma:
mandatory_comma: true
identifier_name:
min_length:
warning: 2
error: 2
line_length:
warning: 120
warning: 2
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
language: objective-c
osx_image: xcode10
after_success:
- bash <(curl -s https://raw.githubusercontent.com/codecov/codecov-bash/04845559fe1caefe990968cc9e3851573012b756/codecov) -J 'AerialApp'
- bash <(curl -s https://raw.githubusercontent.com/codecov/codecov-bash/04845559fe1caefe990968cc9e3851573012b756/codecov) -J 'AerialApp'
before_script:
- make lint
script:
- xcodebuild -scheme 'AerialApp' -enableCodeCoverage YES clean test
- make test
28 changes: 19 additions & 9 deletions Aerial.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@
isa = PBXNativeTarget;
buildConfigurationList = FA143CE01BDA3E880041A82B /* Build configuration list for PBXNativeTarget "AerialApp" */;
buildPhases = (
FA74B8481D94DCE0004FE056 /* ShellScript */,
FA74B8481D94DCE0004FE056 /* Run Script - Swiftlint */,
FA143CD21BDA3E880041A82B /* Sources */,
FA143CD31BDA3E880041A82B /* Frameworks */,
FA143CD41BDA3E880041A82B /* Resources */,
Expand Down Expand Up @@ -391,6 +391,7 @@
isa = PBXNativeTarget;
buildConfigurationList = FACAF1AF1BD9FC6000E539DC /* Build configuration list for PBXNativeTarget "Aerial" */;
buildPhases = (
7E9B50FB2187D302002895ED /* Run Script - Swiftlint */,
FACAF1A01BD9FC6000E539DC /* Sources */,
FACAF1A11BD9FC6000E539DC /* Frameworks */,
FACAF1A21BD9FC6000E539DC /* Headers */,
Expand Down Expand Up @@ -496,18 +497,33 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
FA74B8481D94DCE0004FE056 /* ShellScript */ = {
7E9B50FB2187D302002895ED /* Run Script - Swiftlint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Run Script - Swiftlint";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "";
shellScript = "if which swiftlint >/dev/null; then\n if [ -z \"$CI\" ]; then\n make --directory=${SRCROOT} xcode-lint\n fi\nelse\n echo \"warning: SwiftLint not installed, install using `brew install swiftlint`\"\nfi";
};
FA74B8481D94DCE0004FE056 /* Run Script - Swiftlint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Run Script - Swiftlint";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n if [ -z \"$CI\" ]; then\n make --directory=${SRCROOT} xcode-lint\n fi\nelse\n echo \"warning: SwiftLint not installed, install using `brew install swiftlint`\"\nfi";
};
/* End PBXShellScriptBuildPhase section */

Expand Down Expand Up @@ -615,7 +631,6 @@
SWIFT_OBJC_BRIDGING_HEADER = "Aerial/Source/Models/Time/Aerial-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -634,7 +649,6 @@
SWIFT_COMPILATION_MODE = singlefile;
SWIFT_OBJC_BRIDGING_HEADER = "Aerial/Source/Models/Time/Aerial-Bridging-Header.h";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -655,7 +669,6 @@
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AerialApp.app/Contents/MacOS/AerialApp";
};
name = Debug;
Expand All @@ -675,7 +688,6 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.johncoates.Aerial-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AerialApp.app/Contents/MacOS/AerialApp";
};
name = Release;
Expand Down Expand Up @@ -795,7 +807,6 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Aerial/Source/Models/Time/Aerial-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
WRAPPER_EXTENSION = saver;
};
name = Debug;
Expand All @@ -813,7 +824,6 @@
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Aerial/Source/Models/Time/Aerial-Bridging-Header.h";
SWIFT_VERSION = 4.2;
WRAPPER_EXTENSION = saver;
};
name = Release;
Expand Down
25 changes: 14 additions & 11 deletions Aerial/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,39 @@ class AppDelegate: NSObject, NSApplicationDelegate {

@IBOutlet weak var window: NSWindow!
lazy var preferencesWindowController: PreferencesWindowController = PreferencesWindowController()

func applicationDidFinishLaunching(_ notification: Notification) {
let objects = objectsFromNib(loadNibNamed: "PreferencesWindow")

// We need to find the correct window in our nib
for object in objects {
if object is NSWindow {
if (object as! NSWindow).identifier!.rawValue == "preferencesWindow" {
setUp(preferencesWindow: (object as! NSWindow))
}
let object = objects.first { object in
if let window = object as? NSWindow, window.identifier?.rawValue == "preferencesWindow" {
return true
}
return false
}

if let window = object as? NSWindow {
setUp(preferencesWindow: window)
}
}

private func setUp(preferencesWindow window: NSWindow) {
window.makeKeyAndOrderFront(self)
window.styleMask = [.closable, .titled, .miniaturizable]

var frame = window.frame
frame.origin = window.frame.origin
window.setFrame(frame, display: true)
}

private func objectsFromNib(loadNibNamed nibName: String) -> [AnyObject] {
let bundle = Bundle.main
var topLevelObjects:NSArray? = NSArray()
var topLevelObjects: NSArray? = NSArray()
bundle.loadNibNamed(NSNib.Name(nibName),
owner: preferencesWindowController,
topLevelObjects: &topLevelObjects)

return topLevelObjects! as [AnyObject]
}
}
Loading

0 comments on commit 4ac5291

Please sign in to comment.