Skip to content
This repository has been archived by the owner on Oct 15, 2021. It is now read-only.

SwiftLint integration #9

Merged
merged 15 commits into from
Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Example/.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
excluded:
- Pods/PromiseKit
included:
- ../Pod
26 changes: 22 additions & 4 deletions Example/LocationManager.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
607FACCD1AFB9204008FA782 /* Frameworks */,
607FACCE1AFB9204008FA782 /* Resources */,
A63A9D2756A4ACE49672D8FC /* [CP] Embed Pods Frameworks */,
9E7797ED21E0C48700BDC4EF /* ShellScript */,
);
buildRules = (
);
Expand Down Expand Up @@ -287,6 +288,23 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
9E7797ED21E0C48700BDC4EF /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/SwiftLint/swiftlint\"\n";
};
A63A9D2756A4ACE49672D8FC /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -494,7 +512,7 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -514,7 +532,7 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -537,7 +555,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LocationManager_Example.app/LocationManager_Example";
};
name = Debug;
Expand All @@ -557,7 +575,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LocationManager_Example.app/LocationManager_Example";
};
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>
27 changes: 0 additions & 27 deletions Example/LocationManager/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,4 @@ import UIKit
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
4 changes: 2 additions & 2 deletions Example/LocationManager/LocationObserverLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import CoreLocation
class LocationObserverLabel: LocationObserver {

let label: UILabel

init(label: UILabel) {
self.label = label
}

func didUpdate(manager: LocationManager, newLocation: CLLocation) {
label.text = "lat: \(newLocation.coordinate.latitude)\nlng: \(newLocation.coordinate.longitude)"
}
Expand Down
33 changes: 19 additions & 14 deletions Example/LocationManager/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
import UIKit
import LocationManager
import CoreLocation
import PromiseKit

class ViewController: UIViewController {

var observer: LocationObserverLabel? = nil
var observer: LocationObserverLabel?

@IBOutlet var locationRequestLabel: UILabel!
@IBOutlet var locationLabel: UILabel!
Expand All @@ -23,37 +22,40 @@ class ViewController: UIViewController {
@IBOutlet weak var minimumIntervalSlider: UISlider!
@IBOutlet weak var maximumIntervalLabel: UILabel!
@IBOutlet weak var maximumIntervalSlider: UISlider!

override func viewDidAppear(_ animated: Bool) {

super.viewDidAppear(animated)

refreshLocation(locationLabel)
didUpdateInterface(self)
}

@IBAction func refreshLocation(_ sender: AnyObject) {

locationRequestLabel.text = "...\n"

LocationManager.getCurrentLocation().done { location in
let user_lat = String(format: "%f", location.coordinate.latitude)
let user_long = String(format: "%f", location.coordinate.longitude)
self.locationRequestLabel.text = "lat: \(user_lat)\nlng: \(user_long)"
}.catch {error in
let userLat = String(format: "%f", location.coordinate.latitude)
let userLong = String(format: "%f", location.coordinate.longitude)
self.locationRequestLabel.text = "lat: \(userLat)\nlng: \(userLong)"
}.catch { _ in
self.locationRequestLabel.text = "cannot fetch location"
}

}

@IBAction func didUpdateInterface(_ sender: AnyObject) {

distanceFilterLabel.text = "Distance (\(Int(distanceFilterSlider.value))m)"
minimumIntervalLabel.text = "Minimum interval (\(Int(minimumIntervalSlider.value))s)"
maximumIntervalLabel.text = "Minimum interval (\(Int(maximumIntervalSlider.value))s) – forces call even without new location"
maximumIntervalLabel.text = """
Minimum interval (\(Int(maximumIntervalSlider.value))s) –
forces call even without new location
"""
updateValuesAndInitializeObserver()
}

@objc func updateValuesAndInitializeObserver() {

if let currentObserver = self.observer {
Expand All @@ -67,6 +69,9 @@ class ViewController: UIViewController {
let minimumTimeInterval: Double? = minimumIntervalSlider.value == 0 ? nil : Double(minimumIntervalSlider.value)
let maximumTimeInterval: Double? = maximumIntervalSlider.value == 0 ? nil : Double(maximumIntervalSlider.value)

LocationManager.add(locationObserver: observer, distanceFilter: Double(distanceFilterSlider.value), minimumTimeInterval: minimumTimeInterval, maximumTimeInterval: maximumTimeInterval)
LocationManager.add(locationObserver: observer,
distanceFilter: Double(distanceFilterSlider.value),
minimumTimeInterval: minimumTimeInterval,
maximumTimeInterval: maximumTimeInterval)
}
}
12 changes: 2 additions & 10 deletions Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,8 @@ platform :ios, '11.0'

target 'LocationManager_Example' do
pod 'LocationManager', :path => '../'
pod "PromiseKit", "~> 6.0"

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.0'
end
end
end

pod 'PromiseKit', '~> 6.7'
pod 'SwiftLint', '0.29.2'
end

target 'LocationManager_Tests' do
Expand Down
30 changes: 17 additions & 13 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
PODS:
- LocationManager (2.0.1):
- PromiseKit (~> 6.0)
- PromiseKit (6.5.2):
- PromiseKit/CorePromise (= 6.5.2)
- PromiseKit/Foundation (= 6.5.2)
- PromiseKit/UIKit (= 6.5.2)
- PromiseKit/CorePromise (6.5.2)
- PromiseKit/Foundation (6.5.2):
- PromiseKit (~> 6.7)
- PromiseKit (6.7.1):
- PromiseKit/CorePromise (= 6.7.1)
- PromiseKit/Foundation (= 6.7.1)
- PromiseKit/UIKit (= 6.7.1)
- PromiseKit/CorePromise (6.7.1)
- PromiseKit/Foundation (6.7.1):
- PromiseKit/CorePromise
- PromiseKit/UIKit (6.5.2):
- PromiseKit/UIKit (6.7.1):
- PromiseKit/CorePromise
- SwiftLint (0.29.2)

DEPENDENCIES:
- LocationManager (from `../`)
- PromiseKit (~> 6.0)
- PromiseKit (~> 6.7)
- SwiftLint (= 0.29.2)

SPEC REPOS:
https://github.com/cocoapods/specs.git:
- PromiseKit
- SwiftLint

EXTERNAL SOURCES:
LocationManager:
:path: "../"

SPEC CHECKSUMS:
LocationManager: 50f673c57e4394fc19b49646254153fb96e52b9d
PromiseKit: 27c1601bfb73405871b805bcb8cf7e55c4dad3db
LocationManager: 390c350563ba026b656160c3145e88de4c5e766d
PromiseKit: ef376fb8b4e92edfeb66bd403b983eaa07fbde0c
SwiftLint: 47df60bdea6e7e902b193b6596db8683aafd86a3

PODFILE CHECKSUM: fb0e67fd662777f3e48be2660977a3207df4a2e1
PODFILE CHECKSUM: 3d536b40dd8629fe3178cde38f10e084379d91da

COCOAPODS: 1.6.0.beta.1
COCOAPODS: 1.6.0.beta.2
23 changes: 11 additions & 12 deletions Example/Tests/Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,36 @@ import XCTest
import CoreLocation
import LocationManager


class Tests: XCTestCase, LocationObserver {

override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}

func testObservers() {
// This is an example of a functional test case.
XCTAssert(true, "Pass")

let manager = LocationManager()

manager.add(locationObserver: self)

XCTAssertEqual(manager.locationObserversCount, 1)

manager.remove(locationObserver: self)

XCTAssertEqual(manager.locationObserversCount, 0)
}

// MARK: LocationObserver delegate

func didUpdate(manager: LocationManager, newLocation: CLLocation) {

}
}
5 changes: 3 additions & 2 deletions LocationManager.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ Pod::Spec.new do |s|

s.platform = :ios, '11.0'
s.requires_arc = true

s.swift_version = '4.2'

s.source_files = 'Pod/Classes/**/*'
s.resource_bundles = {
'LocationManager' => ['Pod/Assets/*.png']
}

# s.public_header_files = 'Pod/Classes/**/*.h'
# s.frameworks = 'UIKit', 'MapKit'
s.dependency 'PromiseKit', '~> 6.0'
s.dependency 'PromiseKit', '~> 6.7'
end
Loading