From 558f8b18aad4a144fe845caebc0a4dd466a1de3b Mon Sep 17 00:00:00 2001 From: Darrell Root Date: Thu, 20 Sep 2018 17:48:13 -0700 Subject: [PATCH 1/4] Updated chapter 1 to Swift4.2 Xcode 10 --- .../RandomPassword.xcodeproj/project.pbxproj | 164 +++--------------- .../xcshareddata/IDEWorkspaceChecks.plist | 8 + ...31379D11-66D3-4CE5-B0B8-0598C69B2E33.plist | 22 +++ .../Info.plist | 33 ++++ .../RandomPassword/AppDelegate.swift | 3 +- .../RandomPassword/GeneratePassword.swift | 6 +- .../RandomPassword/RandomPassword/Info.plist | 2 +- .../RandomPassword/MainWindowController.swift | 7 +- .../RandomPassword/MainWindowController.xib | 16 +- .../RandomPasswordTests/Info.plist | 24 --- .../RandomPasswordTests.swift | 36 ---- 11 files changed, 109 insertions(+), 212 deletions(-) create mode 100644 Chapter 01 - GetStarted/RandomPassword/RandomPassword.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 Chapter 01 - GetStarted/RandomPassword/RandomPassword.xcodeproj/xcshareddata/xcbaselines/43DA80CF1AE5754900B48DD0.xcbaseline/31379D11-66D3-4CE5-B0B8-0598C69B2E33.plist create mode 100644 Chapter 01 - GetStarted/RandomPassword/RandomPassword.xcodeproj/xcshareddata/xcbaselines/43DA80CF1AE5754900B48DD0.xcbaseline/Info.plist delete mode 100644 Chapter 01 - GetStarted/RandomPassword/RandomPasswordTests/Info.plist delete mode 100644 Chapter 01 - GetStarted/RandomPassword/RandomPasswordTests/RandomPasswordTests.swift diff --git a/Chapter 01 - GetStarted/RandomPassword/RandomPassword.xcodeproj/project.pbxproj b/Chapter 01 - GetStarted/RandomPassword/RandomPassword.xcodeproj/project.pbxproj index 8bd6ffe..bbe01d0 100644 --- a/Chapter 01 - GetStarted/RandomPassword/RandomPassword.xcodeproj/project.pbxproj +++ b/Chapter 01 - GetStarted/RandomPassword/RandomPassword.xcodeproj/project.pbxproj @@ -10,31 +10,17 @@ 43DA80C61AE5754800B48DD0 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43DA80C51AE5754800B48DD0 /* AppDelegate.swift */; }; 43DA80C81AE5754800B48DD0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 43DA80C71AE5754800B48DD0 /* Images.xcassets */; }; 43DA80CB1AE5754800B48DD0 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 43DA80C91AE5754800B48DD0 /* MainMenu.xib */; }; - 43DA80D71AE5754900B48DD0 /* RandomPasswordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43DA80D61AE5754900B48DD0 /* RandomPasswordTests.swift */; }; 43DA80E21AE5826D00B48DD0 /* MainWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43DA80E01AE5826D00B48DD0 /* MainWindowController.swift */; }; 43DA80E31AE5826D00B48DD0 /* MainWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 43DA80E11AE5826D00B48DD0 /* MainWindowController.xib */; }; 43DA80E51AE5855600B48DD0 /* GeneratePassword.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43DA80E41AE5855600B48DD0 /* GeneratePassword.swift */; }; /* End PBXBuildFile section */ -/* Begin PBXContainerItemProxy section */ - 43DA80D11AE5754900B48DD0 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 43DA80B81AE5754800B48DD0 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 43DA80BF1AE5754800B48DD0; - remoteInfo = RandomPassword; - }; -/* End PBXContainerItemProxy section */ - /* Begin PBXFileReference section */ 43DA80C01AE5754800B48DD0 /* RandomPassword.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RandomPassword.app; sourceTree = BUILT_PRODUCTS_DIR; }; 43DA80C41AE5754800B48DD0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 43DA80C51AE5754800B48DD0 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 43DA80C71AE5754800B48DD0 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 43DA80CA1AE5754800B48DD0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; - 43DA80D01AE5754900B48DD0 /* RandomPasswordTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RandomPasswordTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 43DA80D51AE5754900B48DD0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 43DA80D61AE5754900B48DD0 /* RandomPasswordTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RandomPasswordTests.swift; sourceTree = ""; }; 43DA80E01AE5826D00B48DD0 /* MainWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainWindowController.swift; sourceTree = ""; }; 43DA80E11AE5826D00B48DD0 /* MainWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainWindowController.xib; sourceTree = ""; }; 43DA80E41AE5855600B48DD0 /* GeneratePassword.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratePassword.swift; sourceTree = ""; }; @@ -48,13 +34,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 43DA80CD1AE5754900B48DD0 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -62,7 +41,6 @@ isa = PBXGroup; children = ( 43DA80C21AE5754800B48DD0 /* RandomPassword */, - 43DA80D31AE5754900B48DD0 /* RandomPasswordTests */, 43DA80C11AE5754800B48DD0 /* Products */, ); sourceTree = ""; @@ -71,7 +49,6 @@ isa = PBXGroup; children = ( 43DA80C01AE5754800B48DD0 /* RandomPassword.app */, - 43DA80D01AE5754900B48DD0 /* RandomPasswordTests.xctest */, ); name = Products; sourceTree = ""; @@ -98,23 +75,6 @@ name = "Supporting Files"; sourceTree = ""; }; - 43DA80D31AE5754900B48DD0 /* RandomPasswordTests */ = { - isa = PBXGroup; - children = ( - 43DA80D61AE5754900B48DD0 /* RandomPasswordTests.swift */, - 43DA80D41AE5754900B48DD0 /* Supporting Files */, - ); - path = RandomPasswordTests; - sourceTree = ""; - }; - 43DA80D41AE5754900B48DD0 /* Supporting Files */ = { - isa = PBXGroup; - children = ( - 43DA80D51AE5754900B48DD0 /* Info.plist */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -135,41 +95,19 @@ productReference = 43DA80C01AE5754800B48DD0 /* RandomPassword.app */; productType = "com.apple.product-type.application"; }; - 43DA80CF1AE5754900B48DD0 /* RandomPasswordTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 43DA80DD1AE5754900B48DD0 /* Build configuration list for PBXNativeTarget "RandomPasswordTests" */; - buildPhases = ( - 43DA80CC1AE5754900B48DD0 /* Sources */, - 43DA80CD1AE5754900B48DD0 /* Frameworks */, - 43DA80CE1AE5754900B48DD0 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 43DA80D21AE5754900B48DD0 /* PBXTargetDependency */, - ); - name = RandomPasswordTests; - productName = RandomPasswordTests; - productReference = 43DA80D01AE5754900B48DD0 /* RandomPasswordTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 43DA80B81AE5754800B48DD0 /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0700; + LastSwiftUpdateCheck = 1000; + LastUpgradeCheck = 1000; ORGANIZATIONNAME = "Big Nerd Ranch"; TargetAttributes = { 43DA80BF1AE5754800B48DD0 = { CreatedOnToolsVersion = 6.3; }; - 43DA80CF1AE5754900B48DD0 = { - CreatedOnToolsVersion = 6.3; - TestTargetID = 43DA80BF1AE5754800B48DD0; - }; }; }; buildConfigurationList = 43DA80BB1AE5754800B48DD0 /* Build configuration list for PBXProject "RandomPassword" */; @@ -186,7 +124,6 @@ projectRoot = ""; targets = ( 43DA80BF1AE5754800B48DD0 /* RandomPassword */, - 43DA80CF1AE5754900B48DD0 /* RandomPasswordTests */, ); }; /* End PBXProject section */ @@ -202,13 +139,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 43DA80CE1AE5754900B48DD0 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -222,24 +152,8 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 43DA80CC1AE5754900B48DD0 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 43DA80D71AE5754900B48DD0 /* RandomPasswordTests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXSourcesBuildPhase section */ -/* Begin PBXTargetDependency section */ - 43DA80D21AE5754900B48DD0 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 43DA80BF1AE5754800B48DD0 /* RandomPassword */; - targetProxy = 43DA80D11AE5754900B48DD0 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - /* Begin PBXVariantGroup section */ 43DA80C91AE5754800B48DD0 /* MainMenu.xib */ = { isa = PBXVariantGroup; @@ -260,13 +174,23 @@ 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; CODE_SIGN_IDENTITY = "-"; @@ -289,11 +213,12 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.10; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -305,13 +230,23 @@ 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; CODE_SIGN_IDENTITY = "-"; @@ -327,9 +262,11 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.10; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -357,44 +294,6 @@ }; name = Release; }; - 43DA80DE1AE5754900B48DD0 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - COMBINE_HIDPI_IMAGES = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(DEVELOPER_FRAMEWORKS_DIR)", - "$(inherited)", - ); - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - INFOPLIST_FILE = RandomPasswordTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.bignerdranch.$(PRODUCT_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(TARGET_NAME)"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RandomPassword.app/Contents/MacOS/RandomPassword"; - }; - name = Debug; - }; - 43DA80DF1AE5754900B48DD0 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - COMBINE_HIDPI_IMAGES = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(DEVELOPER_FRAMEWORKS_DIR)", - "$(inherited)", - ); - INFOPLIST_FILE = RandomPasswordTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.bignerdranch.$(PRODUCT_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(TARGET_NAME)"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RandomPassword.app/Contents/MacOS/RandomPassword"; - }; - name = Release; - }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -416,15 +315,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 43DA80DD1AE5754900B48DD0 /* Build configuration list for PBXNativeTarget "RandomPasswordTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 43DA80DE1AE5754900B48DD0 /* Debug */, - 43DA80DF1AE5754900B48DD0 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; /* End XCConfigurationList section */ }; rootObject = 43DA80B81AE5754800B48DD0 /* Project object */; diff --git a/Chapter 01 - GetStarted/RandomPassword/RandomPassword.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Chapter 01 - GetStarted/RandomPassword/RandomPassword.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Chapter 01 - GetStarted/RandomPassword/RandomPassword.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Chapter 01 - GetStarted/RandomPassword/RandomPassword.xcodeproj/xcshareddata/xcbaselines/43DA80CF1AE5754900B48DD0.xcbaseline/31379D11-66D3-4CE5-B0B8-0598C69B2E33.plist b/Chapter 01 - GetStarted/RandomPassword/RandomPassword.xcodeproj/xcshareddata/xcbaselines/43DA80CF1AE5754900B48DD0.xcbaseline/31379D11-66D3-4CE5-B0B8-0598C69B2E33.plist new file mode 100644 index 0000000..f1e17e7 --- /dev/null +++ b/Chapter 01 - GetStarted/RandomPassword/RandomPassword.xcodeproj/xcshareddata/xcbaselines/43DA80CF1AE5754900B48DD0.xcbaseline/31379D11-66D3-4CE5-B0B8-0598C69B2E33.plist @@ -0,0 +1,22 @@ + + + + + classNames + + RandomPasswordTests + + testPerformanceExample() + + com.apple.XCTPerformanceMetric_WallClockTime + + baselineAverage + 8.31e-07 + baselineIntegrationDisplayName + Local Baseline + + + + + + diff --git a/Chapter 01 - GetStarted/RandomPassword/RandomPassword.xcodeproj/xcshareddata/xcbaselines/43DA80CF1AE5754900B48DD0.xcbaseline/Info.plist b/Chapter 01 - GetStarted/RandomPassword/RandomPassword.xcodeproj/xcshareddata/xcbaselines/43DA80CF1AE5754900B48DD0.xcbaseline/Info.plist new file mode 100644 index 0000000..92db816 --- /dev/null +++ b/Chapter 01 - GetStarted/RandomPassword/RandomPassword.xcodeproj/xcshareddata/xcbaselines/43DA80CF1AE5754900B48DD0.xcbaseline/Info.plist @@ -0,0 +1,33 @@ + + + + + runDestinationsByUUID + + 31379D11-66D3-4CE5-B0B8-0598C69B2E33 + + localComputer + + busSpeedInMHz + 100 + cpuCount + 1 + cpuKind + Intel Core i7 + cpuSpeedInMHz + 2300 + logicalCPUCoresPerPackage + 8 + modelCode + MacBookPro10,1 + physicalCPUCoresPerPackage + 4 + platformIdentifier + com.apple.platform.macosx + + targetArchitecture + x86_64 + + + + diff --git a/Chapter 01 - GetStarted/RandomPassword/RandomPassword/AppDelegate.swift b/Chapter 01 - GetStarted/RandomPassword/RandomPassword/AppDelegate.swift index 9f02c6a..092170f 100644 --- a/Chapter 01 - GetStarted/RandomPassword/RandomPassword/AppDelegate.swift +++ b/Chapter 01 - GetStarted/RandomPassword/RandomPassword/AppDelegate.swift @@ -13,8 +13,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { var mainWindowController: MainWindowController? - - func applicationDidFinishLaunching(aNotification: NSNotification) { + func applicationDidFinishLaunching(_ aNotification: Notification) { // Create a window controller with a XIB file of the same name let mainWindowController = MainWindowController() diff --git a/Chapter 01 - GetStarted/RandomPassword/RandomPassword/GeneratePassword.swift b/Chapter 01 - GetStarted/RandomPassword/RandomPassword/GeneratePassword.swift index 3a1f254..b2c617f 100644 --- a/Chapter 01 - GetStarted/RandomPassword/RandomPassword/GeneratePassword.swift +++ b/Chapter 01 - GetStarted/RandomPassword/RandomPassword/GeneratePassword.swift @@ -8,8 +8,10 @@ import Foundation -private let characters = Array(("0123456789abcdefghijklmnopqrstuvwxyz" + - "ABCDEFGHIJKLMNOPQRSTUVWXYZ").characters) +//private let characters = Array(("0123456789abcdefghijklmnopqrstuvwxyz" + +// "ABCDEFGHIJKLMNOPQRSTUVWXYZ").characters) +private let characters = Array("0123456789abcdefghijklmnopqrstuvwxyz" + + "ABCDEFGHIJKLMNOPQRSTUVWXYZ") func generateRandomString(length: Int) -> String { // Start with an empty string diff --git a/Chapter 01 - GetStarted/RandomPassword/RandomPassword/Info.plist b/Chapter 01 - GetStarted/RandomPassword/RandomPassword/Info.plist index 75e9724..abcc927 100644 --- a/Chapter 01 - GetStarted/RandomPassword/RandomPassword/Info.plist +++ b/Chapter 01 - GetStarted/RandomPassword/RandomPassword/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0 + 1.1 CFBundleSignature ???? CFBundleVersion diff --git a/Chapter 01 - GetStarted/RandomPassword/RandomPassword/MainWindowController.swift b/Chapter 01 - GetStarted/RandomPassword/RandomPassword/MainWindowController.swift index e712975..2e79338 100644 --- a/Chapter 01 - GetStarted/RandomPassword/RandomPassword/MainWindowController.swift +++ b/Chapter 01 - GetStarted/RandomPassword/RandomPassword/MainWindowController.swift @@ -12,20 +12,19 @@ class MainWindowController: NSWindowController { @IBOutlet weak var textField: NSTextField! - override var windowNibName: String? { - return "MainWindowController" + override var windowNibName: NSNib.Name? { + return NSNib.Name("MainWindowController") } override func windowDidLoad() { super.windowDidLoad() - // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. } @IBAction func generatePassword(sender: AnyObject) { // Get a random string of length 8 let length = 8 - let password = generateRandomString(length) + let password = generateRandomString(length: length) // Tell the text field what to display textField.stringValue = password diff --git a/Chapter 01 - GetStarted/RandomPassword/RandomPassword/MainWindowController.xib b/Chapter 01 - GetStarted/RandomPassword/RandomPassword/MainWindowController.xib index ac9bf08..61fa5ab 100644 --- a/Chapter 01 - GetStarted/RandomPassword/RandomPassword/MainWindowController.xib +++ b/Chapter 01 - GetStarted/RandomPassword/RandomPassword/MainWindowController.xib @@ -1,7 +1,9 @@ - - + + - + + + @@ -12,17 +14,18 @@ - + - + + @@ -31,12 +34,13 @@ diff --git a/Chapter 01 - GetStarted/RandomPassword/RandomPasswordTests/Info.plist b/Chapter 01 - GetStarted/RandomPassword/RandomPasswordTests/Info.plist deleted file mode 100644 index ba72822..0000000 --- a/Chapter 01 - GetStarted/RandomPassword/RandomPasswordTests/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - - diff --git a/Chapter 01 - GetStarted/RandomPassword/RandomPasswordTests/RandomPasswordTests.swift b/Chapter 01 - GetStarted/RandomPassword/RandomPasswordTests/RandomPasswordTests.swift deleted file mode 100644 index a63807f..0000000 --- a/Chapter 01 - GetStarted/RandomPassword/RandomPasswordTests/RandomPasswordTests.swift +++ /dev/null @@ -1,36 +0,0 @@ -// -// RandomPasswordTests.swift -// RandomPasswordTests -// -// Created by Nate Chandler on 4/20/15. -// Copyright (c) 2015 Big Nerd Ranch. All rights reserved. -// - -import Cocoa -import XCTest - -class RandomPasswordTests: XCTestCase { - - 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 testExample() { - // This is an example of a functional test case. - XCTAssert(true, "Pass") - } - - func testPerformanceExample() { - // This is an example of a performance test case. - self.measureBlock() { - // Put the code you want to measure the time of here. - } - } - -} From cb1af152256b717cf052e6ebe9149a38ba9920ce Mon Sep 17 00:00:00 2001 From: Darrell Root Date: Thu, 20 Sep 2018 20:27:21 -0700 Subject: [PATCH 2/4] Updated Chapter 2 to Swift 4.2 --- .../MyPlayground.playground/contents.swift | 15 +++++++++++++-- .../MyPlayground.playground/contents.xcplayground | 2 +- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++++ .../MyPlayground.playground/timeline.xctimeline | 6 +++--- 4 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 Chapter 02 - Swift/MyPlayground.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Chapter 02 - Swift/MyPlayground.playground/contents.swift b/Chapter 02 - Swift/MyPlayground.playground/contents.swift index 3235630..2b38639 100644 --- a/Chapter 02 - Swift/MyPlayground.playground/contents.swift +++ b/Chapter 02 - Swift/MyPlayground.playground/contents.swift @@ -72,7 +72,18 @@ else { // do something else } -for var i = 0; i < countingUp.count; i++ { +// Old C-style for loop has been removed from Swift as of version 3. +/*for var i = 0; i < countingUp.count; i++ { + let string = countingUp[i] +}*/ + +// Use for i in range syntax instead when incrementing by 1 +for i in 0.. - + \ No newline at end of file diff --git a/Chapter 02 - Swift/MyPlayground.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Chapter 02 - Swift/MyPlayground.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Chapter 02 - Swift/MyPlayground.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Chapter 02 - Swift/MyPlayground.playground/timeline.xctimeline b/Chapter 02 - Swift/MyPlayground.playground/timeline.xctimeline index 3415004..ab7bd15 100644 --- a/Chapter 02 - Swift/MyPlayground.playground/timeline.xctimeline +++ b/Chapter 02 - Swift/MyPlayground.playground/timeline.xctimeline @@ -3,17 +3,17 @@ version = "3.0"> From 47663211517739da1ebd6937f01c099ab639a171 Mon Sep 17 00:00:00 2001 From: Darrell Root Date: Thu, 20 Sep 2018 20:53:49 -0700 Subject: [PATCH 3/4] Updated chapter 3 to Swift 42 --- .../Physics.playground/contents.swift | 26 +++++++++---------- .../Physics.playground/contents.xcplayground | 2 +- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++ .../Physics.playground/timeline.xctimeline | 8 +++--- 4 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 Chapter 03 - Swift2/Physics.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Chapter 03 - Swift2/Physics.playground/contents.swift b/Chapter 03 - Swift2/Physics.playground/contents.swift index 938ddfe..d792e8c 100644 --- a/Chapter 03 - Swift2/Physics.playground/contents.swift +++ b/Chapter 03 - Swift2/Physics.playground/contents.swift @@ -28,7 +28,7 @@ struct Vector: CustomStringConvertible { } func +(left: Vector, right: Vector) -> Vector { - return left.vectorByAddingVector(right) + return left.vectorByAddingVector(vector: right) } func *(left: Vector, right: Double) -> Vector { return Vector(x: left.x * right , y: left.y * right) @@ -53,7 +53,7 @@ class Particle { self.init(position: Vector()) } - func tick(dt: NSTimeInterval) { + func tick(dt: TimeInterval) { velocity = velocity + acceleration * dt position = position + velocity * dt position.y = max(0, position.y) @@ -62,20 +62,20 @@ class Particle { class Rocket: Particle { let thrust: Double - var thrustTimeRemaining: NSTimeInterval + var thrustTimeRemaining: TimeInterval let direction = Vector(x: 0, y: 1) - convenience init(thrust: Double, thrustTime: NSTimeInterval) { + convenience init(thrust: Double, thrustTime: TimeInterval) { self.init(position: Vector(), thrust: thrust, thrustTime: thrustTime) } - init(position: Vector, thrust: Double, thrustTime: NSTimeInterval) { + init(position: Vector, thrust: Double, thrustTime: TimeInterval) { self.thrust = thrust self.thrustTimeRemaining = thrustTime super.init(position: position) } - override func tick(dt: NSTimeInterval) { + override func tick(dt: TimeInterval) { if thrustTimeRemaining > 0.0 { let thrustTime = min(dt, thrustTimeRemaining) let thrustToApply = thrust * thrustTime @@ -83,26 +83,26 @@ class Rocket: Particle { acceleration = acceleration + thrustForce thrustTimeRemaining -= thrustTime } - super.tick(dt) + super.tick(dt: dt) } } let gravity = Vector(x: 0, y: -9.8) // meters per second -let twoGs = gravity.vectorByAddingVector(gravity) +let twoGs = gravity.vectorByAddingVector(vector: gravity) let twoGsAlso = gravity * 2 class Simulation { var particles: [Particle] = [] - var time: NSTimeInterval = 0.0 + var time: TimeInterval = 0.0 func addParticle(particle: Particle) { particles.append(particle) } - func tick(dt: NSTimeInterval) { + func tick(dt: TimeInterval) { for particle in particles { particle.acceleration = particle.acceleration + gravity - particle.tick(dt) + particle.tick(dt: dt) particle.acceleration = Vector() particle.position.y } @@ -125,11 +125,11 @@ let simulation = Simulation() //simulation.addParticle(ball) let rocket = Rocket(thrust: 10.0, thrustTime: 60.0) -simulation.addParticle(rocket) +simulation.addParticle(particle: rocket) while simulation.particles.count > 0 && simulation.time < 500 { - simulation.tick(1.0) + simulation.tick(dt: 1.0) } print("Gravity is \(gravity).") diff --git a/Chapter 03 - Swift2/Physics.playground/contents.xcplayground b/Chapter 03 - Swift2/Physics.playground/contents.xcplayground index a204ba6..06828af 100644 --- a/Chapter 03 - Swift2/Physics.playground/contents.xcplayground +++ b/Chapter 03 - Swift2/Physics.playground/contents.xcplayground @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/Chapter 03 - Swift2/Physics.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Chapter 03 - Swift2/Physics.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Chapter 03 - Swift2/Physics.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Chapter 03 - Swift2/Physics.playground/timeline.xctimeline b/Chapter 03 - Swift2/Physics.playground/timeline.xctimeline index 1668c75..9f83034 100644 --- a/Chapter 03 - Swift2/Physics.playground/timeline.xctimeline +++ b/Chapter 03 - Swift2/Physics.playground/timeline.xctimeline @@ -3,22 +3,22 @@ version = "3.0"> From 039f5a578e86d744b879610278eb649324d20390 Mon Sep 17 00:00:00 2001 From: Darrell Root Date: Thu, 20 Sep 2018 22:42:49 -0700 Subject: [PATCH 4/4] Updated Chapter5 to Swift4.2 --- .../RGBWell/RGBWell.xcodeproj/project.pbxproj | 34 ++++++++++++++++++- .../xcshareddata/IDEWorkspaceChecks.plist | 8 +++++ .../RGBWell/RGBWell/AppDelegate.swift | 4 +-- .../RGBWell/RGBWell/Info.plist | 4 +-- .../RGBWell/MainWindowController.swift | 4 +-- .../RGBWell/RGBWell/MainWindowController.xib | 27 ++++++++++----- .../RGBWell/RGBWellTests/Info.plist | 2 +- 7 files changed, 66 insertions(+), 17 deletions(-) create mode 100644 Chapter 05 - Controls/RGBWell/RGBWell.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Chapter 05 - Controls/RGBWell/RGBWell.xcodeproj/project.pbxproj b/Chapter 05 - Controls/RGBWell/RGBWell.xcodeproj/project.pbxproj index 9cdfb30..672b130 100644 --- a/Chapter 05 - Controls/RGBWell/RGBWell.xcodeproj/project.pbxproj +++ b/Chapter 05 - Controls/RGBWell/RGBWell.xcodeproj/project.pbxproj @@ -157,7 +157,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0620; + LastUpgradeCheck = 1000; ORGANIZATIONNAME = "Big Nerd Ranch"; TargetAttributes = { AE1840031A519F3F005226E6 = { @@ -256,20 +256,32 @@ 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; CODE_SIGN_IDENTITY = "-"; COPY_PHASE_STRIP = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -287,6 +299,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -298,13 +311,23 @@ 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; CODE_SIGN_IDENTITY = "-"; @@ -313,6 +336,7 @@ ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; @@ -322,6 +346,8 @@ MACOSX_DEPLOYMENT_TARGET = 10.10; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -332,7 +358,9 @@ COMBINE_HIDPI_IMAGES = YES; INFOPLIST_FILE = RGBWell/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.bignerdranch.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -343,7 +371,9 @@ COMBINE_HIDPI_IMAGES = YES; INFOPLIST_FILE = RGBWell/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.bignerdranch.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -362,6 +392,7 @@ ); INFOPLIST_FILE = RGBWellTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.bignerdranch.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RGBWell.app/Contents/MacOS/RGBWell"; }; @@ -378,6 +409,7 @@ ); INFOPLIST_FILE = RGBWellTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.bignerdranch.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RGBWell.app/Contents/MacOS/RGBWell"; }; diff --git a/Chapter 05 - Controls/RGBWell/RGBWell.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Chapter 05 - Controls/RGBWell/RGBWell.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Chapter 05 - Controls/RGBWell/RGBWell.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Chapter 05 - Controls/RGBWell/RGBWell/AppDelegate.swift b/Chapter 05 - Controls/RGBWell/RGBWell/AppDelegate.swift index bb473e1..1daff6e 100644 --- a/Chapter 05 - Controls/RGBWell/RGBWell/AppDelegate.swift +++ b/Chapter 05 - Controls/RGBWell/RGBWell/AppDelegate.swift @@ -14,7 +14,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { var mainWindowController: MainWindowController? - func applicationDidFinishLaunching(aNotification: NSNotification) { + func applicationDidFinishLaunching(_ aNotification: Notification) { mainWindowController = MainWindowController() mainWindowController!.showWindow(self) @@ -25,4 +25,4 @@ class AppDelegate: NSObject, NSApplicationDelegate { } -} \ No newline at end of file +} diff --git a/Chapter 05 - Controls/RGBWell/RGBWell/Info.plist b/Chapter 05 - Controls/RGBWell/RGBWell/Info.plist index 8202712..eb63c16 100644 --- a/Chapter 05 - Controls/RGBWell/RGBWell/Info.plist +++ b/Chapter 05 - Controls/RGBWell/RGBWell/Info.plist @@ -9,7 +9,7 @@ CFBundleIconFile CFBundleIdentifier - com.bignerdranch.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0 + 1.1 CFBundleSignature ???? CFBundleVersion diff --git a/Chapter 05 - Controls/RGBWell/RGBWell/MainWindowController.swift b/Chapter 05 - Controls/RGBWell/RGBWell/MainWindowController.swift index b483f85..00f90af 100644 --- a/Chapter 05 - Controls/RGBWell/RGBWell/MainWindowController.swift +++ b/Chapter 05 - Controls/RGBWell/RGBWell/MainWindowController.swift @@ -15,8 +15,8 @@ class MainWindowController: NSWindowController { @IBOutlet weak var bSlider: NSSlider! @IBOutlet weak var colorWell: NSColorWell! - override var windowNibName: String { - return "MainWindowController" + override var windowNibName: NSNib.Name? { + return NSNib.Name("MainWindowController") } var r: Float = 0.5 diff --git a/Chapter 05 - Controls/RGBWell/RGBWell/MainWindowController.xib b/Chapter 05 - Controls/RGBWell/RGBWell/MainWindowController.xib index e243313..22785e4 100644 --- a/Chapter 05 - Controls/RGBWell/RGBWell/MainWindowController.xib +++ b/Chapter 05 - Controls/RGBWell/RGBWell/MainWindowController.xib @@ -1,7 +1,9 @@ - - + + - + + + @@ -15,24 +17,26 @@ - + - + + - + + @@ -41,13 +45,15 @@ + - + + @@ -56,21 +62,24 @@ + - + + - + + diff --git a/Chapter 05 - Controls/RGBWell/RGBWellTests/Info.plist b/Chapter 05 - Controls/RGBWell/RGBWellTests/Info.plist index dff99ba..ba72822 100644 --- a/Chapter 05 - Controls/RGBWell/RGBWellTests/Info.plist +++ b/Chapter 05 - Controls/RGBWell/RGBWellTests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.bignerdranch.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName