Skip to content

Commit

Permalink
Added swift package manager support (#1)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
tc-sgupta authored Jan 4, 2022
1 parent ff5b4cc commit 9fabc75
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions EMTLoadingIndicator/Classes/EMTLoadingIndicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
//

import UIKit
#if !os(iOS)
import WatchKit
#endif

@objc
final public class EMTLoadingIndicator: NSObject {
Expand Down Expand Up @@ -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"))!)!
Expand Down
2 changes: 2 additions & 0 deletions EMTLoadingIndicator/Classes/EMTTimer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
// Copyright (C) 2016 emotionale. All rights reserved.
//

#if !os(iOS)
import WatchKit
#endif

typealias EMTTimerCallback = (Timer) -> Void

Expand Down
22 changes: 22 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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")])
]
)

0 comments on commit 9fabc75

Please sign in to comment.