Skip to content

Commit

Permalink
Swift 5
Browse files Browse the repository at this point in the history
  • Loading branch information
cxa committed Mar 31, 2019
1 parent 222f102 commit 8599f9c
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store

# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
Expand All @@ -17,6 +18,7 @@ DerivedData/
*.perspectivev3
!default.perspectivev3
xcuserdata/
xcshareddata/

## Other
*.moved-aside
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
8 changes: 6 additions & 2 deletions Demo-ObjC/Demo-ObjC.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
E0EFAEAD1C4AC6A000334D78 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0930;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = lazyapps;
TargetAttributes = {
E0EFAEB41C4AC6A000334D78 = {
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand All @@ -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";
Expand Down
16 changes: 9 additions & 7 deletions Demo/Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand Down
2 changes: 1 addition & 1 deletion Demo/Demo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 0 additions & 3 deletions Demo/Demo/Assets.xcassets/Image.imageset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "original"
}
}
2 changes: 1 addition & 1 deletion Demo/Demo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
4 changes: 2 additions & 2 deletions MenuItemKit.podspec
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"
s.homepage = "https://github.com/cxa/MenuItemKit"
Expand All @@ -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
15 changes: 8 additions & 7 deletions MenuItemKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 2 additions & 2 deletions MenuItemKit/Swizzlings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ private extension UIMenuController {

func findImageItemByTitle(_ title: String?) -> 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? {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8599f9c

Please sign in to comment.