From 6c270e9e32353c03944fd6c4bd6c8dcc2e4debf0 Mon Sep 17 00:00:00 2001 From: Menno Lovink Date: Wed, 29 Jan 2020 15:03:11 +0100 Subject: [PATCH 1/7] boyscout - make sure app builds again and doesn't enounter error `openURL is unavailable in application extensions for iOS` note: this is a breaking change since it requires `open(_:open:options)` to be implemented in app delegate --- Example/Podfile.lock | 4 ++-- Example/markymark/AppDelegate.swift | 9 +++++++++ README.md | 5 ++--- .../URL Openers/DefaultURLOpener.swift | 8 +++++++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 9498070..c85d8c2 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -7,7 +7,7 @@ DEPENDENCIES: - SwiftLint SPEC REPOS: - https://github.com/cocoapods/specs.git: + https://github.com/CocoaPods/Specs.git: - SwiftLint EXTERNAL SOURCES: @@ -20,4 +20,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: ac26bbd0b2acca180dc458845f0951e758f55812 -COCOAPODS: 1.7.2 +COCOAPODS: 1.8.4 diff --git a/Example/markymark/AppDelegate.swift b/Example/markymark/AppDelegate.swift index 9b825ff..47f8828 100644 --- a/Example/markymark/AppDelegate.swift +++ b/Example/markymark/AppDelegate.swift @@ -17,4 +17,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { return true } + + func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { + if #available(iOS 10.0, *) { + app.open(url, options: [:], completionHandler: nil) + } else { + app.openURL(url) + } + return true + } } diff --git a/README.md b/README.md index c5560c2..2fd0d95 100644 --- a/README.md +++ b/README.md @@ -287,9 +287,8 @@ markDownTextView.onDidConvertMarkDownItemToView = { } ``` -### Changing link behavior - -By default Markymark opens URL's using `UIApplication.shared.open(url:)`. Markymark allows changing this behavior by passing a custom URLOpener, an object that comforms to the `URLOpener` protocol. +### Link behavior +By default Markymark opens URL's using `UIApplication.shared.delegate.open(_:open:options)`. links will only be openened when this method is implemented. Markymark allows changing this behavior by passing a custom URLOpener, an object that conforms to the `URLOpener` protocol. ```swift let markDownView = MarkDownTextView() diff --git a/markymark/Classes/Default implementations/URL Openers/DefaultURLOpener.swift b/markymark/Classes/Default implementations/URL Openers/DefaultURLOpener.swift index 9c8fee8..e8683d3 100644 --- a/markymark/Classes/Default implementations/URL Openers/DefaultURLOpener.swift +++ b/markymark/Classes/Default implementations/URL Openers/DefaultURLOpener.swift @@ -21,6 +21,12 @@ public class DefaultURLOpener: URLOpener { } public func open(url: URL) { - _ = sharedApplication?.openURL(url) + guard let sharedApplication = sharedApplication else { return } + + if #available(iOS 10, *) { + _ = sharedApplication.delegate?.application?(sharedApplication, open: url, options: [:]) + } else { + _ = sharedApplication.delegate?.application?(sharedApplication, handleOpen: url) + } } } From e8f5061f0534aa3d49406e450979d4bbc9c1af41 Mon Sep 17 00:00:00 2001 From: Menno Lovink Date: Wed, 29 Jan 2020 15:11:35 +0100 Subject: [PATCH 2/7] ref #98 - add Package.swift --- .gitignore | 1 + Package.swift | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 Package.swift diff --git a/.gitignore b/.gitignore index 8bcddc7..e39d86e 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ Carthage # `pod install` in .travis.yml # # Pods/ +.swiftpm diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..8949eaf --- /dev/null +++ b/Package.swift @@ -0,0 +1,23 @@ +// swift-tools-version:5.0 + +import PackageDescription + +let package = Package( + name: "Marky-Mark", + platforms: [ + .iOS("8.0"), + ], + products: [ + .library( + name: "markymark", + targets: ["markymark"]), + ], + dependencies: [], + targets: [ + .target( + name: "markymark", + dependencies: [], + path: "markymark"), + ], + swiftLanguageVersions: [.v5] +) From caf86971d8b175fc5d4e9c945722c6f8dad97de9 Mon Sep 17 00:00:00 2001 From: Menno Lovink Date: Wed, 29 Jan 2020 15:11:53 +0100 Subject: [PATCH 3/7] ref #98 - add missing UIKit imports --- .../Attributed label/MarkdownAttributedLabel.swift | 1 + markymark/Classes/Default implementations/MarkDownTextView.swift | 1 + .../Default implementations/URL Openers/DefaultURLOpener.swift | 1 + .../Block/HeaderAttributedStringLayoutBlockBuilder.swift | 1 + .../Block/ParagraphAttributedStringLayoutBlockBuilder.swift | 1 + .../Block/QuoteAttributedStringLayoutBlockBuilder.swift | 1 + .../Inline/InlineAttributedStringLayoutBlockBuilder.swift | 1 + .../Classes/Styling/Protocols/LetterSpacingStylingRule.swift | 1 + .../Classes/Styling/Protocols/MinimumHeightStylingRule.swift | 1 + 9 files changed, 9 insertions(+) diff --git a/markymark/Classes/Default implementations/Attributed label/MarkdownAttributedLabel.swift b/markymark/Classes/Default implementations/Attributed label/MarkdownAttributedLabel.swift index 132d757..31a800d 100644 --- a/markymark/Classes/Default implementations/Attributed label/MarkdownAttributedLabel.swift +++ b/markymark/Classes/Default implementations/Attributed label/MarkdownAttributedLabel.swift @@ -6,6 +6,7 @@ // import Foundation +import UIKit @IBDesignable open class MarkdownAttributedLabel: AttributedInteractiveLabel { diff --git a/markymark/Classes/Default implementations/MarkDownTextView.swift b/markymark/Classes/Default implementations/MarkDownTextView.swift index 31bf164..9adbe70 100644 --- a/markymark/Classes/Default implementations/MarkDownTextView.swift +++ b/markymark/Classes/Default implementations/MarkDownTextView.swift @@ -6,6 +6,7 @@ // import Foundation +import UIKit public enum MarkDownConfiguration { case view diff --git a/markymark/Classes/Default implementations/URL Openers/DefaultURLOpener.swift b/markymark/Classes/Default implementations/URL Openers/DefaultURLOpener.swift index e8683d3..75f8f42 100644 --- a/markymark/Classes/Default implementations/URL Openers/DefaultURLOpener.swift +++ b/markymark/Classes/Default implementations/URL Openers/DefaultURLOpener.swift @@ -6,6 +6,7 @@ // import Foundation +import UIKit public class DefaultURLOpener: URLOpener { diff --git a/markymark/Classes/Layout Builders/AttributedString/Block Builders/Block/HeaderAttributedStringLayoutBlockBuilder.swift b/markymark/Classes/Layout Builders/AttributedString/Block Builders/Block/HeaderAttributedStringLayoutBlockBuilder.swift index 1e661f8..76b76e8 100644 --- a/markymark/Classes/Layout Builders/AttributedString/Block Builders/Block/HeaderAttributedStringLayoutBlockBuilder.swift +++ b/markymark/Classes/Layout Builders/AttributedString/Block Builders/Block/HeaderAttributedStringLayoutBlockBuilder.swift @@ -7,6 +7,7 @@ // import Foundation +import UIKit class HeaderAttributedStringLayoutBlockBuilder: InlineAttributedStringLayoutBlockBuilder { diff --git a/markymark/Classes/Layout Builders/AttributedString/Block Builders/Block/ParagraphAttributedStringLayoutBlockBuilder.swift b/markymark/Classes/Layout Builders/AttributedString/Block Builders/Block/ParagraphAttributedStringLayoutBlockBuilder.swift index bf83705..cd34eb8 100644 --- a/markymark/Classes/Layout Builders/AttributedString/Block Builders/Block/ParagraphAttributedStringLayoutBlockBuilder.swift +++ b/markymark/Classes/Layout Builders/AttributedString/Block Builders/Block/ParagraphAttributedStringLayoutBlockBuilder.swift @@ -7,6 +7,7 @@ // import Foundation +import UIKit class ParagraphAttributedStringLayoutBlockBuilder: InlineAttributedStringLayoutBlockBuilder { diff --git a/markymark/Classes/Layout Builders/AttributedString/Block Builders/Block/QuoteAttributedStringLayoutBlockBuilder.swift b/markymark/Classes/Layout Builders/AttributedString/Block Builders/Block/QuoteAttributedStringLayoutBlockBuilder.swift index 2407e9d..e6d98dc 100644 --- a/markymark/Classes/Layout Builders/AttributedString/Block Builders/Block/QuoteAttributedStringLayoutBlockBuilder.swift +++ b/markymark/Classes/Layout Builders/AttributedString/Block Builders/Block/QuoteAttributedStringLayoutBlockBuilder.swift @@ -7,6 +7,7 @@ // import Foundation +import UIKit class QuoteAttributedStringLayoutBlockBuilder: InlineAttributedStringLayoutBlockBuilder { diff --git a/markymark/Classes/Layout Builders/AttributedString/Block Builders/Inline/InlineAttributedStringLayoutBlockBuilder.swift b/markymark/Classes/Layout Builders/AttributedString/Block Builders/Inline/InlineAttributedStringLayoutBlockBuilder.swift index 26d659a..48f18ad 100644 --- a/markymark/Classes/Layout Builders/AttributedString/Block Builders/Inline/InlineAttributedStringLayoutBlockBuilder.swift +++ b/markymark/Classes/Layout Builders/AttributedString/Block Builders/Inline/InlineAttributedStringLayoutBlockBuilder.swift @@ -7,6 +7,7 @@ // import Foundation +import UIKit class InlineAttributedStringLayoutBlockBuilder: LayoutBlockBuilder { diff --git a/markymark/Classes/Styling/Protocols/LetterSpacingStylingRule.swift b/markymark/Classes/Styling/Protocols/LetterSpacingStylingRule.swift index 0c62c45..4c4ac84 100644 --- a/markymark/Classes/Styling/Protocols/LetterSpacingStylingRule.swift +++ b/markymark/Classes/Styling/Protocols/LetterSpacingStylingRule.swift @@ -6,6 +6,7 @@ // import Foundation +import UIKit public protocol LetterSpacingStylingRule: ItemStyling { var letterSpacing: CGFloat? { get } diff --git a/markymark/Classes/Styling/Protocols/MinimumHeightStylingRule.swift b/markymark/Classes/Styling/Protocols/MinimumHeightStylingRule.swift index a5cd698..82ba68a 100644 --- a/markymark/Classes/Styling/Protocols/MinimumHeightStylingRule.swift +++ b/markymark/Classes/Styling/Protocols/MinimumHeightStylingRule.swift @@ -4,6 +4,7 @@ // import Foundation +import UIKit public protocol MinimumHeightStylingRule: ItemStyling { From 21c707dfedbdaae6976585b768292d7a2b9d6af3 Mon Sep 17 00:00:00 2001 From: Menno Lovink Date: Wed, 29 Jan 2020 16:58:32 +0100 Subject: [PATCH 4/7] ref #98 - attempt building created SPM within travis --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3a6227b..a8cc22b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ os: osx language: swift xcode_project: MarkyMark.xcodeproj xcode_scheme: markymark_Tests -osx_image: xcode10 +osx_image: xcode11.3 podfile: Example/Podfile before_install: - gem install cocoapods # Since Travis is not always on latest version @@ -11,6 +11,8 @@ before_install: - pod install --project-directory=Example script: - set -o pipefail && xcodebuild test -workspace Example/markymark.xcworkspace -scheme markymark-Example -destination 'platform=iOS Simulator,name=iPhone 8' | xcpretty +- swift package generate-xcodeproj +- xcodebuild build -sdk iphoneos -scheme 'Marky-Mark-Package' -project Marky-Mark.xcodeproj # - pod lib lint after_success: - bash <(curl -s https://codecov.io/bash) From 585cbcd47c43ef2d0506c72d43e7d03422752f17 Mon Sep 17 00:00:00 2001 From: Menno Lovink Date: Wed, 29 Jan 2020 17:55:14 +0100 Subject: [PATCH 5/7] ref #98 - (temporarily) remove `pod repo update` in order to increase build speed --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a8cc22b..92ccb44 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ osx_image: xcode11.3 podfile: Example/Podfile before_install: - gem install cocoapods # Since Travis is not always on latest version -- pod repo update - pod install --project-directory=Example script: - set -o pipefail && xcodebuild test -workspace Example/markymark.xcworkspace -scheme markymark-Example -destination 'platform=iOS Simulator,name=iPhone 8' | xcpretty From a2c5b37e0079d08e47db55d5537232f0e4d3b4ca Mon Sep 17 00:00:00 2001 From: Menno Lovink Date: Wed, 29 Jan 2020 18:07:52 +0100 Subject: [PATCH 6/7] (temporarily) remove failing link to specs repo --- Example/Podfile | 2 -- Example/Podfile.lock | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Example/Podfile b/Example/Podfile index 7e9d5ab..f3fd5cd 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -1,7 +1,5 @@ use_frameworks! -source 'https://github.com/CocoaPods/Specs.git' - target 'markymark_Example' do pod 'markymark', :path => '../' pod 'SwiftLint' diff --git a/Example/Podfile.lock b/Example/Podfile.lock index c85d8c2..4e41d48 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -18,6 +18,6 @@ SPEC CHECKSUMS: markymark: e7fa1cdb7ad51c21a46cda308ad8ef4511fa49f6 SwiftLint: 7f5f7de0da74a649b16616cb5246ae323489656e -PODFILE CHECKSUM: ac26bbd0b2acca180dc458845f0951e758f55812 +PODFILE CHECKSUM: e6179d5e64bda0057471cea1521ff93bf207a88b COCOAPODS: 1.8.4 From 3e2316f9e3a0513799f1f7f473f71640e6bad35e Mon Sep 17 00:00:00 2001 From: Menno Lovink Date: Thu, 30 Jan 2020 10:14:23 +0100 Subject: [PATCH 7/7] ignore everything beneath .build --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e39d86e..4add152 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ Carthage # # Pods/ .swiftpm +.build