From 7be572f771d11a5b08fe54cec09f3be25eca5a04 Mon Sep 17 00:00:00 2001 From: Xin Hong Date: Wed, 27 Sep 2017 16:22:10 +0800 Subject: [PATCH] swift 4 --- .gitignore | 68 +++++++++++++++++++ Example.xcodeproj/project.pbxproj | 22 ++++-- .../xcschemes/Example.xcscheme | 4 +- Example/Base.lproj/Main.storyboard | 16 +++-- Example/Cartfile.resolved | 2 +- Example/EventsViewController.swift | 4 +- Example/ExampleViewController.swift | 6 +- Example/Info.plist | 4 +- Example/Models/ModelObject.swift | 1 + Example/ProjectsViewController.swift | 4 +- .../Transformers/ArrayValueTransformer.swift | 2 +- .../Transformers/ObjectValueTransformer.swift | 2 +- .../project.pbxproj | 34 +++++++--- .../ManagedObjectAdapter iOS.xcscheme | 4 +- .../ManagedObjectAdapter watchOS.xcscheme | 4 +- .../ManagedObjectAdapterTests.xcscheme | 4 +- .../Supporting Files/Info-iOS.plist | 2 +- .../Supporting Files/Info-watchOS.plist | 2 +- ManagedObjectAdapterTests/Info.plist | 2 +- 19 files changed, 149 insertions(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index 4a9794f..3319107 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,69 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData/ +Carthage/ Example/Carthage/ + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata/ + +## Other +*.moved-aside +*.xccheckout +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/#source-control + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output diff --git a/Example.xcodeproj/project.pbxproj b/Example.xcodeproj/project.pbxproj index c582bc8..bcf6821 100644 --- a/Example.xcodeproj/project.pbxproj +++ b/Example.xcodeproj/project.pbxproj @@ -191,12 +191,12 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = Teambition; TargetAttributes = { D3283CA91D48812300E1B445 = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; }; }; @@ -296,14 +296,20 @@ 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_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_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; @@ -344,14 +350,20 @@ 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_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_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; @@ -389,7 +401,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = Teambition.ManagedObjectAdapter.Example; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -405,7 +418,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = Teambition.ManagedObjectAdapter.Example; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Release; }; diff --git a/Example.xcodeproj/xcuserdata/hongxin.xcuserdatad/xcschemes/Example.xcscheme b/Example.xcodeproj/xcuserdata/hongxin.xcuserdatad/xcschemes/Example.xcscheme index 8381b1b..ee68f25 100644 --- a/Example.xcodeproj/xcuserdata/hongxin.xcuserdatad/xcschemes/Example.xcscheme +++ b/Example.xcodeproj/xcuserdata/hongxin.xcuserdatad/xcschemes/Example.xcscheme @@ -1,6 +1,6 @@ @@ -45,6 +46,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/Example/Base.lproj/Main.storyboard b/Example/Base.lproj/Main.storyboard index 45a1f6c..5cd9b44 100644 --- a/Example/Base.lproj/Main.storyboard +++ b/Example/Base.lproj/Main.storyboard @@ -1,8 +1,12 @@ - - + + + + + - + + @@ -10,9 +14,9 @@ - + - + @@ -30,7 +34,7 @@ - + diff --git a/Example/Cartfile.resolved b/Example/Cartfile.resolved index 2457a02..3e94aa3 100644 --- a/Example/Cartfile.resolved +++ b/Example/Cartfile.resolved @@ -1 +1 @@ -github "Hearst-DD/ObjectMapper" "2.2.1" +github "Hearst-DD/ObjectMapper" "3.0.0" diff --git a/Example/EventsViewController.swift b/Example/EventsViewController.swift index acc6046..f7f9aaf 100644 --- a/Example/EventsViewController.swift +++ b/Example/EventsViewController.swift @@ -23,11 +23,11 @@ class EventsViewController: UITableViewController { let event = events.first let moEvent = event?.toManagedObject(in: CoreDataManager.context) as? _Event print("\n********** Transferred ManagedObject **********") - print(moEvent) + print(moEvent ?? "moEvent is nil") let eventModel = Event.model(from: moEvent!) print("\n********** Transferred Model **********") - print(eventModel) + print(eventModel ?? "eventModel is nil") } // MARK: - Helper diff --git a/Example/ExampleViewController.swift b/Example/ExampleViewController.swift index 897c1a8..7b7505f 100644 --- a/Example/ExampleViewController.swift +++ b/Example/ExampleViewController.swift @@ -17,7 +17,7 @@ class ExampleViewController: UITableViewController { // MARK: - Life cycle override func viewDidLoad() { super.viewDidLoad() - print(CoreDataManager.coreDataStorePath) + print(CoreDataManager.coreDataStorePath ?? "coreDataStorePath is nil") setupUI() loadData() @@ -29,11 +29,11 @@ class ExampleViewController: UITableViewController { } print("\n********** Transferred ManagedObject **********") - print(moOrg) + print(moOrg ?? "moOrg is nil") let orgModel = Organization.model(from: moOrg!) print("\n********** Transferred Model **********") - print(orgModel) + print(orgModel ?? "orgModel is nil") if let firstProject = orgModel?.projects?.first { print(firstProject) } diff --git a/Example/Info.plist b/Example/Info.plist index afd47e9..a90bf0a 100644 --- a/Example/Info.plist +++ b/Example/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.0.2 + 0.0.4 CFBundleSignature ???? CFBundleVersion - 2 + 4 LSRequiresIPhoneOS UILaunchStoryboardName diff --git a/Example/Models/ModelObject.swift b/Example/Models/ModelObject.swift index 14c8806..74a6672 100644 --- a/Example/Models/ModelObject.swift +++ b/Example/Models/ModelObject.swift @@ -10,6 +10,7 @@ import Foundation import ObjectMapper import ManagedObjectAdapter +@objcMembers class ModelObject: NSObject, Mappable, ManagedObjectSerializing { var id: String? var createdAt: Date? diff --git a/Example/ProjectsViewController.swift b/Example/ProjectsViewController.swift index 556ee04..8b16ee2 100644 --- a/Example/ProjectsViewController.swift +++ b/Example/ProjectsViewController.swift @@ -27,11 +27,11 @@ class ProjectsViewController: UITableViewController { } print("\n********** Transferred ManagedObject **********") - print(moProject) + print(moProject ?? "moProject is nil") let projectModel = Project.model(from: moProject!) print("\n********** Transferred Model **********") - print(projectModel) + print(projectModel ?? "projectModel is nil") if let firstEvent = projectModel?.events?.first { print(firstEvent) } diff --git a/Example/Transformers/ArrayValueTransformer.swift b/Example/Transformers/ArrayValueTransformer.swift index e2d8b23..85ffcab 100644 --- a/Example/Transformers/ArrayValueTransformer.swift +++ b/Example/Transformers/ArrayValueTransformer.swift @@ -9,7 +9,7 @@ import UIKit import ObjectMapper -class ArrayValueTransformer: ValueTransformer where T: Mappable { +class ArrayValueTransformer: ValueTransformer { override func transformedValue(_ value: Any?) -> Any? { if let value = value as? [T] { let jsonArray = value.toJSON() diff --git a/Example/Transformers/ObjectValueTransformer.swift b/Example/Transformers/ObjectValueTransformer.swift index e7f5ce7..8aab3c9 100644 --- a/Example/Transformers/ObjectValueTransformer.swift +++ b/Example/Transformers/ObjectValueTransformer.swift @@ -9,7 +9,7 @@ import UIKit import ObjectMapper -class ObjectValueTransformer: ValueTransformer where T: Mappable { +class ObjectValueTransformer: ValueTransformer { override func transformedValue(_ value: Any?) -> Any? { if let value = value as? T { let json = value.toJSON() diff --git a/ManagedObjectAdapter.xcodeproj/project.pbxproj b/ManagedObjectAdapter.xcodeproj/project.pbxproj index 89508c6..02d9300 100644 --- a/ManagedObjectAdapter.xcodeproj/project.pbxproj +++ b/ManagedObjectAdapter.xcodeproj/project.pbxproj @@ -195,12 +195,12 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = Teambition; TargetAttributes = { D3283C951D4880C500E1B445 = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; D3D39DED1D6AA90F00AECD76 = { CreatedOnToolsVersion = 7.3.1; @@ -208,7 +208,7 @@ }; D3D39DFD1D6AC3B600AECD76 = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; }; }; @@ -304,14 +304,20 @@ 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_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_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; @@ -355,14 +361,20 @@ 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_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_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; @@ -407,7 +419,8 @@ PRODUCT_NAME = ManagedObjectAdapter; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -426,7 +439,8 @@ PRODUCT_BUNDLE_IDENTIFIER = Teambition.ManagedObjectAdapter; PRODUCT_NAME = ManagedObjectAdapter; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -438,7 +452,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = Teambition.ManagedObjectAdapterTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -450,7 +464,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = Teambition.ManagedObjectAdapterTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -470,7 +484,8 @@ PRODUCT_NAME = ManagedObjectAdapter; SDKROOT = watchos; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; @@ -492,7 +507,8 @@ PRODUCT_NAME = ManagedObjectAdapter; SDKROOT = watchos; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; diff --git a/ManagedObjectAdapter.xcodeproj/xcshareddata/xcschemes/ManagedObjectAdapter iOS.xcscheme b/ManagedObjectAdapter.xcodeproj/xcshareddata/xcschemes/ManagedObjectAdapter iOS.xcscheme index aaf8523..718edbb 100644 --- a/ManagedObjectAdapter.xcodeproj/xcshareddata/xcschemes/ManagedObjectAdapter iOS.xcscheme +++ b/ManagedObjectAdapter.xcodeproj/xcshareddata/xcschemes/ManagedObjectAdapter iOS.xcscheme @@ -1,6 +1,6 @@ @@ -36,6 +37,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/ManagedObjectAdapter.xcodeproj/xcuserdata/hongxin.xcuserdatad/xcschemes/ManagedObjectAdapterTests.xcscheme b/ManagedObjectAdapter.xcodeproj/xcuserdata/hongxin.xcuserdatad/xcschemes/ManagedObjectAdapterTests.xcscheme index d0fc33a..23ff4fb 100644 --- a/ManagedObjectAdapter.xcodeproj/xcuserdata/hongxin.xcuserdatad/xcschemes/ManagedObjectAdapterTests.xcscheme +++ b/ManagedObjectAdapter.xcodeproj/xcuserdata/hongxin.xcuserdatad/xcschemes/ManagedObjectAdapterTests.xcscheme @@ -1,6 +1,6 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.0.2 + 0.0.4 CFBundleSignature ???? CFBundleVersion diff --git a/ManagedObjectAdapter/Supporting Files/Info-watchOS.plist b/ManagedObjectAdapter/Supporting Files/Info-watchOS.plist index 50325bf..826542e 100644 --- a/ManagedObjectAdapter/Supporting Files/Info-watchOS.plist +++ b/ManagedObjectAdapter/Supporting Files/Info-watchOS.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.0.2 + 0.0.4 CFBundleSignature ???? CFBundleVersion diff --git a/ManagedObjectAdapterTests/Info.plist b/ManagedObjectAdapterTests/Info.plist index 0507bbd..291b256 100644 --- a/ManagedObjectAdapterTests/Info.plist +++ b/ManagedObjectAdapterTests/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 0.0.1 + 0.0.4 CFBundleSignature ???? CFBundleVersion