From ac8430284c9b6723fbef5fa48abc0d9acec70036 Mon Sep 17 00:00:00 2001 From: Marin Todorov Date: Mon, 16 Oct 2017 15:50:14 +0200 Subject: [PATCH 1/2] swift 4 branch -> dep on rc --- Example/Podfile | 15 ++++++++++++- .../RealmContent.xcodeproj/project.pbxproj | 22 ++++++++++++++----- .../xcschemes/RealmContent-Example.xcscheme | 4 +++- Example/RealmContent/Entities.swift | 8 +++---- RealmContent.podspec | 8 ++++--- .../Core/Classes/ContentListDataSource.swift | 4 ++-- .../Core/View/ContentViewController.swift | 8 +++---- RealmContent/Core/View/ImageContentCell.swift | 4 ++-- RealmContent/Core/View/TextContentCell.swift | 2 +- RealmContent/Entities/ContentElement.swift | 7 +++--- RealmContent/Entities/ContentPage.swift | 12 +++++----- .../View/MarkdownViewController.swift | 8 +++---- 12 files changed, 65 insertions(+), 37 deletions(-) diff --git a/Example/Podfile b/Example/Podfile index eff3684..6917453 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -1,7 +1,7 @@ use_frameworks! target 'RealmContent_Example' do - pod 'RealmSwift' + pod 'RealmSwift', '= 3.0.0-rc.1' pod 'RealmContent', :path => '../' pod 'RealmContent/Markdown', :path => '../' @@ -10,3 +10,16 @@ target 'RealmContent_Example' do inherit! :search_paths end end + +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + next unless target.name.include?("RealmSwift") || + target.name.include?("Kingfisher") || + target.name.include?("MMMarkdown") || + target.name.include?("RealmContent") + + config.build_settings['SWIFT_VERSION'] = '4.0' + end + end +end diff --git a/Example/RealmContent.xcodeproj/project.pbxproj b/Example/RealmContent.xcodeproj/project.pbxproj index 0a995d1..88b17e0 100644 --- a/Example/RealmContent.xcodeproj/project.pbxproj +++ b/Example/RealmContent.xcodeproj/project.pbxproj @@ -268,7 +268,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0820; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = CocoaPods; TargetAttributes = { 607FACCF1AFB9204008FA782 = { @@ -503,14 +503,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; @@ -550,14 +556,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; @@ -595,7 +607,7 @@ MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -612,7 +624,7 @@ MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -633,7 +645,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -650,7 +662,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; diff --git a/Example/RealmContent.xcodeproj/xcshareddata/xcschemes/RealmContent-Example.xcscheme b/Example/RealmContent.xcodeproj/xcshareddata/xcschemes/RealmContent-Example.xcscheme index 0fd7fd8..eb224b0 100644 --- a/Example/RealmContent.xcodeproj/xcshareddata/xcschemes/RealmContent-Example.xcscheme +++ b/Example/RealmContent.xcodeproj/xcshareddata/xcschemes/RealmContent-Example.xcscheme @@ -1,6 +1,6 @@ () } diff --git a/RealmContent.podspec b/RealmContent.podspec index 22a5c04..25a1d60 100644 --- a/RealmContent.podspec +++ b/RealmContent.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'RealmContent' - s.version = '0.2.3' + s.version = '0.2.4' s.summary = 'Realm powered content management system' s.description = <<-DESC @@ -21,8 +21,8 @@ Realm powered content management system providing built-in view controllers and s.frameworks = 'UIKit' - s.dependency 'RealmSwift', '~> 2' - s.dependency 'Kingfisher', '~> 3' + s.dependency 'RealmSwift', '= 3.0.0-rc.1' + s.dependency 'Kingfisher', '~> 4' s.dependency 'NSString+Color' s.default_subspec = 'Core' @@ -36,4 +36,6 @@ Realm powered content management system providing built-in view controllers and cs.source_files = 'RealmContent/Entities/*', 'RealmContent/Markdown/Classes/*', 'RealmContent/Markdown/View/*' end + + s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.0' } end diff --git a/RealmContent/Core/Classes/ContentListDataSource.swift b/RealmContent/Core/Classes/ContentListDataSource.swift index 50e34f2..ab245f2 100644 --- a/RealmContent/Core/Classes/ContentListDataSource.swift +++ b/RealmContent/Core/Classes/ContentListDataSource.swift @@ -102,7 +102,7 @@ public class ContentListDataSource: NSObject { // sort the pages by priority results = results!.sorted(byKeyPath: keyPriority, ascending: false) - resultsToken = results?.addNotificationBlock { [weak self] change in + resultsToken = results?.observe { [weak self] change in guard let view = self?.view else { return } if let tableView = view as? UITableView { tableView.reloadData() } if let collectionView = view as? UICollectionView { collectionView.reloadData() } @@ -124,7 +124,7 @@ public class ContentListDataSource: NSObject { SortDescriptor(keyPath: keyPriority, ascending: false) ]) - resultsToken = results?.addNotificationBlock { [weak self] change in + resultsToken = results?.observe { [weak self] change in guard let this = self else { return } switch change { diff --git a/RealmContent/Core/View/ContentViewController.swift b/RealmContent/Core/View/ContentViewController.swift index 75a7948..8987f32 100644 --- a/RealmContent/Core/View/ContentViewController.swift +++ b/RealmContent/Core/View/ContentViewController.swift @@ -88,14 +88,14 @@ public class ContentViewController: UIViewController, UITableViewDataSource, UIT } private func observe(page: ContentPage) { - pageUpdatesToken?.stop() - pageElementsUpdatesToken?.stop() + pageUpdatesToken?.invalidate() + pageElementsUpdatesToken?.invalidate() // load the page content populateFrom(page: page) // enable updates - pageUpdatesToken = page.addNotificationBlock() { [weak self] change in + pageUpdatesToken = page.observe() { [weak self] change in switch change { case .change(let properties): for p in properties { @@ -112,7 +112,7 @@ public class ContentViewController: UIViewController, UITableViewDataSource, UIT pageElementsUpdatesToken = page.elements .filter(NSPredicate(format: "type in %@", ContentElement.Kind.allRawValues())) - .addNotificationBlock(applyChanges) + .observe(applyChanges) } private func populateFrom(page: ContentPage) { diff --git a/RealmContent/Core/View/ImageContentCell.swift b/RealmContent/Core/View/ImageContentCell.swift index 78e023a..a449b3e 100644 --- a/RealmContent/Core/View/ImageContentCell.swift +++ b/RealmContent/Core/View/ImageContentCell.swift @@ -51,7 +51,7 @@ public class ImageContentCell: UITableViewCell { contentView.addSubview(img) heightConstraint = contentView.heightAnchor.constraint(equalToConstant: 20) - heightConstraint.priority = 500 + heightConstraint.priority = UILayoutPriority.defaultLow heightConstraint.isActive = true } @@ -124,7 +124,7 @@ public class ImageContentCell: UITableViewCell { return image } - internal func didTap() { + @objc internal func didTap() { guard let url = url else { return } img.alpha = 0.67 UIView.animate(withDuration: 0.33, animations: { diff --git a/RealmContent/Core/View/TextContentCell.swift b/RealmContent/Core/View/TextContentCell.swift index dbfe962..c135c7f 100644 --- a/RealmContent/Core/View/TextContentCell.swift +++ b/RealmContent/Core/View/TextContentCell.swift @@ -132,7 +132,7 @@ public class TextContentCell: UITableViewCell { // MARK: - private methods - internal func didTap() { + @objc internal func didTap() { guard let url = url else { return } label.alpha = 0.5 UIView.animate(withDuration: 0.33, animations: { diff --git a/RealmContent/Entities/ContentElement.swift b/RealmContent/Entities/ContentElement.swift index a80d2a3..a6a02ca 100644 --- a/RealmContent/Entities/ContentElement.swift +++ b/RealmContent/Entities/ContentElement.swift @@ -21,10 +21,9 @@ public class ContentElement: Object { } - public dynamic var type = "p" - public dynamic var content = "" - public dynamic var url: String? - + @objc public dynamic var type = "p" + @objc public dynamic var content = "" + @objc public dynamic var url: String? } extension ContentElement { diff --git a/RealmContent/Entities/ContentPage.swift b/RealmContent/Entities/ContentPage.swift index fb437dc..26f391c 100644 --- a/RealmContent/Entities/ContentPage.swift +++ b/RealmContent/Entities/ContentPage.swift @@ -10,13 +10,13 @@ import RealmSwift /// represents a single content page - news article, blog post, announcement, etc. public class ContentPage: Object { - public dynamic var title: String? + @objc public dynamic var title: String? public let elements = List() - public dynamic var priority = 0 - public dynamic var mainColor: String? - public dynamic var lang: String? - public dynamic var tag = "" - public dynamic var uuid = UUID().uuidString + @objc public dynamic var priority = 0 + @objc public dynamic var mainColor: String? + @objc public dynamic var lang: String? + @objc public dynamic var tag = "" + @objc public dynamic var uuid = UUID().uuidString override public static func indexedProperties() -> [String] { return ["priority", "tag"] diff --git a/RealmContent/Markdown/View/MarkdownViewController.swift b/RealmContent/Markdown/View/MarkdownViewController.swift index 202231f..7fadd86 100644 --- a/RealmContent/Markdown/View/MarkdownViewController.swift +++ b/RealmContent/Markdown/View/MarkdownViewController.swift @@ -39,14 +39,14 @@ public class MarkdownViewController: UIViewController { // dynamically update the content private func observe(page: ContentPage) { - pageUpdatesToken?.stop() - pageElementsUpdatesToken?.stop() + pageUpdatesToken?.invalidate() + pageElementsUpdatesToken?.invalidate() // load the page content populateFrom(page: page) // enable updates - pageUpdatesToken = page.addNotificationBlock { [weak self] change in + pageUpdatesToken = page.observe { [weak self] change in switch change { case .change: self?.populateFrom(page: page) case .deleted: self?.pageUpdatesToken = nil @@ -54,7 +54,7 @@ public class MarkdownViewController: UIViewController { } } - pageElementsUpdatesToken = page.elements.addNotificationBlock { [weak self] change in + pageElementsUpdatesToken = page.elements.observe { [weak self] change in switch change { case .update: self?.populateFrom(page: page) default: break From fae99aa0317b6114ccd3f0a690e5cbfef8e3ce4f Mon Sep 17 00:00:00 2001 From: Marin Todorov Date: Tue, 17 Oct 2017 11:30:36 +0200 Subject: [PATCH 2/2] swift 4 release --- Example/Podfile | 2 +- RealmContent.podspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Example/Podfile b/Example/Podfile index 6917453..5c8641a 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -1,7 +1,7 @@ use_frameworks! target 'RealmContent_Example' do - pod 'RealmSwift', '= 3.0.0-rc.1' + pod 'RealmSwift', '~> 3' pod 'RealmContent', :path => '../' pod 'RealmContent/Markdown', :path => '../' diff --git a/RealmContent.podspec b/RealmContent.podspec index 25a1d60..f92e624 100644 --- a/RealmContent.podspec +++ b/RealmContent.podspec @@ -21,7 +21,7 @@ Realm powered content management system providing built-in view controllers and s.frameworks = 'UIKit' - s.dependency 'RealmSwift', '= 3.0.0-rc.1' + s.dependency 'RealmSwift', '~> 3' s.dependency 'Kingfisher', '~> 4' s.dependency 'NSString+Color'