From 06fde84a44e62c5dfb74aa849b8bae9990d5d61c Mon Sep 17 00:00:00 2001 From: Masayuki Ono Date: Sun, 1 Oct 2017 16:18:42 +0900 Subject: [PATCH 1/3] Update to Swift 4 --- NativePopup.xcodeproj/project.pbxproj | 22 ++++++++++++++----- .../xcschemes/NativePopup.xcscheme | 4 +++- NativePopup/NativePopup.swift | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/NativePopup.xcodeproj/project.pbxproj b/NativePopup.xcodeproj/project.pbxproj index 9dae418..ac6cd56 100644 --- a/NativePopup.xcodeproj/project.pbxproj +++ b/NativePopup.xcodeproj/project.pbxproj @@ -226,7 +226,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0830; - LastUpgradeCheck = 0830; + LastUpgradeCheck = 0910; ORGANIZATIONNAME = mono; TargetAttributes = { FE85338A1EAC7C92004BB756 = { @@ -351,7 +351,9 @@ 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_DOCUMENTATION_COMMENTS = YES; @@ -359,7 +361,11 @@ 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; @@ -405,7 +411,9 @@ 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_DOCUMENTATION_COMMENTS = YES; @@ -413,7 +421,11 @@ 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; @@ -458,7 +470,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -477,7 +489,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.mono0926.NativePopup; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -492,7 +504,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mono0926.Example; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -507,7 +519,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mono0926.Example; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; diff --git a/NativePopup.xcodeproj/xcshareddata/xcschemes/NativePopup.xcscheme b/NativePopup.xcodeproj/xcshareddata/xcschemes/NativePopup.xcscheme index befd8d7..bf50ac3 100644 --- a/NativePopup.xcodeproj/xcshareddata/xcschemes/NativePopup.xcscheme +++ b/NativePopup.xcodeproj/xcshareddata/xcschemes/NativePopup.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/NativePopup/NativePopup.swift b/NativePopup/NativePopup.swift index a96666f..524b54e 100644 --- a/NativePopup/NativePopup.swift +++ b/NativePopup/NativePopup.swift @@ -79,7 +79,7 @@ public class NativePopup: UIView { let style = NSMutableParagraphStyle() style.lineSpacing = 3 style.alignment = .center - $0.attributedText = NSAttributedString(string: $0.text ?? "", attributes: [NSParagraphStyleAttributeName: style]) + $0.attributedText = NSAttributedString(string: $0.text ?? "", attributes: [.paragraphStyle: style]) } effectView.addSubview(imageContentView) From fcf5fa479a9d8a8befbecf3105f24b6cf22e8d9b Mon Sep 17 00:00:00 2001 From: Masayuki Ono Date: Sun, 1 Oct 2017 16:20:16 +0900 Subject: [PATCH 2/3] Fix layout --- Example/Base.lproj/Main.storyboard | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Example/Base.lproj/Main.storyboard b/Example/Base.lproj/Main.storyboard index a0e94b1..fcd6e7f 100644 --- a/Example/Base.lproj/Main.storyboard +++ b/Example/Base.lproj/Main.storyboard @@ -1,10 +1,12 @@ - + - + + + @@ -12,10 +14,6 @@ - - - - @@ -24,7 +22,7 @@ - + @@ -117,13 +115,14 @@ - - + + - - - + + + + From ca56669427181d73cc742cbe2f8dce8db186b4e0 Mon Sep 17 00:00:00 2001 From: Masayuki Ono Date: Sun, 1 Oct 2017 16:21:11 +0900 Subject: [PATCH 3/3] Fix assertion error --- NativePopup/NativePopup.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NativePopup/NativePopup.swift b/NativePopup/NativePopup.swift index 524b54e..973584f 100644 --- a/NativePopup/NativePopup.swift +++ b/NativePopup/NativePopup.swift @@ -82,8 +82,8 @@ public class NativePopup: UIView { $0.attributedText = NSAttributedString(string: $0.text ?? "", attributes: [.paragraphStyle: style]) } - effectView.addSubview(imageContentView) - effectView.addSubview(titleLabel) + effectView.contentView.addSubview(imageContentView) + effectView.contentView.addSubview(titleLabel) imageContentView.heightAnchor.constraint(equalTo: imageContentView.widthAnchor, multiplier: 1).isActive = true imageContentView.heightAnchor.constraint(equalToConstant: 112).isActive = true @@ -99,7 +99,7 @@ public class NativePopup: UIView { if message?.isEmpty ?? true { titleLabel.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -bottomSpace).isActive = true } else { - effectView.addSubview(messageLabel) + effectView.contentView.addSubview(messageLabel) titleLabel.bottomAnchor.constraint(equalTo: messageLabel.topAnchor, constant: -6).isActive = true messageLabel.leftAnchor.constraint(equalTo: leftAnchor, constant: sideSpace).isActive = true messageLabel.rightAnchor.constraint(equalTo: rightAnchor, constant: -sideSpace).isActive = true