From 78eb55ecebe8f31cea98d91884e185f44f7d0dd4 Mon Sep 17 00:00:00 2001 From: Mihaela MJ Date: Mon, 20 May 2019 18:30:33 +0200 Subject: [PATCH 1/4] converting to swift 4.2 --- SampleCodeStalker.xcodeproj/project.pbxproj | 26 ++++++++++-- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++ .../DocumentListViewController.swift | 2 +- SampleCodeStalker/DocumentTableCellView.swift | 14 +++---- SampleCodeStalker/DownloadButton.swift | 42 +++++++++---------- SampleCodeStalker/MainWindow.swift | 2 +- .../SharedCode/CoreDataErrors.swift | 6 +-- .../NSManagedObjectContext+Observers.swift | 2 +- SampleCodeStalker/TableViewCellFactory.swift | 7 +++- 9 files changed, 70 insertions(+), 39 deletions(-) create mode 100644 SampleCodeStalker.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/SampleCodeStalker.xcodeproj/project.pbxproj b/SampleCodeStalker.xcodeproj/project.pbxproj index 806ee86..2ff16f8 100644 --- a/SampleCodeStalker.xcodeproj/project.pbxproj +++ b/SampleCodeStalker.xcodeproj/project.pbxproj @@ -241,12 +241,12 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 1010; ORGANIZATIONNAME = "Thomas Krajacic"; TargetAttributes = { 44C344841C5362CB0068AD9D = { CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 0800; + LastSwiftMigration = 1010; }; }; }; @@ -360,14 +360,22 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 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; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -406,14 +414,22 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 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; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -446,7 +462,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = at.krajacic.SampleCodeStalker; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -459,7 +476,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = at.krajacic.SampleCodeStalker; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/SampleCodeStalker.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/SampleCodeStalker.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/SampleCodeStalker.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/SampleCodeStalker/DocumentListViewController.swift b/SampleCodeStalker/DocumentListViewController.swift index fcdedec..940977a 100644 --- a/SampleCodeStalker/DocumentListViewController.swift +++ b/SampleCodeStalker/DocumentListViewController.swift @@ -80,7 +80,7 @@ extension DocumentListViewController: NSTableViewDelegate { // MARK: - NSSearchFieldDelegate extension DocumentListViewController: NSSearchFieldDelegate { - override func controlTextDidChange(_ obj: Notification) { + func controlTextDidChange(_ obj: Notification) { guard let textField = obj.object as? NSTextField else { return } dataSource.filterWithString(textField.stringValue.lowercased()) } diff --git a/SampleCodeStalker/DocumentTableCellView.swift b/SampleCodeStalker/DocumentTableCellView.swift index 91d7674..dc7238c 100644 --- a/SampleCodeStalker/DocumentTableCellView.swift +++ b/SampleCodeStalker/DocumentTableCellView.swift @@ -62,26 +62,26 @@ class DocumentTableCellView: NSTableCellView { dateTextField.stringValue = DocumentTableCellView.dateFormatter.string(from: document.date as Date) if let topicName = document.topic?.name , topicName != "" { - tagStackView.setVisibilityPriority(NSStackViewVisibilityPriorityMustHold, for: topicTextField) + tagStackView.setVisibilityPriority(NSStackView.VisibilityPriority.mustHold, for: topicTextField) topicTextField.stringValue = topicName } else { - tagStackView.setVisibilityPriority(NSStackViewVisibilityPriorityNotVisible, for: topicTextField) + tagStackView.setVisibilityPriority(NSStackView.VisibilityPriority.notVisible, for: topicTextField) topicTextField.stringValue = "" } if let subTopicName = document.subTopic?.name , subTopicName != "" { - tagStackView.setVisibilityPriority(NSStackViewVisibilityPriorityMustHold, for: subTopicTextField) + tagStackView.setVisibilityPriority(NSStackView.VisibilityPriority.mustHold, for: subTopicTextField) subTopicTextField.stringValue = subTopicName } else { - tagStackView.setVisibilityPriority(NSStackViewVisibilityPriorityNotVisible, for: subTopicTextField) + tagStackView.setVisibilityPriority(NSStackView.VisibilityPriority.notVisible, for: subTopicTextField) subTopicTextField.stringValue = "" } if let frameworkName = document.framework?.name , frameworkName != "" { - tagStackView.setVisibilityPriority(NSStackViewVisibilityPriorityMustHold, for: frameworkTextField) + tagStackView.setVisibilityPriority(NSStackView.VisibilityPriority.mustHold, for: frameworkTextField) frameworkTextField.stringValue = frameworkName } else { - tagStackView.setVisibilityPriority(NSStackViewVisibilityPriorityNotVisible, for: frameworkTextField) + tagStackView.setVisibilityPriority(NSStackView.VisibilityPriority.notVisible, for: frameworkTextField) frameworkTextField.stringValue = "" } @@ -92,7 +92,7 @@ class DocumentTableCellView: NSTableCellView { @IBAction func downloadButtonPressed(_ sender: DownloadButton) { guard let document = document else { return } - NSWorkspace.shared().open(document.url as URL) + NSWorkspace.shared.open(document.url as URL) } } diff --git a/SampleCodeStalker/DownloadButton.swift b/SampleCodeStalker/DownloadButton.swift index b9e7d02..52a7b69 100644 --- a/SampleCodeStalker/DownloadButton.swift +++ b/SampleCodeStalker/DownloadButton.swift @@ -43,26 +43,26 @@ class DownloadButton: NSButton { bezierPath.close() bezierPath.move(to: NSPoint(x: bounds.minX + 0.97368 * bounds.width, y: bounds.minY + 0.50000 * bounds.height)) bezierPath.curve(to: NSPoint(x: bounds.minX + 0.50000 * bounds.width, y: bounds.minY + 0.97368 * bounds.height), - controlPoint1: NSPoint(x: bounds.minX + 0.97368 * bounds.width, y: bounds.minY + 0.76161 * bounds.height), - controlPoint2: NSPoint(x: bounds.minX + 0.76161 * bounds.width, y: bounds.minY + 0.97368 * bounds.height)) + controlPoint1: NSPoint(x: bounds.minX + 0.97368 * bounds.width, y: bounds.minY + 0.76161 * bounds.height), + controlPoint2: NSPoint(x: bounds.minX + 0.76161 * bounds.width, y: bounds.minY + 0.97368 * bounds.height)) bezierPath.curve(to: NSPoint(x: bounds.minX + 0.02632 * bounds.width, y: bounds.minY + 0.50000 * bounds.height), - controlPoint1: NSPoint(x: bounds.minX + 0.23839 * bounds.width, y: bounds.minY + 0.97368 * bounds.height), - controlPoint2: NSPoint(x: bounds.minX + 0.02632 * bounds.width, y: bounds.minY + 0.76161 * bounds.height)) + controlPoint1: NSPoint(x: bounds.minX + 0.23839 * bounds.width, y: bounds.minY + 0.97368 * bounds.height), + controlPoint2: NSPoint(x: bounds.minX + 0.02632 * bounds.width, y: bounds.minY + 0.76161 * bounds.height)) bezierPath.curve(to: NSPoint(x: bounds.minX + 0.21382 * bounds.width, y: bounds.minY + 0.12250 * bounds.height), - controlPoint1: NSPoint(x: bounds.minX + 0.02632 * bounds.width, y: bounds.minY + 0.34591 * bounds.height), - controlPoint2: NSPoint(x: bounds.minX + 0.09989 * bounds.width, y: bounds.minY + 0.20901 * bounds.height)) + controlPoint1: NSPoint(x: bounds.minX + 0.02632 * bounds.width, y: bounds.minY + 0.34591 * bounds.height), + controlPoint2: NSPoint(x: bounds.minX + 0.09989 * bounds.width, y: bounds.minY + 0.20901 * bounds.height)) bezierPath.curve(to: NSPoint(x: bounds.minX + 0.50000 * bounds.width, y: bounds.minY + 0.02632 * bounds.height), - controlPoint1: NSPoint(x: bounds.minX + 0.29333 * bounds.width, y: bounds.minY + 0.06214 * bounds.height), - controlPoint2: NSPoint(x: bounds.minX + 0.39248 * bounds.width, y: bounds.minY + 0.02632 * bounds.height)) + controlPoint1: NSPoint(x: bounds.minX + 0.29333 * bounds.width, y: bounds.minY + 0.06214 * bounds.height), + controlPoint2: NSPoint(x: bounds.minX + 0.39248 * bounds.width, y: bounds.minY + 0.02632 * bounds.height)) bezierPath.curve(to: NSPoint(x: bounds.minX + 0.97368 * bounds.width, y: bounds.minY + 0.50000 * bounds.height), - controlPoint1: NSPoint(x: bounds.minX + 0.76161 * bounds.width, y: bounds.minY + 0.02632 * bounds.height), - controlPoint2: NSPoint(x: bounds.minX + 0.97368 * bounds.width, y: bounds.minY + 0.23839 * bounds.height)) + controlPoint1: NSPoint(x: bounds.minX + 0.76161 * bounds.width, y: bounds.minY + 0.02632 * bounds.height), + controlPoint2: NSPoint(x: bounds.minX + 0.97368 * bounds.width, y: bounds.minY + 0.23839 * bounds.height)) bezierPath.close() shapeLayer.path = bezierPath.cgPath() } } - fileprivate var trackingTag: NSTrackingRectTag? + fileprivate var trackingTag: NSView.TrackingRectTag? override var frame: NSRect { get { return super.frame } @@ -137,9 +137,9 @@ class DownloadButton: NSButton { CATransaction.setAnimationDuration(kAnimationDuration) switch (isMousedOver, isActive) { - case (true, true): shapeLayer.fillColor = Colors.Active - case (true, false): shapeLayer.fillColor = Colors.Tint - default: shapeLayer.fillColor = Colors.DarkTint + case (true, true): shapeLayer.fillColor = Colors.Active + case (true, false): shapeLayer.fillColor = Colors.Tint + default: shapeLayer.fillColor = Colors.DarkTint } rootLayer.opacity = isEnabled ? kEnabledOpacity: kDisabledOpacity @@ -186,7 +186,7 @@ class DownloadButton: NSButton { // MARK: - extension NSBezierPath extension NSBezierPath { - + func cgPath() -> CGPath { let path = CGMutablePath() @@ -195,14 +195,14 @@ extension NSBezierPath { for index in 0.. NSError { @@ -63,7 +63,7 @@ extension NSManagedObject { NSLocalizedDescriptionKey as NSObject: localizedDescription as AnyObject ] let domain = Bundle(for: type(of: self)).bundleIdentifier ?? "undefined" - return NSError(domain: domain, code: NSManagedObjectValidationError, userInfo: userInfo) + return NSError(domain: domain, code: NSManagedObjectValidationError, userInfo: userInfo as! [String : Any]) } func multipleValidationErrorWithDescriptions(_ localizedDescriptions: [String]) -> NSError { @@ -71,6 +71,6 @@ extension NSManagedObject { NSDetailedErrorsKey as NSObject: localizedDescriptions.map(validationErrorWithDescription) as AnyObject ] let domain = Bundle(for: type(of: self)).bundleIdentifier ?? "undefined" - return NSError(domain: domain, code: NSValidationMultipleErrorsError, userInfo: userInfo) + return NSError(domain: domain, code: NSValidationMultipleErrorsError, userInfo: userInfo as! [String : Any]) } } diff --git a/SampleCodeStalker/SharedCode/NSManagedObjectContext+Observers.swift b/SampleCodeStalker/SharedCode/NSManagedObjectContext+Observers.swift index d949d29..bdd68b4 100644 --- a/SampleCodeStalker/SharedCode/NSManagedObjectContext+Observers.swift +++ b/SampleCodeStalker/SharedCode/NSManagedObjectContext+Observers.swift @@ -43,7 +43,7 @@ public struct ContextDidSaveNotification { guard let set = (notification as NSNotification).userInfo?[key] as? NSSet else { return AnyIterator { nil } } - let innerGenerator = set.makeIterator() + var innerGenerator = set.makeIterator() return AnyIterator { return innerGenerator.next() as? ManagedObject } } diff --git a/SampleCodeStalker/TableViewCellFactory.swift b/SampleCodeStalker/TableViewCellFactory.swift index d4adcd6..fd4fdf0 100644 --- a/SampleCodeStalker/TableViewCellFactory.swift +++ b/SampleCodeStalker/TableViewCellFactory.swift @@ -24,7 +24,7 @@ class TableViewCellFactory Cell { - let cell = tableView.make(withIdentifier: item.cellReuseIdentifier, owner: self) as! Cell + let cell = tableView.makeView(withIdentifier: convertToNSUserInterfaceItemIdentifier(item.cellReuseIdentifier), owner: self) as! Cell cellConfigurator(cell, item) return cell } @@ -34,3 +34,8 @@ class TableViewCellFactory NSUserInterfaceItemIdentifier { + return NSUserInterfaceItemIdentifier(rawValue: input) +} From 379ff8c6c9f656404abb28cdb300a5ae231111df Mon Sep 17 00:00:00 2001 From: Mihaela MJ Date: Mon, 20 May 2019 18:46:38 +0200 Subject: [PATCH 2/4] converting to swift 4.2 --- SampleCodeStalker.xcodeproj/project.pbxproj | 2 ++ SampleCodeStalker/DocumentParser.swift | 7 ++++++- SampleCodeStalker/SharedCode/CoreDataErrors.swift | 6 +++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/SampleCodeStalker.xcodeproj/project.pbxproj b/SampleCodeStalker.xcodeproj/project.pbxproj index 2ff16f8..ee659b7 100644 --- a/SampleCodeStalker.xcodeproj/project.pbxproj +++ b/SampleCodeStalker.xcodeproj/project.pbxproj @@ -403,6 +403,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -450,6 +451,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/SampleCodeStalker/DocumentParser.swift b/SampleCodeStalker/DocumentParser.swift index bf8ae52..006c670 100644 --- a/SampleCodeStalker/DocumentParser.swift +++ b/SampleCodeStalker/DocumentParser.swift @@ -140,7 +140,12 @@ struct DocumentParser { , type == Int(sampleCodeType) else { return } - let cleanedURLString = urlString.hasPrefix("../") ? urlString.substring(from: urlString.characters.index(urlString.startIndex, offsetBy: 3)): urlString + var cleanedURLString = urlString + if urlString.hasPrefix("../") { + let startIndex = urlString.index(urlString.startIndex, offsetBy: 3) + cleanedURLString = String(urlString[startIndex ..< urlString.endIndex]) + } + let url = URL(string: AppleDocumentsAPI.rootURLString + "prerelease/content/" + cleanedURLString)! CDDocument.updateOrInsertIntoContext(self.moc, diff --git a/SampleCodeStalker/SharedCode/CoreDataErrors.swift b/SampleCodeStalker/SharedCode/CoreDataErrors.swift index f3e9cc2..fd9c419 100644 --- a/SampleCodeStalker/SharedCode/CoreDataErrors.swift +++ b/SampleCodeStalker/SharedCode/CoreDataErrors.swift @@ -54,7 +54,7 @@ extension NSManagedObject { NSLocalizedDescriptionKey as NSObject: localizedDescription as AnyObject ] let domain = Bundle(for: type(of: self)).bundleIdentifier ?? "undefined" - return NSError(domain: domain, code: NSManagedObjectValidationError, userInfo: userInfo as! [String : Any]) + return NSError(domain: domain, code: NSManagedObjectValidationError, userInfo: userInfo as? [String : Any]) } func validationErrorWithDescription(_ localizedDescription: String) -> NSError { @@ -63,7 +63,7 @@ extension NSManagedObject { NSLocalizedDescriptionKey as NSObject: localizedDescription as AnyObject ] let domain = Bundle(for: type(of: self)).bundleIdentifier ?? "undefined" - return NSError(domain: domain, code: NSManagedObjectValidationError, userInfo: userInfo as! [String : Any]) + return NSError(domain: domain, code: NSManagedObjectValidationError, userInfo: userInfo as? [String : Any]) } func multipleValidationErrorWithDescriptions(_ localizedDescriptions: [String]) -> NSError { @@ -71,6 +71,6 @@ extension NSManagedObject { NSDetailedErrorsKey as NSObject: localizedDescriptions.map(validationErrorWithDescription) as AnyObject ] let domain = Bundle(for: type(of: self)).bundleIdentifier ?? "undefined" - return NSError(domain: domain, code: NSValidationMultipleErrorsError, userInfo: userInfo as! [String : Any]) + return NSError(domain: domain, code: NSValidationMultipleErrorsError, userInfo: userInfo as? [String : Any]) } } From fb5247c1fe923d67bf8b70f1dea04f4cf78f1052 Mon Sep 17 00:00:00 2001 From: Mihaela MJ Date: Mon, 20 May 2019 18:53:23 +0200 Subject: [PATCH 3/4] converted to swift 5 --- SampleCodeStalker.xcodeproj/project.pbxproj | 12 +++++------- SampleCodeStalker/DataSource.swift | 2 +- SampleCodeStalker/DownloadButton.swift | 1 + .../SharedCode/ManagedObjectObserver.swift | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/SampleCodeStalker.xcodeproj/project.pbxproj b/SampleCodeStalker.xcodeproj/project.pbxproj index ee659b7..0d52c72 100644 --- a/SampleCodeStalker.xcodeproj/project.pbxproj +++ b/SampleCodeStalker.xcodeproj/project.pbxproj @@ -246,13 +246,13 @@ TargetAttributes = { 44C344841C5362CB0068AD9D = { CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 1010; + LastSwiftMigration = 1020; }; }; }; buildConfigurationList = 44C344801C5362CB0068AD9D /* Build configuration list for PBXProject "SampleCodeStalker" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -293,7 +293,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/bash; - shellScript = "#!/bin/bash\n# Xcode: Set version and build number from Git\n# --------------------------------------------\n#\n# This script sets the version number `CFBundleShortVersionString` to one of\n#\n# - `1.2.3` -- for the tagged commit `v1.2.3` or a hyphen-separated prerelease,\n# e.g. `v1.2.3-alpha`, `v1.2.3-alpha.2`, `v1.2.3-beta`, `v1.2.3-rc`.\n# - `1.2.3-7-gabc1234` -- at commit `abc1234`, 7 commits after `v1.2.3`,\n# - `1.2.3-7-gabc1234-dirty` -- when there are uncommitted changes, or\n# - `abc1234` or `abc1234-dirty`, respectively -- if there is no previous tag.\n#\n# and the build number `CFBundleVersion` to the number of Git commits up to the\n# current `HEAD`. (That should be a pretty much monotonically growing number\n# that is okay for the App Store. If not,)\n#\n# When about to release a new version, create a prerelease like\n#\n# git tag v1.2.3-rc.1\n#\n# and then build and archive. The script strips the hyphen-separated part from\n# the resulting binary\n#\n# Once everything looks okay and the release is tested\n# to work, set the version in stone, with release notes in the message, by running:\n#\n# git tag -s v1.2.3 # signed using your GPG key\n# git tag -a v1.2.3 # unsigned\n#\n# Remember to push the tags to origin too:\n#\n# git push --tags origin\n#\n# Read more about semantic versioning: http://semver.org\n\n\nset -e\n\nfunction strip-v () { echo -n \"${1#v}\"; }\nfunction strip-pre () { local x=\"${1#v}\"; echo -n \"${x%-*}\"; }\n\nPLIST=\"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH%.*}\"\n\nif [[ -d \"${SRCROOT}/.git\" ]];\nthen\n\nCOMMIT=$(git --git-dir=\"${SRCROOT}/.git\" rev-parse HEAD)\n\nLATEST=$(git describe --tags --abbrev=0 --match 'v[0-9]*' 2> /dev/null || true)\nSTATIC=\"$(defaults read \"${SRCROOT}/${INFOPLIST_FILE}\" \"CFBundleShortVersionString\" 2> /dev/null || true)\"\nif [[ -n \"$STATIC\" ]] && [[ \"$STATIC\" != $(strip-pre \"${LATEST}\") ]];\nthen\necho \"warning: CFBundleShortVersionString ${STATIC} disagrees with tag ${LATEST}\"\nfi\n\nTAG=$(strip-pre $(git describe --tags --match 'v[0-9]*' --abbrev=0 --exact-match 2> /dev/null || true))\nFULL_VERSION=$(strip-v $(git describe --tags --match 'v[0-9]*' --always --dirty))\nBUILD=$(echo -n $(git rev-list HEAD | wc -l))\nif [[ \"${FULL_VERSION}\" == *\"-dirty\" ]];\nthen\necho \"warning: There are uncommitted changes in Git\"\nSHORT_VERSION=\"${FULL_VERSION}\"\nelse\nSHORT_VERSION=\"${TAG:-${FULL_VERSION}}\"\nfi\n\ndefaults write \"${PLIST}\" \"CFBundleShortVersionString\" -string \"${SHORT_VERSION}\"\ndefaults write \"${PLIST}\" \"CFBundleVersion\" -string \"${BUILD}\"\ndefaults write \"${PLIST}\" \"Commit\" -string \"${COMMIT}\"\n\nelse\n\necho \"warning: Building outside Git. Leaving version number untouched.\"\n\nfi\n\necho \"CFBundleIdentifier:\" \"$(defaults read \"${PLIST}\" CFBundleIdentifier)\"\necho \"CFBundleShortVersionString:\" \"$(defaults read \"${PLIST}\" CFBundleShortVersionString)\"\necho \"CFBundleVersion:\" \"$(defaults read \"${PLIST}\" CFBundleVersion)\""; + shellScript = "#!/bin/bash\n# Xcode: Set version and build number from Git\n# --------------------------------------------\n#\n# This script sets the version number `CFBundleShortVersionString` to one of\n#\n# - `1.2.3` -- for the tagged commit `v1.2.3` or a hyphen-separated prerelease,\n# e.g. `v1.2.3-alpha`, `v1.2.3-alpha.2`, `v1.2.3-beta`, `v1.2.3-rc`.\n# - `1.2.3-7-gabc1234` -- at commit `abc1234`, 7 commits after `v1.2.3`,\n# - `1.2.3-7-gabc1234-dirty` -- when there are uncommitted changes, or\n# - `abc1234` or `abc1234-dirty`, respectively -- if there is no previous tag.\n#\n# and the build number `CFBundleVersion` to the number of Git commits up to the\n# current `HEAD`. (That should be a pretty much monotonically growing number\n# that is okay for the App Store. If not,)\n#\n# When about to release a new version, create a prerelease like\n#\n# git tag v1.2.3-rc.1\n#\n# and then build and archive. The script strips the hyphen-separated part from\n# the resulting binary\n#\n# Once everything looks okay and the release is tested\n# to work, set the version in stone, with release notes in the message, by running:\n#\n# git tag -s v1.2.3 # signed using your GPG key\n# git tag -a v1.2.3 # unsigned\n#\n# Remember to push the tags to origin too:\n#\n# git push --tags origin\n#\n# Read more about semantic versioning: http://semver.org\n\n\nset -e\n\nfunction strip-v () { echo -n \"${1#v}\"; }\nfunction strip-pre () { local x=\"${1#v}\"; echo -n \"${x%-*}\"; }\n\nPLIST=\"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH%.*}\"\n\nif [[ -d \"${SRCROOT}/.git\" ]];\nthen\n\nCOMMIT=$(git --git-dir=\"${SRCROOT}/.git\" rev-parse HEAD)\n\nLATEST=$(git describe --tags --abbrev=0 --match 'v[0-9]*' 2> /dev/null || true)\nSTATIC=\"$(defaults read \"${SRCROOT}/${INFOPLIST_FILE}\" \"CFBundleShortVersionString\" 2> /dev/null || true)\"\nif [[ -n \"$STATIC\" ]] && [[ \"$STATIC\" != $(strip-pre \"${LATEST}\") ]];\nthen\necho \"warning: CFBundleShortVersionString ${STATIC} disagrees with tag ${LATEST}\"\nfi\n\nTAG=$(strip-pre $(git describe --tags --match 'v[0-9]*' --abbrev=0 --exact-match 2> /dev/null || true))\nFULL_VERSION=$(strip-v $(git describe --tags --match 'v[0-9]*' --always --dirty))\nBUILD=$(echo -n $(git rev-list HEAD | wc -l))\nif [[ \"${FULL_VERSION}\" == *\"-dirty\" ]];\nthen\necho \"warning: There are uncommitted changes in Git\"\nSHORT_VERSION=\"${FULL_VERSION}\"\nelse\nSHORT_VERSION=\"${TAG:-${FULL_VERSION}}\"\nfi\n\ndefaults write \"${PLIST}\" \"CFBundleShortVersionString\" -string \"${SHORT_VERSION}\"\ndefaults write \"${PLIST}\" \"CFBundleVersion\" -string \"${BUILD}\"\ndefaults write \"${PLIST}\" \"Commit\" -string \"${COMMIT}\"\n\nelse\n\necho \"warning: Building outside Git. Leaving version number untouched.\"\n\nfi\n\necho \"CFBundleIdentifier:\" \"$(defaults read \"${PLIST}\" CFBundleIdentifier)\"\necho \"CFBundleShortVersionString:\" \"$(defaults read \"${PLIST}\" CFBundleShortVersionString)\"\necho \"CFBundleVersion:\" \"$(defaults read \"${PLIST}\" CFBundleVersion)\"\n"; }; /* End PBXShellScriptBuildPhase section */ @@ -464,8 +464,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = at.krajacic.SampleCodeStalker; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = On; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -478,8 +477,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = at.krajacic.SampleCodeStalker; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = On; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/SampleCodeStalker/DataSource.swift b/SampleCodeStalker/DataSource.swift index 79974a3..35543c4 100644 --- a/SampleCodeStalker/DataSource.swift +++ b/SampleCodeStalker/DataSource.swift @@ -34,7 +34,7 @@ final class DataSource: DataSourceType where Deleg } deinit { - NotificationCenter.default.removeObserver(contextSavedToken) + NotificationCenter.default.removeObserver(contextSavedToken!) } // To keep the filter string when reloading the data diff --git a/SampleCodeStalker/DownloadButton.swift b/SampleCodeStalker/DownloadButton.swift index 52a7b69..010229d 100644 --- a/SampleCodeStalker/DownloadButton.swift +++ b/SampleCodeStalker/DownloadButton.swift @@ -199,6 +199,7 @@ extension NSBezierPath { case .lineTo: path.addLine(to: points[0]) case .curveTo: path.addCurve(to: points[2], control1: points[0], control2: points[1]) case .closePath: path.closeSubpath() + @unknown default: fatalError() } } diff --git a/SampleCodeStalker/SharedCode/ManagedObjectObserver.swift b/SampleCodeStalker/SharedCode/ManagedObjectObserver.swift index 59017de..8aa2b13 100644 --- a/SampleCodeStalker/SharedCode/ManagedObjectObserver.swift +++ b/SampleCodeStalker/SharedCode/ManagedObjectObserver.swift @@ -27,7 +27,7 @@ public final class ManagedObjectObserver { } deinit { - NotificationCenter.default.removeObserver(token) + NotificationCenter.default.removeObserver(token!) } From d0f33a88570b05ec52bf6e371fff3ae50d44ace5 Mon Sep 17 00:00:00 2001 From: Mihaela MJ Date: Mon, 20 May 2019 19:00:06 +0200 Subject: [PATCH 4/4] changed text color --- SampleCodeStalker/Base.lproj/Main.storyboard | 44 ++++++++++---------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/SampleCodeStalker/Base.lproj/Main.storyboard b/SampleCodeStalker/Base.lproj/Main.storyboard index 9de147b..ba8d84f 100644 --- a/SampleCodeStalker/Base.lproj/Main.storyboard +++ b/SampleCodeStalker/Base.lproj/Main.storyboard @@ -1,9 +1,10 @@ - - + + - - + + + @@ -652,11 +653,14 @@ - + + + + @@ -681,7 +685,7 @@ - + @@ -706,7 +710,7 @@ - + @@ -722,7 +726,7 @@ - + @@ -733,7 +737,7 @@ - + @@ -741,7 +745,7 @@ - + @@ -814,13 +818,13 @@ - + -