From ae1f137759a33fc397367fa4e951800145b579a7 Mon Sep 17 00:00:00 2001 From: Levin Li Date: Tue, 26 May 2020 10:17:37 +0800 Subject: [PATCH] Fix importing via spm (#69) * Fix SPM * Update README.md * Use @_exported to remove duplicate imports --- Package.swift | 2 +- README.md | 6 ++++++ Sources/DarkModeCore/UIColor+DarkModeKit.h | 4 ++++ Sources/DarkModeCore/UIImage+DarkModeKit.h | 4 ++++ Sources/DarkModeCore/include/DarkModeCore.h | 8 ++++++++ Sources/FluentDarkModeKit/DarkModeManager.swift | 3 +++ .../Extensions/UIApplication+DarkModeKit.swift | 2 -- .../Extensions/UIButton+DarkModeKit.swift | 4 ---- .../Extensions/UIImageView+DarkModeKit.swift | 4 ---- .../Extensions/UILabel+DarkModeKit.swift | 4 ---- .../Extensions/UINavigationBar+DarkModeKit.swift | 4 ---- .../Extensions/UIPageControl+DarkModeKit.swift | 4 ---- .../Extensions/UIProgressView+DarkModeKit.swift | 4 ---- .../Extensions/UIScrollView+DarkModeKit.swift | 4 ---- .../Extensions/UISlider+DarkModeKit.swift | 4 ---- .../Extensions/UITabBar+DarkModeKit.swift | 4 ---- .../Extensions/UITableView+DarkModeKit.swift | 4 ---- .../Extensions/UITextField+DarkModeKit.swift | 4 ---- .../Extensions/UITextView+DarkModeKit.swift | 4 ---- .../Extensions/UIToolbar+DarkModeKit.swift | 4 ---- .../FluentDarkModeKit/Extensions/UIView+DarkModeKit.swift | 4 ---- .../Extensions/UIViewController+DarkModeKit.swift | 4 ---- .../Extensions/UIWindow+DarkModeKit.swift | 2 -- 23 files changed, 26 insertions(+), 65 deletions(-) diff --git a/Package.swift b/Package.swift index 399c4e5..62b988d 100644 --- a/Package.swift +++ b/Package.swift @@ -12,7 +12,7 @@ let package = Package( ]) ], targets: [ - .target(name: "DarkModeCore"), + .target(name: "DarkModeCore", cSettings: [.define("SWIFT_PACKAGE")]), .target(name: "FluentDarkModeKit", dependencies: ["DarkModeCore"]), .testTarget(name: "FluentDarkModeKitTests", dependencies: ["FluentDarkModeKit"]), ] diff --git a/README.md b/README.md index 1380aff..8911552 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,12 @@ github "microsoft/FluentDarkModeKit" Click "Files -> Swift Package Manager -> Add Package Dependency..." in Xcode's menu and search "https://github.com/microsoft/FluentDarkModeKit" +Since Xcode uses its own tools to handle swifft packages, git-lfs might not be picked up if it is installed via Homebrew. Run the following command to create a symbolic link if Xcode fails to fetch the package: + +``` +ln -s /usr/local/bin/git-lfs $(xcode-select -p)/usr/bin/git-lfs +``` + ### CocoaPods To integrate FluentDarkModeKit into your Xcode project using CocoaPods, specify it in your `Podfile`: diff --git a/Sources/DarkModeCore/UIColor+DarkModeKit.h b/Sources/DarkModeCore/UIColor+DarkModeKit.h index cad5ea8..0de1239 100644 --- a/Sources/DarkModeCore/UIColor+DarkModeKit.h +++ b/Sources/DarkModeCore/UIColor+DarkModeKit.h @@ -4,7 +4,11 @@ // #import +#ifdef SWIFT_PACKAGE +#import "DMNamespace.h" +#else #import +#endif NS_ASSUME_NONNULL_BEGIN diff --git a/Sources/DarkModeCore/UIImage+DarkModeKit.h b/Sources/DarkModeCore/UIImage+DarkModeKit.h index 9f410a1..f445778 100644 --- a/Sources/DarkModeCore/UIImage+DarkModeKit.h +++ b/Sources/DarkModeCore/UIImage+DarkModeKit.h @@ -4,7 +4,11 @@ // #import +#ifdef SWIFT_PACKAGE +#import "DMNamespace.h" +#else #import +#endif NS_ASSUME_NONNULL_BEGIN diff --git a/Sources/DarkModeCore/include/DarkModeCore.h b/Sources/DarkModeCore/include/DarkModeCore.h index e17ddeb..4cfb270 100644 --- a/Sources/DarkModeCore/include/DarkModeCore.h +++ b/Sources/DarkModeCore/include/DarkModeCore.h @@ -1,4 +1,12 @@ +#ifndef SWIFT_PACKAGE +#define SWIFT_PACKAGE +#endif + #import "../DMDynamicColor.h" #import "../DMDynamicImage.h" +#import "../DMNamespace.h" #import "../DMTraitCollection.h" #import "../NSObject+DarkModeKit.h" +#import "../UIColor+DarkModeKit.h" +#import "../UIImage+DarkModeKit.h" +#import "../UIView+DarkModeKit.h" diff --git a/Sources/FluentDarkModeKit/DarkModeManager.swift b/Sources/FluentDarkModeKit/DarkModeManager.swift index 55cd326..956b1ac 100644 --- a/Sources/FluentDarkModeKit/DarkModeManager.swift +++ b/Sources/FluentDarkModeKit/DarkModeManager.swift @@ -4,6 +4,9 @@ // import UIKit +#if SWIFT_PACKAGE +@_exported import DarkModeCore +#endif public final class DarkModeManager: NSObject { public static func setup() { diff --git a/Sources/FluentDarkModeKit/Extensions/UIApplication+DarkModeKit.swift b/Sources/FluentDarkModeKit/Extensions/UIApplication+DarkModeKit.swift index 8052e78..9e58ff5 100644 --- a/Sources/FluentDarkModeKit/Extensions/UIApplication+DarkModeKit.swift +++ b/Sources/FluentDarkModeKit/Extensions/UIApplication+DarkModeKit.swift @@ -3,8 +3,6 @@ // Licensed under the MIT License. // -import UIKit - extension UIApplication: DMTraitEnvironment { open func dmTraitCollectionDidChange(_ previousTraitCollection: DMTraitCollection?) { windows.forEach { $0.dmTraitCollectionDidChange(previousTraitCollection) } diff --git a/Sources/FluentDarkModeKit/Extensions/UIButton+DarkModeKit.swift b/Sources/FluentDarkModeKit/Extensions/UIButton+DarkModeKit.swift index 8a70a1e..843d1a7 100644 --- a/Sources/FluentDarkModeKit/Extensions/UIButton+DarkModeKit.swift +++ b/Sources/FluentDarkModeKit/Extensions/UIButton+DarkModeKit.swift @@ -3,10 +3,6 @@ // Licensed under the MIT License. // -#if SWIFT_PACKAGE -import DarkModeCore -#endif - extension UIButton { override func dm_updateDynamicColors() { super.dm_updateDynamicColors() diff --git a/Sources/FluentDarkModeKit/Extensions/UIImageView+DarkModeKit.swift b/Sources/FluentDarkModeKit/Extensions/UIImageView+DarkModeKit.swift index f4fb3bd..7336c4b 100644 --- a/Sources/FluentDarkModeKit/Extensions/UIImageView+DarkModeKit.swift +++ b/Sources/FluentDarkModeKit/Extensions/UIImageView+DarkModeKit.swift @@ -3,10 +3,6 @@ // Licensed under the MIT License. // -#if SWIFT_PACKAGE -import DarkModeCore -#endif - extension UIImageView { private struct Constants { diff --git a/Sources/FluentDarkModeKit/Extensions/UILabel+DarkModeKit.swift b/Sources/FluentDarkModeKit/Extensions/UILabel+DarkModeKit.swift index 67c8ad0..97033b4 100644 --- a/Sources/FluentDarkModeKit/Extensions/UILabel+DarkModeKit.swift +++ b/Sources/FluentDarkModeKit/Extensions/UILabel+DarkModeKit.swift @@ -3,10 +3,6 @@ // Licensed under the MIT License. // -#if SWIFT_PACKAGE -import DarkModeCore -#endif - extension UILabel { private enum Constants { static var currentThemeKey = "currentThemeKey" diff --git a/Sources/FluentDarkModeKit/Extensions/UINavigationBar+DarkModeKit.swift b/Sources/FluentDarkModeKit/Extensions/UINavigationBar+DarkModeKit.swift index 78e7d7a..d2fa3a7 100644 --- a/Sources/FluentDarkModeKit/Extensions/UINavigationBar+DarkModeKit.swift +++ b/Sources/FluentDarkModeKit/Extensions/UINavigationBar+DarkModeKit.swift @@ -3,10 +3,6 @@ // Licensed under the MIT License. // -#if SWIFT_PACKAGE -import DarkModeCore -#endif - extension UINavigationBar { override func dm_updateDynamicColors() { super.dm_updateDynamicColors() diff --git a/Sources/FluentDarkModeKit/Extensions/UIPageControl+DarkModeKit.swift b/Sources/FluentDarkModeKit/Extensions/UIPageControl+DarkModeKit.swift index 69e4065..4c3fc8c 100644 --- a/Sources/FluentDarkModeKit/Extensions/UIPageControl+DarkModeKit.swift +++ b/Sources/FluentDarkModeKit/Extensions/UIPageControl+DarkModeKit.swift @@ -3,10 +3,6 @@ // Licensed under the MIT License. // -#if SWIFT_PACKAGE -import DarkModeCore -#endif - extension UIPageControl { override func dm_updateDynamicColors() { super.dm_updateDynamicColors() diff --git a/Sources/FluentDarkModeKit/Extensions/UIProgressView+DarkModeKit.swift b/Sources/FluentDarkModeKit/Extensions/UIProgressView+DarkModeKit.swift index 6812ba2..0e58952 100644 --- a/Sources/FluentDarkModeKit/Extensions/UIProgressView+DarkModeKit.swift +++ b/Sources/FluentDarkModeKit/Extensions/UIProgressView+DarkModeKit.swift @@ -3,10 +3,6 @@ // Licensed under the MIT License. // -#if SWIFT_PACKAGE -import DarkModeCore -#endif - extension UIProgressView { override func dm_updateDynamicColors() { super.dm_updateDynamicColors() diff --git a/Sources/FluentDarkModeKit/Extensions/UIScrollView+DarkModeKit.swift b/Sources/FluentDarkModeKit/Extensions/UIScrollView+DarkModeKit.swift index 03914b3..9368210 100644 --- a/Sources/FluentDarkModeKit/Extensions/UIScrollView+DarkModeKit.swift +++ b/Sources/FluentDarkModeKit/Extensions/UIScrollView+DarkModeKit.swift @@ -3,10 +3,6 @@ // Licensed under the MIT License. // -#if SWIFT_PACKAGE -import DarkModeCore -#endif - extension UIScrollView { override func dm_updateDynamicColors() { super.dm_updateDynamicColors() diff --git a/Sources/FluentDarkModeKit/Extensions/UISlider+DarkModeKit.swift b/Sources/FluentDarkModeKit/Extensions/UISlider+DarkModeKit.swift index 65a1f94..cdae3bf 100644 --- a/Sources/FluentDarkModeKit/Extensions/UISlider+DarkModeKit.swift +++ b/Sources/FluentDarkModeKit/Extensions/UISlider+DarkModeKit.swift @@ -3,10 +3,6 @@ // Licensed under the MIT License. // -#if SWIFT_PACKAGE -import DarkModeCore -#endif - extension UISlider { override func dm_updateDynamicColors() { super.dm_updateDynamicColors() diff --git a/Sources/FluentDarkModeKit/Extensions/UITabBar+DarkModeKit.swift b/Sources/FluentDarkModeKit/Extensions/UITabBar+DarkModeKit.swift index ce4d281..23d247c 100644 --- a/Sources/FluentDarkModeKit/Extensions/UITabBar+DarkModeKit.swift +++ b/Sources/FluentDarkModeKit/Extensions/UITabBar+DarkModeKit.swift @@ -3,10 +3,6 @@ // Licensed under the MIT License. // -#if SWIFT_PACKAGE -import DarkModeCore -#endif - extension UITabBar { override open func dmTraitCollectionDidChange(_ previousTraitCollection: DMTraitCollection?) { super.dmTraitCollectionDidChange(previousTraitCollection) diff --git a/Sources/FluentDarkModeKit/Extensions/UITableView+DarkModeKit.swift b/Sources/FluentDarkModeKit/Extensions/UITableView+DarkModeKit.swift index 56b90ac..2d7c304 100644 --- a/Sources/FluentDarkModeKit/Extensions/UITableView+DarkModeKit.swift +++ b/Sources/FluentDarkModeKit/Extensions/UITableView+DarkModeKit.swift @@ -3,10 +3,6 @@ // Licensed under the MIT License. // -#if SWIFT_PACKAGE -import DarkModeCore -#endif - extension UITableView { override func dm_updateDynamicColors() { super.dm_updateDynamicColors() diff --git a/Sources/FluentDarkModeKit/Extensions/UITextField+DarkModeKit.swift b/Sources/FluentDarkModeKit/Extensions/UITextField+DarkModeKit.swift index 952c0ea..3725a10 100644 --- a/Sources/FluentDarkModeKit/Extensions/UITextField+DarkModeKit.swift +++ b/Sources/FluentDarkModeKit/Extensions/UITextField+DarkModeKit.swift @@ -3,10 +3,6 @@ // Licensed under the MIT License. // -#if SWIFT_PACKAGE -import DarkModeCore -#endif - extension UITextField { override func dm_updateDynamicColors() { super.dm_updateDynamicColors() diff --git a/Sources/FluentDarkModeKit/Extensions/UITextView+DarkModeKit.swift b/Sources/FluentDarkModeKit/Extensions/UITextView+DarkModeKit.swift index fb88f86..c446dec 100644 --- a/Sources/FluentDarkModeKit/Extensions/UITextView+DarkModeKit.swift +++ b/Sources/FluentDarkModeKit/Extensions/UITextView+DarkModeKit.swift @@ -3,10 +3,6 @@ // Licensed under the MIT License. // -#if SWIFT_PACKAGE -import DarkModeCore -#endif - extension UITextView { override func dm_updateDynamicColors() { super.dm_updateDynamicColors() diff --git a/Sources/FluentDarkModeKit/Extensions/UIToolbar+DarkModeKit.swift b/Sources/FluentDarkModeKit/Extensions/UIToolbar+DarkModeKit.swift index 51f13a8..2e9fb9d 100644 --- a/Sources/FluentDarkModeKit/Extensions/UIToolbar+DarkModeKit.swift +++ b/Sources/FluentDarkModeKit/Extensions/UIToolbar+DarkModeKit.swift @@ -3,10 +3,6 @@ // Licensed under the MIT License. // -#if SWIFT_PACKAGE -import DarkModeCore -#endif - extension UIToolbar { override func dm_updateDynamicColors() { super.dm_updateDynamicColors() diff --git a/Sources/FluentDarkModeKit/Extensions/UIView+DarkModeKit.swift b/Sources/FluentDarkModeKit/Extensions/UIView+DarkModeKit.swift index 8d007b9..84a00cd 100644 --- a/Sources/FluentDarkModeKit/Extensions/UIView+DarkModeKit.swift +++ b/Sources/FluentDarkModeKit/Extensions/UIView+DarkModeKit.swift @@ -3,10 +3,6 @@ // Licensed under the MIT License. // -#if SWIFT_PACKAGE -import DarkModeCore -#endif - extension UIView: DMTraitEnvironment { open func dmTraitCollectionDidChange(_ previousTraitCollection: DMTraitCollection?) { subviews.forEach { $0.dmTraitCollectionDidChange(previousTraitCollection) } diff --git a/Sources/FluentDarkModeKit/Extensions/UIViewController+DarkModeKit.swift b/Sources/FluentDarkModeKit/Extensions/UIViewController+DarkModeKit.swift index 1d63c41..06924bb 100644 --- a/Sources/FluentDarkModeKit/Extensions/UIViewController+DarkModeKit.swift +++ b/Sources/FluentDarkModeKit/Extensions/UIViewController+DarkModeKit.swift @@ -3,10 +3,6 @@ // Licensed under the MIT License. // -#if SWIFT_PACKAGE -import DarkModeCore -#endif - extension UIViewController: DMTraitEnvironment { open func dmTraitCollectionDidChange(_ previousTraitCollection: DMTraitCollection?) { setNeedsStatusBarAppearanceUpdate() diff --git a/Sources/FluentDarkModeKit/Extensions/UIWindow+DarkModeKit.swift b/Sources/FluentDarkModeKit/Extensions/UIWindow+DarkModeKit.swift index 4facea0..2bdf91e 100644 --- a/Sources/FluentDarkModeKit/Extensions/UIWindow+DarkModeKit.swift +++ b/Sources/FluentDarkModeKit/Extensions/UIWindow+DarkModeKit.swift @@ -3,8 +3,6 @@ // Licensed under the MIT License. // -import UIKit - extension UIWindow { override open func dmTraitCollectionDidChange(_ previousTraitCollection: DMTraitCollection?) { super.dmTraitCollectionDidChange(previousTraitCollection)