From 9fabc75120c74471d2f0b4b28b88e340753892b5 Mon Sep 17 00:00:00 2001 From: Sourabh Gupta <67338847+tc-sgupta@users.noreply.github.com> Date: Wed, 5 Jan 2022 01:54:24 +1300 Subject: [PATCH 1/3] Added swift package manager support (#1) * Added swift package manager support * Restrict platform to watchOS version 3.0 * Fix package syntax * Specify library type to dynamic * Try copying resources * Specify resource file instead of folder * Copy all resources * Try without resources * Move back to static library * Try processing resources * Try again dynamic again * Avoid importing watch kit on iOS. Revert type dynamic * Fix watch kit import * Use swift package bundle --- .../Classes/EMTLoadingIndicator.swift | 6 +++++ EMTLoadingIndicator/Classes/EMTTimer.swift | 2 ++ Package.swift | 22 +++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 Package.swift diff --git a/EMTLoadingIndicator/Classes/EMTLoadingIndicator.swift b/EMTLoadingIndicator/Classes/EMTLoadingIndicator.swift index eb0a31c..90a411f 100644 --- a/EMTLoadingIndicator/Classes/EMTLoadingIndicator.swift +++ b/EMTLoadingIndicator/Classes/EMTLoadingIndicator.swift @@ -6,7 +6,9 @@ // import UIKit +#if !os(iOS) import WatchKit +#endif @objc final public class EMTLoadingIndicator: NSObject { @@ -61,7 +63,11 @@ final public class EMTLoadingIndicator: NSObject { private func prepareImagesForWaitStyleDot() { if EMTLoadingIndicator.dotWaitImage == nil { + #if SWIFT_PACKAGE + let bundle = Bundle.module + #else let bundle = Bundle(for: EMTLoadingIndicator.self) + #endif let cursors: [UIImage] = (0...29).map { let index = $0 return UIImage(contentsOfFile: (bundle.path(forResource: "waitIndicatorGraphic-\(index)@2x", ofType: "png"))!)! diff --git a/EMTLoadingIndicator/Classes/EMTTimer.swift b/EMTLoadingIndicator/Classes/EMTTimer.swift index 73facf2..e8160b9 100644 --- a/EMTLoadingIndicator/Classes/EMTTimer.swift +++ b/EMTLoadingIndicator/Classes/EMTTimer.swift @@ -5,7 +5,9 @@ // Copyright (C) 2016 emotionale. All rights reserved. // +#if !os(iOS) import WatchKit +#endif typealias EMTTimerCallback = (Timer) -> Void diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..4d033d0 --- /dev/null +++ b/Package.swift @@ -0,0 +1,22 @@ +// swift-tools-version:5.3 +// The swift-tools-version declares the minimum version of Swift required to build this package. +import PackageDescription + +let package = Package( + name: "EMTLoadingIndicator", + platforms: [ + .watchOS(.v3) + ], + products: [ + .library( + name: "EMTLoadingIndicator", + targets: ["EMTLoadingIndicator"]) + ], + targets: [ + .target( + name: "EMTLoadingIndicator", + path: ".", + sources: ["EMTLoadingIndicator/Classes"], + resources: [.process("EMTLoadingIndicator/Resources")]) + ] +) \ No newline at end of file From 476d5a813fd90c5c865f12c81dc3cd4087ec1dd4 Mon Sep 17 00:00:00 2001 From: Sourabh Gupta <67338847+tc-sgupta@users.noreply.github.com> Date: Wed, 5 Jan 2022 02:19:49 +1300 Subject: [PATCH 2/3] Fix warnings (#2) --- Package.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 4d033d0..eb318d7 100644 --- a/Package.swift +++ b/Package.swift @@ -16,7 +16,12 @@ let package = Package( .target( name: "EMTLoadingIndicator", path: ".", + exclude: ["LICENSE", + "README.md", + "waitIndicatorGraphic.fla", + "EMTLoadingIndicator/Info.plist", + "EMTLoadingIndicator.podspec"], sources: ["EMTLoadingIndicator/Classes"], resources: [.process("EMTLoadingIndicator/Resources")]) ] -) \ No newline at end of file +) From 36061fafa63a01bf8551fe20fb303395bf1da375 Mon Sep 17 00:00:00 2001 From: Sourabh Gupta Date: Tue, 13 Sep 2022 15:25:57 +1200 Subject: [PATCH 3/3] Updated swift tools version to 5.7 --- Package.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index eb318d7..7e283c3 100644 --- a/Package.swift +++ b/Package.swift @@ -1,11 +1,11 @@ -// swift-tools-version:5.3 +// swift-tools-version:5.7 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "EMTLoadingIndicator", platforms: [ - .watchOS(.v3) + .watchOS(.v4) ], products: [ .library(