From 8599f9c06015e7c4ec3edc6c7a16fa264cea223e Mon Sep 17 00:00:00 2001 From: CHEN Xian-an Date: Sun, 31 Mar 2019 17:58:43 +0800 Subject: [PATCH] Swift 5 --- .gitignore | 2 ++ .../project.pbxproj | 4 ++-- .../AppDelegate.swift | 2 +- .../ViewController.swift | 2 +- Demo-ObjC/Demo-ObjC.xcodeproj/project.pbxproj | 8 ++++++-- Demo/Demo.xcodeproj/project.pbxproj | 16 +++++++++------- Demo/Demo/AppDelegate.swift | 2 +- .../Assets.xcassets/Image.imageset/Contents.json | 3 --- Demo/Demo/ViewController.swift | 2 +- MenuItemKit.podspec | 4 ++-- MenuItemKit.xcodeproj/project.pbxproj | 15 ++++++++------- .../xcshareddata/xcschemes/MenuItemKit.xcscheme | 2 +- MenuItemKit/Swizzlings.swift | 4 ++-- README.md | 2 +- 14 files changed, 37 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index 5b6607e..2bc5dec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store + # Xcode # # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore @@ -17,6 +18,7 @@ DerivedData/ *.perspectivev3 !default.perspectivev3 xcuserdata/ +xcshareddata/ ## Other *.moved-aside diff --git a/AutoPopupMenuContorllerDemo/AutoPopupMenuContorllerDemo.xcodeproj/project.pbxproj b/AutoPopupMenuContorllerDemo/AutoPopupMenuContorllerDemo.xcodeproj/project.pbxproj index 795a437..d3ac143 100644 --- a/AutoPopupMenuContorllerDemo/AutoPopupMenuContorllerDemo.xcodeproj/project.pbxproj +++ b/AutoPopupMenuContorllerDemo/AutoPopupMenuContorllerDemo.xcodeproj/project.pbxproj @@ -344,7 +344,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = lazyapps.AutoPopupMenuContorllerDemo; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -358,7 +358,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = lazyapps.AutoPopupMenuContorllerDemo; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; diff --git a/AutoPopupMenuContorllerDemo/AutoPopupMenuContorllerDemo/AppDelegate.swift b/AutoPopupMenuContorllerDemo/AutoPopupMenuContorllerDemo/AppDelegate.swift index 6c56a85..8d3bb67 100644 --- a/AutoPopupMenuContorllerDemo/AutoPopupMenuContorllerDemo/AppDelegate.swift +++ b/AutoPopupMenuContorllerDemo/AutoPopupMenuContorllerDemo/AppDelegate.swift @@ -12,7 +12,7 @@ import UIKit class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true } diff --git a/AutoPopupMenuContorllerDemo/AutoPopupMenuContorllerDemo/ViewController.swift b/AutoPopupMenuContorllerDemo/AutoPopupMenuContorllerDemo/ViewController.swift index ab2070f..e8c9a02 100644 --- a/AutoPopupMenuContorllerDemo/AutoPopupMenuContorllerDemo/ViewController.swift +++ b/AutoPopupMenuContorllerDemo/AutoPopupMenuContorllerDemo/ViewController.swift @@ -28,7 +28,7 @@ class ViewController: UIViewController { } let colorImage = UIImage(named: "ColorImage") - let colorImageItem = UIMenuItem(title: "Image", image: colorImage) { [weak self] _ in + let colorImageItem = UIMenuItem(title: "ColorImage", image: colorImage) { [weak self] _ in self?.showAlertWithTitle("color image item tapped") } diff --git a/Demo-ObjC/Demo-ObjC.xcodeproj/project.pbxproj b/Demo-ObjC/Demo-ObjC.xcodeproj/project.pbxproj index 528a6d1..ad91cc2 100644 --- a/Demo-ObjC/Demo-ObjC.xcodeproj/project.pbxproj +++ b/Demo-ObjC/Demo-ObjC.xcodeproj/project.pbxproj @@ -159,7 +159,7 @@ E0EFAEAD1C4AC6A000334D78 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = lazyapps; TargetAttributes = { E0EFAEB41C4AC6A000334D78 = { @@ -169,7 +169,7 @@ }; buildConfigurationList = E0EFAEB01C4AC6A000334D78 /* Build configuration list for PBXProject "Demo-ObjC" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -266,6 +266,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -320,6 +321,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -368,6 +370,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "Demo-ObjC/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -380,6 +383,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "Demo-ObjC/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; diff --git a/Demo/Demo.xcodeproj/project.pbxproj b/Demo/Demo.xcodeproj/project.pbxproj index ff1dbb4..d9687d4 100644 --- a/Demo/Demo.xcodeproj/project.pbxproj +++ b/Demo/Demo.xcodeproj/project.pbxproj @@ -145,19 +145,19 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = lazyapps; TargetAttributes = { E0EFAE6E1C4A050000334D78 = { CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 0900; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; }; }; }; buildConfigurationList = E0EFAE6A1C4A050000334D78 /* Build configuration list for PBXProject "Demo" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -253,6 +253,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -310,6 +311,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -361,13 +363,13 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = Demo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.lazyapps.MenuItemKitDemo-Swift"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -376,14 +378,14 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = Demo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.lazyapps.MenuItemKitDemo-Swift"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/Demo/Demo/AppDelegate.swift b/Demo/Demo/AppDelegate.swift index c2ab1fb..dc980a8 100644 --- a/Demo/Demo/AppDelegate.swift +++ b/Demo/Demo/AppDelegate.swift @@ -12,7 +12,7 @@ import UIKit class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { return true } diff --git a/Demo/Demo/Assets.xcassets/Image.imageset/Contents.json b/Demo/Demo/Assets.xcassets/Image.imageset/Contents.json index 3d99b9a..0056190 100644 --- a/Demo/Demo/Assets.xcassets/Image.imageset/Contents.json +++ b/Demo/Demo/Assets.xcassets/Image.imageset/Contents.json @@ -8,8 +8,5 @@ "info" : { "version" : 1, "author" : "xcode" - }, - "properties" : { - "template-rendering-intent" : "original" } } \ No newline at end of file diff --git a/Demo/Demo/ViewController.swift b/Demo/Demo/ViewController.swift index 00f8369..0164ed1 100644 --- a/Demo/Demo/ViewController.swift +++ b/Demo/Demo/ViewController.swift @@ -29,7 +29,7 @@ class ViewController: UIViewController { } let colorImage = UIImage(named: "ColorImage") - let colorImageItem = UIMenuItem(title: "Image", image: colorImage) { [weak self] _ in + let colorImageItem = UIMenuItem(title: "ColorImage", image: colorImage) { [weak self] _ in self?.showAlertWithTitle("color image item tapped") } diff --git a/MenuItemKit.podspec b/MenuItemKit.podspec index 248ba75..9eacaa4 100644 --- a/MenuItemKit.podspec +++ b/MenuItemKit.podspec @@ -1,7 +1,7 @@ # coding: utf-8 Pod::Spec.new do |s| s.name = "MenuItemKit" - s.version = "3.1.3" + s.version = "3.2.0" s.summary = "MenuItemKit provides image and closure(block) support for UIMenuItem." s.author = "CHEN Xian’an " s.homepage = "https://github.com/cxa/MenuItemKit" @@ -11,5 +11,5 @@ Pod::Spec.new do |s| s.source_files = 'MenuItemKit/*.{h,m,swift}' s.requires_arc = true s.frameworks = 'UIKit' - s.swift_version= "4.2" + s.swift_version= "5.0" end diff --git a/MenuItemKit.xcodeproj/project.pbxproj b/MenuItemKit.xcodeproj/project.pbxproj index 3f98698..83d016c 100644 --- a/MenuItemKit.xcodeproj/project.pbxproj +++ b/MenuItemKit.xcodeproj/project.pbxproj @@ -158,12 +158,12 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = lazyapps; TargetAttributes = { E0EFAE491C49F99300334D78 = { CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 0900; + LastSwiftMigration = 1020; }; E0EFAE531C49F99400334D78 = { CreatedOnToolsVersion = 7.3; @@ -173,10 +173,11 @@ }; buildConfigurationList = E0EFAE441C49F99300334D78 /* Build configuration list for PBXProject "MenuItemKit" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = E0EFAE401C49F99300334D78; productRefGroup = E0EFAE4B1C49F99300334D78 /* Products */; @@ -242,6 +243,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -302,6 +304,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -368,8 +371,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -390,8 +392,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/MenuItemKit.xcodeproj/xcshareddata/xcschemes/MenuItemKit.xcscheme b/MenuItemKit.xcodeproj/xcshareddata/xcschemes/MenuItemKit.xcscheme index 6c06a51..5cba09d 100644 --- a/MenuItemKit.xcodeproj/xcshareddata/xcschemes/MenuItemKit.xcscheme +++ b/MenuItemKit.xcodeproj/xcshareddata/xcschemes/MenuItemKit.xcscheme @@ -1,6 +1,6 @@ UIMenuItem? { guard title?.hasSuffix(imageItemIdetifier) == true else { return nil } - return menuItems?.lazy.filter { $0.title == title }.first + return menuItems?.first { $0.title == title } } func findMenuItemBySelector(_ selector: Selector?) -> UIMenuItem? { guard let selector = selector else { return nil } - return menuItems?.lazy.filter { sel_isEqual($0.action, selector) }.first + return menuItems?.first { sel_isEqual($0.action, selector) } } func findMenuItemBySelector(_ selector: String?) -> UIMenuItem? { diff --git a/README.md b/README.md index 4f0a148..4f1f9da 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Check dome projects (both Swift and Objective-C are provided) for more details. ## Advance Usage -For menu items out of your control, you can use `static func installTo(responder: UIResponder, shouldShowForAction: @escaping (Selector, Bool) -> Bool = default)` to configure items visibility. Check [AutoPopupMenuContorllerDemo](AutoPopupMenuContorllerDemo). +For menu items being out of your control, you can use `static func installTo(responder: UIResponder, shouldShowForAction: @escaping (Selector, Bool) -> Bool = default)` to configure items visibility. Check [AutoPopupMenuContorllerDemo](AutoPopupMenuContorllerDemo). ## About Me