From 4d601218a2525a5bcb8e54badd4099dc699775c6 Mon Sep 17 00:00:00 2001 From: Maximilian Alexander Date: Tue, 3 Oct 2017 13:42:04 -0700 Subject: [PATCH 1/4] changing to swift 4 apis and semantics --- Cartfile | 2 +- NMessenger.podspec | 2 +- Podfile | 2 +- .../MessageGroups.xcodeproj/project.pbxproj | 66 +++++++++++++++---- examples/MessageGroups/Podfile | 4 +- nMessenger.xcodeproj/project.pbxproj | 61 +++++++++++++---- .../xcschemes/nMessenger-iOS.xcscheme | 4 +- .../ImageContent/ImageContentNode.swift | 2 +- .../NetworkImageContentNode.swift | 2 +- .../TextContent/TextContentNode.swift | 30 ++++----- .../TypingIndicatorContent.swift | 14 ++-- .../Indicators/HeadLoadingIndicator.swift | 6 +- .../Indicators/MessageSentIndicator.swift | 6 +- .../MessageCell/MessageGroup.swift | 2 +- .../MessageCell/MessageNode.swift | 4 +- .../Components/CameraViewController.swift | 16 ++--- .../InputBarView/NMessengerBarView.swift | 8 +-- .../Messenger/Components/NMessenger.swift | 4 +- .../Messenger/NMessengerViewController.swift | 4 +- .../Source/Utilities/UIFont+N1Fonts.swift | 24 +++---- 20 files changed, 170 insertions(+), 93 deletions(-) diff --git a/Cartfile b/Cartfile index 8068945..7ef6695 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "facebook/AsyncDisplayKit" "1.9.92" +github "texturegroup/texture" diff --git a/NMessenger.podspec b/NMessenger.podspec index 75bff8a..0e9a157 100644 --- a/NMessenger.podspec +++ b/NMessenger.podspec @@ -133,5 +133,5 @@ NMessenger is a fast, lightweight messenger component built on AsyncDisplaykit a s.requires_arc = true # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } - s.dependency "Texture", "2.3.2" + s.dependency "Texture", "2.5" end diff --git a/Podfile b/Podfile index a3be80c..979a9fe 100644 --- a/Podfile +++ b/Podfile @@ -6,7 +6,7 @@ target 'nMessenger' do use_frameworks! # Pods for nMessenger - pod 'Texture', '2.3.2' + pod 'Texture', '2.5' target 'nMessengerTests' do inherit! :search_paths diff --git a/examples/MessageGroups/MessageGroups.xcodeproj/project.pbxproj b/examples/MessageGroups/MessageGroups.xcodeproj/project.pbxproj index 9125804..b779989 100644 --- a/examples/MessageGroups/MessageGroups.xcodeproj/project.pbxproj +++ b/examples/MessageGroups/MessageGroups.xcodeproj/project.pbxproj @@ -237,22 +237,22 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = "Ebay Inc."; TargetAttributes = { 197D8B0A1D64BA50004630AE = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; ProvisioningStyle = Manual; }; 197D8B1E1D64BA51004630AE = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; TestTargetID = 197D8B0A1D64BA50004630AE; }; 197D8B291D64BA51004630AE = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; TestTargetID = 197D8B0A1D64BA50004630AE; }; }; @@ -310,13 +310,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-MessageGroupsTests-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; 3E9E3F11630A3F4FDDF5E069 /* [CP] Copy Pods Resources */ = { @@ -385,13 +388,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-MessageGroupsUITests-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; D538704BF25A1A41EF7E2A0B /* [CP] Embed Pods Frameworks */ = { @@ -400,9 +406,22 @@ files = ( ); inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-MessageGroups/Pods-MessageGroups-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/LoremIpsum/LoremIpsum.framework", + "${BUILT_PRODUCTS_DIR}/NMessenger/NMessenger.framework", + "${BUILT_PRODUCTS_DIR}/PINCache/PINCache.framework", + "${BUILT_PRODUCTS_DIR}/PINOperation/PINOperation.framework", + "${BUILT_PRODUCTS_DIR}/PINRemoteImage/PINRemoteImage.framework", + "${BUILT_PRODUCTS_DIR}/Texture/AsyncDisplayKit.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/LoremIpsum.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/NMessenger.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PINCache.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PINOperation.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PINRemoteImage.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AsyncDisplayKit.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -415,13 +434,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-MessageGroups-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; FB608C1E2E4141DD12C62F4B /* [CP] Embed Pods Frameworks */ = { @@ -504,14 +526,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; @@ -552,14 +580,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; @@ -597,7 +631,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = ebay.MessageGroups; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -613,7 +648,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = ebay.MessageGroups; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -626,7 +662,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = ebay.MessageGroupsTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MessageGroups.app/MessageGroups"; }; name = Debug; @@ -640,7 +677,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = ebay.MessageGroupsTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MessageGroups.app/MessageGroups"; }; name = Release; @@ -653,7 +691,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = ebay.MessageGroupsUITests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; TEST_TARGET_NAME = MessageGroups; }; name = Debug; @@ -666,7 +705,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = ebay.MessageGroupsUITests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; TEST_TARGET_NAME = MessageGroups; }; name = Release; diff --git a/examples/MessageGroups/Podfile b/examples/MessageGroups/Podfile index f906993..52f1157 100644 --- a/examples/MessageGroups/Podfile +++ b/examples/MessageGroups/Podfile @@ -5,7 +5,7 @@ target 'MessageGroups' do # Comment this line if you're not using Swift and don't want to use dynamic frameworks use_frameworks! - swift_version = '3.0' + swift_version = '4.0' # Pods for MessageGroups pod 'NMessenger', :path => '../..' @@ -26,7 +26,7 @@ end post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| - config.build_settings['SWIFT_VERSION'] = '3.0' + config.build_settings['SWIFT_VERSION'] = '4.0' end end end diff --git a/nMessenger.xcodeproj/project.pbxproj b/nMessenger.xcodeproj/project.pbxproj index fc873c1..2444383 100755 --- a/nMessenger.xcodeproj/project.pbxproj +++ b/nMessenger.xcodeproj/project.pbxproj @@ -1220,7 +1220,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = "Ebay Inc."; TargetAttributes = { 616280241D8196F700D1F510 = { @@ -1601,13 +1601,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-nMessenger-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; 72DD7E364423637E2B452014 /* [CP] Embed Pods Frameworks */ = { @@ -1616,9 +1619,18 @@ files = ( ); inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-nMessenger/Pods-nMessenger-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/PINCache/PINCache.framework", + "${BUILT_PRODUCTS_DIR}/PINOperation/PINOperation.framework", + "${BUILT_PRODUCTS_DIR}/PINRemoteImage/PINRemoteImage.framework", + "${BUILT_PRODUCTS_DIR}/Texture/AsyncDisplayKit.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PINCache.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PINOperation.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PINRemoteImage.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AsyncDisplayKit.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -1631,13 +1643,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-nMessenger-iOS-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; 92EE1EB1707ECEA825593FBA /* [CP] Copy Pods Resources */ = { @@ -1661,13 +1676,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-nMessengerTests-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; B63E1D299EF994DC6556DA08 /* [CP] Copy Pods Resources */ = { @@ -1706,13 +1724,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-nMessengerUITests-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; F7B47B6A4B98158750DAB112 /* [CP] Embed Pods Frameworks */ = { @@ -1897,7 +1918,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.ebay.nMessenger-iOS"; PRODUCT_NAME = NMessenger; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -1924,7 +1945,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.ebay.nMessenger-iOS"; PRODUCT_NAME = NMessenger; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -1939,14 +1960,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; @@ -1974,6 +2001,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -1987,14 +2015,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; @@ -2015,6 +2049,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -2033,7 +2068,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.ebay.nMessenger; PRODUCT_NAME = nMessenger; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -2050,7 +2085,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.ebay.nMessenger; PRODUCT_NAME = nMessenger; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -2063,7 +2098,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.ebay.nMessengerTests; PRODUCT_NAME = nMessengerTests; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/nMessenger.app/nMessenger"; }; name = Debug; @@ -2077,7 +2112,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.ebay.nMessengerTests; PRODUCT_NAME = nMessengerTests; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/nMessenger.app/nMessenger"; }; name = Release; @@ -2090,7 +2125,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.ebay.nMessengerUITests; PRODUCT_NAME = nMessengerUITests; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TEST_TARGET_NAME = nMessenger; }; name = Debug; @@ -2103,7 +2138,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.ebay.nMessengerUITests; PRODUCT_NAME = nMessengerUITests; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TEST_TARGET_NAME = nMessenger; }; name = Release; diff --git a/nMessenger.xcodeproj/xcshareddata/xcschemes/nMessenger-iOS.xcscheme b/nMessenger.xcodeproj/xcshareddata/xcschemes/nMessenger-iOS.xcscheme index 082c76a..96c286e 100644 --- a/nMessenger.xcodeproj/xcshareddata/xcschemes/nMessenger-iOS.xcscheme +++ b/nMessenger.xcodeproj/xcshareddata/xcschemes/nMessenger-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/nMessenger/Source/MessageNodes/ContentNodes/ImageContent/ImageContentNode.swift b/nMessenger/Source/MessageNodes/ContentNodes/ImageContent/ImageContentNode.swift index c6b7a92..c5244c5 100755 --- a/nMessenger/Source/MessageNodes/ContentNodes/ImageContent/ImageContentNode.swift +++ b/nMessenger/Source/MessageNodes/ContentNodes/ImageContent/ImageContentNode.swift @@ -118,7 +118,7 @@ open class ImageContentNode: ContentNode { Copy Selector for UIMenuController Puts the node's image on UIPasteboard */ - open func copySelector() { + @objc open func copySelector() { if let image = self.image { UIPasteboard.general.image = image } diff --git a/nMessenger/Source/MessageNodes/ContentNodes/NetworkImageContent/NetworkImageContentNode.swift b/nMessenger/Source/MessageNodes/ContentNodes/NetworkImageContent/NetworkImageContentNode.swift index 205fba4..4955a77 100755 --- a/nMessenger/Source/MessageNodes/ContentNodes/NetworkImageContent/NetworkImageContentNode.swift +++ b/nMessenger/Source/MessageNodes/ContentNodes/NetworkImageContent/NetworkImageContentNode.swift @@ -123,7 +123,7 @@ open class NetworkImageContentNode: ContentNode,ASNetworkImageNodeDelegate { Copy Selector for UIMenuController Puts the node's image on UIPasteboard */ - open func copySelector() { + @objc open func copySelector() { if let image = self.networkImageMessageNode.image { UIPasteboard.general.image = image } diff --git a/nMessenger/Source/MessageNodes/ContentNodes/TextContent/TextContentNode.swift b/nMessenger/Source/MessageNodes/ContentNodes/TextContent/TextContentNode.swift index 1c00743..e1362e4 100755 --- a/nMessenger/Source/MessageNodes/ContentNodes/TextContent/TextContentNode.swift +++ b/nMessenger/Source/MessageNodes/ContentNodes/TextContent/TextContentNode.swift @@ -118,7 +118,7 @@ open class TextContentNode: ContentNode,ASTextNodeDelegate { textMessageNode.delegate = self textMessageNode.isUserInteractionEnabled = true textMessageNode.linkAttributeNames = ["LinkAttribute","PhoneNumberAttribute"] - let fontAndSizeAndTextColor = [ NSFontAttributeName: self.isIncomingMessage ? incomingTextFont : outgoingTextFont, NSForegroundColorAttributeName: self.isIncomingMessage ? incomingTextColor : outgoingTextColor] + let fontAndSizeAndTextColor = [ NSAttributedStringKey.font: self.isIncomingMessage ? incomingTextFont : outgoingTextFont, NSAttributedStringKey.foregroundColor: self.isIncomingMessage ? incomingTextColor : outgoingTextColor] let outputString = NSMutableAttributedString(string: textMessageString, attributes: fontAndSizeAndTextColor ) let types: NSTextCheckingResult.CheckingType = [.link, .phoneNumber] let detector = try! NSDataDetector(types: types.rawValue) @@ -126,15 +126,15 @@ open class TextContentNode: ContentNode,ASTextNodeDelegate { for match in matches { if let url = match.url { - outputString.addAttribute("LinkAttribute", value: url, range: match.range) - outputString.addAttribute(NSUnderlineStyleAttributeName, value: NSUnderlineStyle.styleSingle.rawValue, range: match.range) - outputString.addAttribute(NSForegroundColorAttributeName, value: UIColor.blue, range: match.range) + outputString.addAttribute(NSAttributedStringKey(rawValue: "LinkAttribute"), value: url, range: match.range) + outputString.addAttribute(NSAttributedStringKey.underlineStyle, value: NSUnderlineStyle.styleSingle.rawValue, range: match.range) + outputString.addAttribute(NSAttributedStringKey.foregroundColor, value: UIColor.blue, range: match.range) } if let phoneNumber = match.phoneNumber { - outputString.addAttribute("PhoneNumberAttribute", value: phoneNumber, range: match.range) - outputString.addAttribute(NSUnderlineStyleAttributeName, value: NSUnderlineStyle.styleSingle.rawValue, range: match.range) - outputString.addAttribute(NSForegroundColorAttributeName, value: UIColor.blue, range: match.range) + outputString.addAttribute(NSAttributedStringKey(rawValue: "PhoneNumberAttribute"), value: phoneNumber, range: match.range) + outputString.addAttribute(NSAttributedStringKey.underlineStyle, value: NSUnderlineStyle.styleSingle.rawValue, range: match.range) + outputString.addAttribute(NSAttributedStringKey.foregroundColor, value: UIColor.blue, range: match.range) } } self.textMessageNode.attributedText = outputString @@ -147,7 +147,7 @@ open class TextContentNode: ContentNode,ASTextNodeDelegate { /** Updates the attributed string to the correct incoming/outgoing settings and lays out the component again*/ fileprivate func updateAttributedText() { let tmpString = NSMutableAttributedString(attributedString: self.textMessageNode.attributedText!) - tmpString.addAttributes([NSForegroundColorAttributeName: isIncomingMessage ? incomingTextColor : outgoingTextColor, NSFontAttributeName: isIncomingMessage ? incomingTextFont : outgoingTextFont], range: NSMakeRange(0, tmpString.length)) + tmpString.addAttributes([NSAttributedStringKey.foregroundColor: isIncomingMessage ? incomingTextColor : outgoingTextColor, NSAttributedStringKey.font: isIncomingMessage ? incomingTextFont : outgoingTextFont], range: NSMakeRange(0, tmpString.length)) self.textMessageNode.attributedText = tmpString setNeedsLayout() @@ -216,14 +216,14 @@ open class TextContentNode: ContentNode,ASTextNodeDelegate { if let tmpString = self.textMessageNode.attributedText { let attributedString = NSMutableAttributedString(attributedString: tmpString) - attributedString.addAttribute(NSBackgroundColorAttributeName, value: UIColor.lightGray, range: textRange) + attributedString.addAttribute(NSAttributedStringKey.backgroundColor, value: UIColor.lightGray, range: textRange) self.textMessageNode.attributedText = attributedString UIApplication.shared.openURL(value as! URL) delay(0.4) { if let tmpString = self.textMessageNode.attributedText { let attributedString = NSMutableAttributedString(attributedString: tmpString) - attributedString.removeAttribute(NSBackgroundColorAttributeName, range: textRange) + attributedString.removeAttribute(NSAttributedStringKey.backgroundColor, range: textRange) self.textMessageNode.attributedText = attributedString } } @@ -264,7 +264,7 @@ open class TextContentNode: ContentNode,ASTextNodeDelegate { if let tmpString = self.textMessageNode.attributedText { let attributedString = NSMutableAttributedString(attributedString: tmpString) - attributedString.addAttribute(NSBackgroundColorAttributeName, value: UIColor.lightGray, range: textRange) + attributedString.addAttribute(NSAttributedStringKey.backgroundColor, value: UIColor.lightGray, range: textRange) self.textMessageNode.attributedText = attributedString let optionMenu = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) @@ -306,7 +306,7 @@ open class TextContentNode: ContentNode,ASTextNodeDelegate { if let tmpString = self.textMessageNode.attributedText { let attributedString = NSMutableAttributedString(attributedString: tmpString) - attributedString.removeAttribute(NSBackgroundColorAttributeName, range: textRange) + attributedString.removeAttribute(NSAttributedStringKey.backgroundColor, range: textRange) self.textMessageNode.attributedText = attributedString } } @@ -318,7 +318,7 @@ open class TextContentNode: ContentNode,ASTextNodeDelegate { if let tmpString = self.textMessageNode.attributedText { let attributedString = NSMutableAttributedString(attributedString: tmpString) - attributedString.addAttribute(NSBackgroundColorAttributeName, value: UIColor.lightGray, range: textRange) + attributedString.addAttribute(NSAttributedStringKey.backgroundColor, value: UIColor.lightGray, range: textRange) self.textMessageNode.attributedText = attributedString let optionMenu = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) @@ -372,7 +372,7 @@ open class TextContentNode: ContentNode,ASTextNodeDelegate { if let tmpString = self.textMessageNode.attributedText { let attributedString = NSMutableAttributedString(attributedString: tmpString) - attributedString.removeAttribute(NSBackgroundColorAttributeName, range: textRange) + attributedString.removeAttribute(NSAttributedStringKey.backgroundColor, range: textRange) self.textMessageNode.attributedText = attributedString } } @@ -416,7 +416,7 @@ open class TextContentNode: ContentNode,ASTextNodeDelegate { /** Copy Selector for UIMenuController */ - open func copySelector() { + @objc open func copySelector() { UIPasteboard.general.string = self.textMessageNode.attributedText!.string } diff --git a/nMessenger/Source/MessageNodes/ContentNodes/TypingIndicatorContent/TypingIndicatorContent.swift b/nMessenger/Source/MessageNodes/ContentNodes/TypingIndicatorContent/TypingIndicatorContent.swift index 439a033..457b1bf 100755 --- a/nMessenger/Source/MessageNodes/ContentNodes/TypingIndicatorContent/TypingIndicatorContent.swift +++ b/nMessenger/Source/MessageNodes/ContentNodes/TypingIndicatorContent/TypingIndicatorContent.swift @@ -29,15 +29,15 @@ open class TypingIndicatorContent: ContentNode { } - open override func visibilityDidChange(_ isVisible: Bool) { - if(isVisible){ - self.gifNode.removeFromSupernode(); - addIndicators() - }else{ - self.gifNode.removeFromSupernode(); - } + open override func didEnterVisibleState() { + self.gifNode.removeFromSupernode(); + addIndicators() } + open override func didExitVisibleState() { + self.gifNode.removeFromSupernode(); + } + func addIndicators(){ let imageNames = ["loadBubble_0038_Layer-1", "loadBubble_0037_Layer-2", "loadBubble_0036_Layer-3", "loadBubble_0035_Layer-4", "loadBubble_0034_Layer-5", "loadBubble_0033_Layer-6", "loadBubble_0032_Layer-7", "loadBubble_0031_Layer-8", "loadBubble_0030_Layer-9", "loadBubble_0029_Layer-10", "loadBubble_0028_Layer-11", "loadBubble_0027_Layer-12", "loadBubble_0026_Layer-13", "loadBubble_0025_Layer-14", "loadBubble_0024_Layer-15", "loadBubble_0023_Layer-16", "loadBubble_0022_Layer-17", "loadBubble_0021_Layer-18", "loadBubble_0020_Layer-19", "loadBubble_0019_Layer-20", "loadBubble_0018_Layer-21", "loadBubble_0017_Layer-22", "loadBubble_0016_Layer-23", "loadBubble_0015_Layer-24", "loadBubble_0014_Layer-25", "loadBubble_0013_Layer-26", "loadBubble_0012_Layer-27", "loadBubble_0011_Layer-28", "loadBubble_0010_Layer-29", "loadBubble_0009_Layer-30", "loadBubble_0008_Layer-31", "loadBubble_0007_Layer-32", "loadBubble_0006_Layer-33", "loadBubble_0005_Layer-34", "loadBubble_0004_Layer-35", "loadBubble_0003_Layer-36", "loadBubble_0002_Layer-37", "loadBubble_0001_Layer-38", "loadBubble_0000_Layer-39"]; diff --git a/nMessenger/Source/MessageNodes/Indicators/HeadLoadingIndicator.swift b/nMessenger/Source/MessageNodes/Indicators/HeadLoadingIndicator.swift index c9ac17a..d274b41 100755 --- a/nMessenger/Source/MessageNodes/Indicators/HeadLoadingIndicator.swift +++ b/nMessenger/Source/MessageNodes/Indicators/HeadLoadingIndicator.swift @@ -42,9 +42,9 @@ open class HeadLoadingIndicator: GeneralMessengerCell { text.attributedText = NSAttributedString( string: "Loading…", attributes: [ - NSFontAttributeName: UIFont.systemFont(ofSize: 12), - NSForegroundColorAttributeName: UIColor.lightGray, - NSKernAttributeName: -0.3 + NSAttributedStringKey.font: UIFont.systemFont(ofSize: 12), + NSAttributedStringKey.foregroundColor: UIColor.lightGray, + NSAttributedStringKey.kern: -0.3 ]) addSubnode(spinner) } diff --git a/nMessenger/Source/MessageNodes/Indicators/MessageSentIndicator.swift b/nMessenger/Source/MessageNodes/Indicators/MessageSentIndicator.swift index 9abb690..eba3cf9 100755 --- a/nMessenger/Source/MessageNodes/Indicators/MessageSentIndicator.swift +++ b/nMessenger/Source/MessageNodes/Indicators/MessageSentIndicator.swift @@ -38,9 +38,9 @@ open class MessageSentIndicator: GeneralMessengerCell { text.attributedText = NSAttributedString( string: newValue != nil ? newValue! : "", attributes: [ - NSFontAttributeName: UIFont.systemFont(ofSize: 14), - NSForegroundColorAttributeName: UIColor.lightGray, - NSKernAttributeName: -0.3 + NSAttributedStringKey.font: UIFont.systemFont(ofSize: 14), + NSAttributedStringKey.foregroundColor: UIColor.lightGray, + NSAttributedStringKey.kern: -0.3 ]) self.setNeedsLayout() } get { diff --git a/nMessenger/Source/MessageNodes/MessageCell/MessageGroup.swift b/nMessenger/Source/MessageNodes/MessageCell/MessageGroup.swift index 8423c37..893f28d 100755 --- a/nMessenger/Source/MessageNodes/MessageCell/MessageGroup.swift +++ b/nMessenger/Source/MessageNodes/MessageCell/MessageGroup.swift @@ -429,7 +429,7 @@ extension MessageGroup { /** Notifies the delegate that the avatar was clicked */ - public func avatarClicked() { + @objc public func avatarClicked() { self.delegate?.avatarClicked?(self) } } diff --git a/nMessenger/Source/MessageNodes/MessageCell/MessageNode.swift b/nMessenger/Source/MessageNodes/MessageCell/MessageNode.swift index b0a0599..729a5df 100755 --- a/nMessenger/Source/MessageNodes/MessageCell/MessageNode.swift +++ b/nMessenger/Source/MessageNodes/MessageCell/MessageNode.swift @@ -267,7 +267,7 @@ open class MessageNode: GeneralMessengerCell { - parameter recognizer: Must be an UITapGestureRecognizer. Can be be overritten when subclassed */ - open func messageNodeLongPressSelector(_ recognizer: UITapGestureRecognizer) { + @objc open func messageNodeLongPressSelector(_ recognizer: UITapGestureRecognizer) { contentNode?.messageNodeLongPressSelector(recognizer) } } @@ -277,7 +277,7 @@ extension MessageNode { /** Notifies the delegate that the avatar was clicked */ - public func avatarClicked() + @objc public func avatarClicked() { self.delegate?.avatarClicked?(self) } diff --git a/nMessenger/Source/Messenger/Components/CameraViewController.swift b/nMessenger/Source/Messenger/Components/CameraViewController.swift index 0d3935c..be4075d 100755 --- a/nMessenger/Source/Messenger/Components/CameraViewController.swift +++ b/nMessenger/Source/Messenger/Components/CameraViewController.swift @@ -47,7 +47,7 @@ open class CameraViewController: UIImagePickerController, UIImagePickerControlle //SelectionType type of selection the user is making - defualt is camera open var selection = SelectionType.camera //AVAuthorizationStatus authorization status for the camera - open var cameraAuthStatus = AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) + open var cameraAuthStatus = AVCaptureDevice.authorizationStatus(for: AVMediaType.video) //PHAuthorizationStatus authorization status for the library open var photoLibAuthStatus = PHPhotoLibrary.authorizationStatus() //MARK: Private Parameters @@ -112,7 +112,7 @@ open class CameraViewController: UIImagePickerController, UIImagePickerControlle } else { - self.cameraAuthStatus = AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) + self.cameraAuthStatus = AVCaptureDevice.authorizationStatus(for: AVMediaType.video) if(photoLibAuthStatus != PHAuthorizationStatus.authorized) { self.requestPhotoLibraryPermissions({ (granted) in if(granted) { @@ -301,7 +301,7 @@ open class CameraViewController: UIImagePickerController, UIImagePickerControlle /** Changes between camera view and gallery view */ - open func changePictureMode() { + @objc open func changePictureMode() { switch selection { case .camera: @@ -345,19 +345,19 @@ open class CameraViewController: UIImagePickerController, UIImagePickerControlle /** Closes the view */ - open func exitButtonPressed() { + @objc open func exitButtonPressed() { cameraDelegate?.cameraCancelSelection() } /** Takes a photo */ - open func capture(_ sender: UIButton) { + @objc open func capture(_ sender: UIButton) { self.takePicture() } /** Enables/disables flash */ - open func toggleFlash(_ sender: UIButton) { + @objc open func toggleFlash(_ sender: UIButton) { if (sender.isSelected == false) { sender.tintColor = UIColor.n1ActionBlueColor() sender.isSelected = true @@ -380,7 +380,7 @@ open class CameraViewController: UIImagePickerController, UIImagePickerControlle /** Changes the camera from front to back */ - open func flipCamera(_ sender: UIButton) { + @objc open func flipCamera(_ sender: UIButton) { if (sender.isSelected == false) { sender.tintColor = UIColor.n1ActionBlueColor() sender.isSelected = true @@ -416,7 +416,7 @@ open class CameraViewController: UIImagePickerController, UIImagePickerControlle - parameter completion: Must be (granted : Bool) -> Void */ open func requestAccessForCamera(_ completion:@escaping (_ granted : Bool) -> Void) { - AVCaptureDevice.requestAccess(forMediaType: AVMediaTypeVideo) { (granted) in + AVCaptureDevice.requestAccess(for: AVMediaType.video) { (granted) in completion(granted) } } diff --git a/nMessenger/Source/Messenger/Components/InputBarView/NMessengerBarView.swift b/nMessenger/Source/Messenger/Components/InputBarView/NMessengerBarView.swift index 2c2b94f..fd06511 100755 --- a/nMessenger/Source/Messenger/Components/InputBarView/NMessengerBarView.swift +++ b/nMessenger/Source/Messenger/Components/InputBarView/NMessengerBarView.swift @@ -157,7 +157,7 @@ open class NMessengerBarView: InputBarView, UITextViewDelegate, CameraViewDelega textWidth -= 2.0 * textView.textContainer.lineFragmentPadding - let boundingRect: CGRect = newText.boundingRect(with: CGSize(width: textWidth, height: 0), options: [NSStringDrawingOptions.usesLineFragmentOrigin,NSStringDrawingOptions.usesFontLeading], attributes: [NSFontAttributeName: textView.font!], context: nil) + let boundingRect: CGRect = newText.boundingRect(with: CGSize(width: textWidth, height: 0), options: [NSStringDrawingOptions.usesLineFragmentOrigin,NSStringDrawingOptions.usesFontLeading], attributes: [NSAttributedStringKey.font: textView.font!], context: nil) let numberOfLines = boundingRect.height / textView.font!.lineHeight; @@ -218,14 +218,14 @@ open class NMessengerBarView: InputBarView, UITextViewDelegate, CameraViewDelega if(authStatus != AVAuthorizationStatus.authorized) { cameraVC.isCameraPermissionGranted({(granted) in if(granted) { - self.cameraVC.cameraAuthStatus = AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) + self.cameraVC.cameraAuthStatus = AVCaptureDevice.authorizationStatus(for: AVMediaType.video) DispatchQueue.main.async(execute: { () -> Void in self.controller.present(self.cameraVC, animated: true, completion: nil) }) } else { - self.cameraVC.cameraAuthStatus = AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) + self.cameraVC.cameraAuthStatus = AVCaptureDevice.authorizationStatus(for: AVMediaType.video) if(photoLibAuthStatus != PHAuthorizationStatus.authorized) { self.cameraVC.requestPhotoLibraryPermissions({ (granted) in if(granted) { @@ -254,7 +254,7 @@ open class NMessengerBarView: InputBarView, UITextViewDelegate, CameraViewDelega } }) } else {//also check if photo gallery permissions are granted - self.cameraVC.cameraAuthStatus = AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) + self.cameraVC.cameraAuthStatus = AVCaptureDevice.authorizationStatus(for: AVMediaType.video) DispatchQueue.main.async(execute: { () -> Void in self.controller.present(self.cameraVC, animated: true, completion: nil) }) diff --git a/nMessenger/Source/Messenger/Components/NMessenger.swift b/nMessenger/Source/Messenger/Components/NMessenger.swift index f1397fe..e75e715 100755 --- a/nMessenger/Source/Messenger/Components/NMessenger.swift +++ b/nMessenger/Source/Messenger/Components/NMessenger.swift @@ -115,7 +115,7 @@ open class NMessenger: UIView { messengerNode.view.separatorStyle = UITableViewCellSeparatorStyle.none messengerNode.view.allowsSelection = false messengerNode.view.showsVerticalScrollIndicator = false - messengerNode.view.automaticallyAdjustsContentOffset = true + messengerNode.automaticallyAdjustsContentOffset = true } //MARK: Public functions @@ -514,7 +514,7 @@ open class NMessenger: UIView { */ fileprivate func shouldHandleBatchFetch(_ offset: CGPoint) { if doesBatchFetch && self.messengerDelegate.batchFetchContent != nil { - if shouldBatchFetch(self.state.batchFetchLock, direction: self.state.scrollDirection, bounds: messengerNode.view.bounds, contentSize: messengerNode.view.contentSize, targetOffset: offset, leadingScreens: messengerNode.view.leadingScreensForBatching) { + if shouldBatchFetch(self.state.batchFetchLock, direction: self.state.scrollDirection, bounds: messengerNode.view.bounds, contentSize: messengerNode.view.contentSize, targetOffset: offset, leadingScreens: messengerNode.leadingScreensForBatching) { //lock and fetch self.state.batchFetchLock.beginBatchFetching() diff --git a/nMessenger/Source/Messenger/NMessengerViewController.swift b/nMessenger/Source/Messenger/NMessengerViewController.swift index 00ce354..62c5b0a 100755 --- a/nMessenger/Source/Messenger/NMessengerViewController.swift +++ b/nMessenger/Source/Messenger/NMessengerViewController.swift @@ -192,7 +192,7 @@ open class NMessengerViewController: UIViewController, UITextViewDelegate, NMess /** Moves InputBarView up and down accoridng to the location of the keyboard */ - func keyboardNotification(_ notification: Notification) { + @objc func keyboardNotification(_ notification: Notification) { if let userInfo = (notification as NSNotification).userInfo { let endFrame = (userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue let duration:TimeInterval = (userInfo[UIKeyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue ?? 0 @@ -232,7 +232,7 @@ open class NMessengerViewController: UIViewController, UITextViewDelegate, NMess /** Closes the messenger on swipe on InputBarView */ - func respondToSwipeGesture(_ gesture: UIGestureRecognizer) { + @objc func respondToSwipeGesture(_ gesture: UIGestureRecognizer) { self.inputBarView.textInputView.resignFirstResponder() } diff --git a/nMessenger/Source/Utilities/UIFont+N1Fonts.swift b/nMessenger/Source/Utilities/UIFont+N1Fonts.swift index 52d1081..6691ffa 100755 --- a/nMessenger/Source/Utilities/UIFont+N1Fonts.swift +++ b/nMessenger/Source/Utilities/UIFont+N1Fonts.swift @@ -17,50 +17,50 @@ import UIKit */ extension UIFont { class func n1H1Font() -> UIFont { - return UIFont.systemFont(ofSize: 28.0, weight: UIFontWeightThin) + return UIFont.systemFont(ofSize: 28.0, weight: UIFont.Weight.thin) } class func n1H2Font() -> UIFont { - return UIFont.systemFont(ofSize: 20.0, weight: UIFontWeightLight) + return UIFont.systemFont(ofSize: 20.0, weight: UIFont.Weight.light) } class func n1H3Font() -> UIFont { - return UIFont.systemFont(ofSize: 18.0, weight: UIFontWeightRegular) + return UIFont.systemFont(ofSize: 18.0, weight: UIFont.Weight.regular) } class func n1LinkFont() -> UIFont { - return UIFont.systemFont(ofSize: 16.0, weight: UIFontWeightSemibold) + return UIFont.systemFont(ofSize: 16.0, weight: UIFont.Weight.semibold) } class func n1TextStyleFont() -> UIFont { - return UIFont.systemFont(ofSize: 16.0, weight: UIFontWeightRegular) + return UIFont.systemFont(ofSize: 16.0, weight: UIFont.Weight.regular) } class func n1B1Font() -> UIFont { - return UIFont.systemFont(ofSize: 16.0, weight: UIFontWeightRegular) + return UIFont.systemFont(ofSize: 16.0, weight: UIFont.Weight.regular) } class func n1TextStyle3Font() -> UIFont { - return UIFont.systemFont(ofSize: 12.0, weight: UIFontWeightBold) + return UIFont.systemFont(ofSize: 12.0, weight: UIFont.Weight.bold) } class func n1TextStyle3MiniFont() -> UIFont { - return UIFont.systemFont(ofSize: 8.0, weight: UIFontWeightBold) + return UIFont.systemFont(ofSize: 8.0, weight: UIFont.Weight.bold) } class func n1TextStyle2Font() -> UIFont { - return UIFont.systemFont(ofSize: 14.0, weight: UIFontWeightRegular) + return UIFont.systemFont(ofSize: 14.0, weight: UIFont.Weight.regular) } class func n1B2Font() -> UIFont { - return UIFont.systemFont(ofSize: 14.0, weight: UIFontWeightRegular) + return UIFont.systemFont(ofSize: 14.0, weight: UIFont.Weight.regular) } class func n1TextStyle4Font() -> UIFont { - return UIFont.systemFont(ofSize: 14.0, weight: UIFontWeightLight) + return UIFont.systemFont(ofSize: 14.0, weight: UIFont.Weight.light) } class func n1CaptionFont() -> UIFont { - return UIFont.systemFont(ofSize: 12.0, weight: UIFontWeightMedium) + return UIFont.systemFont(ofSize: 12.0, weight: UIFont.Weight.medium) } } From 8d53b1ad23cb842844aa4be01907f3f6325b9158 Mon Sep 17 00:00:00 2001 From: Maximilian Alexander Date: Fri, 10 Nov 2017 21:28:29 -0800 Subject: [PATCH 2/4] adding austin zhengs fixes --- .../MessageGroups.xcodeproj/project.pbxproj | 2 ++ .../AppIcon.appiconset/Contents.json | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/examples/MessageGroups/MessageGroups.xcodeproj/project.pbxproj b/examples/MessageGroups/MessageGroups.xcodeproj/project.pbxproj index b779989..fbe4b5a 100644 --- a/examples/MessageGroups/MessageGroups.xcodeproj/project.pbxproj +++ b/examples/MessageGroups/MessageGroups.xcodeproj/project.pbxproj @@ -567,6 +567,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -614,6 +615,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; diff --git a/examples/MessageGroups/MessageGroups/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/MessageGroups/MessageGroups/Assets.xcassets/AppIcon.appiconset/Contents.json index 36d2c80..d8db8d6 100644 --- a/examples/MessageGroups/MessageGroups/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/examples/MessageGroups/MessageGroups/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,5 +1,15 @@ { "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "29x29", @@ -30,6 +40,16 @@ "size" : "60x60", "scale" : "3x" }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, { "idiom" : "ipad", "size" : "29x29", @@ -59,6 +79,16 @@ "idiom" : "ipad", "size" : "76x76", "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" } ], "info" : { From c88460e06e0d35ce3278997e4cbb8e5493f3d0af Mon Sep 17 00:00:00 2001 From: Maximilian Alexander Date: Fri, 10 Nov 2017 21:30:18 -0800 Subject: [PATCH 3/4] moving to swift 4 apis --- Podfile | 2 +- .../ContentNodes/ContentNode.swift | 59 +++++++++++-------- .../TextContent/TextContentNode.swift | 2 +- .../Source/Utilities/UIFont+N1Fonts.swift | 1 + 4 files changed, 38 insertions(+), 26 deletions(-) diff --git a/Podfile b/Podfile index 979a9fe..8c36908 100644 --- a/Podfile +++ b/Podfile @@ -6,7 +6,7 @@ target 'nMessenger' do use_frameworks! # Pods for nMessenger - pod 'Texture', '2.5' + pod 'Texture', '2.5.1' target 'nMessengerTests' do inherit! :search_paths diff --git a/nMessenger/Source/MessageNodes/ContentNodes/ContentNode.swift b/nMessenger/Source/MessageNodes/ContentNodes/ContentNode.swift index 4597427..ea7bd1b 100755 --- a/nMessenger/Source/MessageNodes/ContentNodes/ContentNode.swift +++ b/nMessenger/Source/MessageNodes/ContentNodes/ContentNode.swift @@ -34,7 +34,7 @@ open class ContentNode: ASDisplayNode { */ open var isIncomingMessage = true { didSet { - self.backgroundBubble?.bubbleColor = isIncomingMessage ? bubbleConfiguration.getIncomingColor() : bubbleConfiguration.getOutgoingColor() + self.backgroundBubble?.bubbleColor = isIncomingMessage ? bubbleConfiguration.getIncomingColor() : bubbleConfiguration.getOutgoingColor() self.setNeedsLayout() } @@ -93,27 +93,40 @@ open class ContentNode: ASDisplayNode { } } } - - //MARK: Override AsycDisaplyKit Methods + + //MARK: Override Texture (AsyncDisplayKit) Methods + + // Return the self object as the optional parameter. + open override func drawParameters(forAsyncLayer layer: _ASDisplayLayer) -> NSObjectProtocol? { + return self + } /** - Draws the content in the bubble. This is called on a background thread. + Draw the content in the bubble. This is called on a background thread. */ - open func drawRect(_ bounds: CGRect, withParameters parameters: NSObjectProtocol!, - isCancelled isCancelledBlock: asdisplaynode_iscancelled_block_t, isRasterizing: Bool) { - self.isOpaque = false + + open override class func draw(_ bounds: CGRect, withParameters parameters: Any?, + isCancelled isCancelledBlock: asdisplaynode_iscancelled_block_t, isRasterizing: Bool) { + guard let instance = parameters as? ContentNode else { + return + } + instance.isOpaque = false if !isRasterizing { - self.calculateLayerPropertiesThatFit(bounds) + instance.calculateLayerPropertiesThatFit(bounds) //call the main queue DispatchQueue.main.async { - self.layoutLayers() + guard let bubble = instance.backgroundBubble else { + return + } + self.layoutLayers(with: bubble, isIncomingMessage: instance.isIncomingMessage) } } } + //MARK: Override AsycDisaplyKit helper methods /** @@ -122,25 +135,23 @@ open class ContentNode: ASDisplayNode { */ open func calculateLayerPropertiesThatFit(_ bounds: CGRect) { if let backgroundBubble = self.backgroundBubble { - backgroundBubble.sizeToBounds(bounds) + backgroundBubble.sizeToBounds(bounds) } } /** Called on the main thread */ - open func layoutLayers() { - if let backgroundBubble = self.backgroundBubble { - backgroundBubble.createLayer() - - //TODO: this is slightly hacky, will need to rethink - if isIncomingMessage { - CATransaction.begin() - CATransaction.setDisableActions(true) - backgroundBubble.layer.transform = CATransform3DTranslate(CATransform3DMakeScale(-1, 1, 1), -backgroundBubble.calculatedBounds.width, 0, 0) - backgroundBubble.maskLayer.transform = CATransform3DTranslate(CATransform3DMakeScale(-1, 1, 1), -backgroundBubble.calculatedBounds.width, 0, 0) - CATransaction.commit() - } + open class func layoutLayers(with backgroundBubble: Bubble, isIncomingMessage: Bool) { + backgroundBubble.createLayer() + + //TODO: this is slightly hacky, will need to rethink + if isIncomingMessage { + CATransaction.begin() + CATransaction.setDisableActions(true) + backgroundBubble.layer.transform = CATransform3DTranslate(CATransform3DMakeScale(-1, 1, 1), -backgroundBubble.calculatedBounds.width, 0, 0) + backgroundBubble.maskLayer.transform = CATransform3DTranslate(CATransform3DMakeScale(-1, 1, 1), -backgroundBubble.calculatedBounds.width, 0, 0) + CATransaction.commit() } } @@ -155,7 +166,7 @@ open class ContentNode: ASDisplayNode { execute: closure ) } - + //MARK: UITapGestureRecognizer Selector @@ -165,5 +176,5 @@ open class ContentNode: ASDisplayNode { */ open func messageNodeLongPressSelector(_ recognizer: UITapGestureRecognizer) { } - + } diff --git a/nMessenger/Source/MessageNodes/ContentNodes/TextContent/TextContentNode.swift b/nMessenger/Source/MessageNodes/ContentNodes/TextContent/TextContentNode.swift index e1362e4..09bab4d 100755 --- a/nMessenger/Source/MessageNodes/ContentNodes/TextContent/TextContentNode.swift +++ b/nMessenger/Source/MessageNodes/ContentNodes/TextContent/TextContentNode.swift @@ -122,7 +122,7 @@ open class TextContentNode: ContentNode,ASTextNodeDelegate { let outputString = NSMutableAttributedString(string: textMessageString, attributes: fontAndSizeAndTextColor ) let types: NSTextCheckingResult.CheckingType = [.link, .phoneNumber] let detector = try! NSDataDetector(types: types.rawValue) - let matches = detector.matches(in: textMessageString, options: [], range: NSMakeRange(0, textMessageString.characters.count)) + let matches = detector.matches(in: textMessageString, options: [], range: NSMakeRange(0, textMessageString.count)) for match in matches { if let url = match.url { diff --git a/nMessenger/Source/Utilities/UIFont+N1Fonts.swift b/nMessenger/Source/Utilities/UIFont+N1Fonts.swift index 6691ffa..444fe3a 100755 --- a/nMessenger/Source/Utilities/UIFont+N1Fonts.swift +++ b/nMessenger/Source/Utilities/UIFont+N1Fonts.swift @@ -64,3 +64,4 @@ extension UIFont { return UIFont.systemFont(ofSize: 12.0, weight: UIFont.Weight.medium) } } + From aa71c026afa4e2aaf0c8842b3069413bceda920f Mon Sep 17 00:00:00 2001 From: Maximilian Alexander Date: Tue, 28 Nov 2017 09:27:47 -1000 Subject: [PATCH 4/4] fixing layout from artanisdesign suggestion --- nMessenger/Source/MessageNodes/MessageCell/MessageGroup.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nMessenger/Source/MessageNodes/MessageCell/MessageGroup.swift b/nMessenger/Source/MessageNodes/MessageCell/MessageGroup.swift index 893f28d..dcfed13 100755 --- a/nMessenger/Source/MessageNodes/MessageCell/MessageGroup.swift +++ b/nMessenger/Source/MessageNodes/MessageCell/MessageGroup.swift @@ -199,6 +199,8 @@ open class MessageGroup: GeneralMessengerCell { //Need to set height in cell node as of ASDK 2.x self.frame.size.height = context.finalFrame(for: self.messageTable).size.height + self.cellPadding.bottom + self.cellPadding.top + self.setNeedsLayout() + //wait for layout animation let dispatchTime: DispatchTime = DispatchTime.now() + Double(Int64(self.animationDelay)*1000 * Int64(NSEC_PER_MSEC)) / Double(NSEC_PER_SEC) DispatchQueue.main.asyncAfter(deadline: dispatchTime) {