Skip to content

Commit

Permalink
Merge pull request #20 from emirandm/master
Browse files Browse the repository at this point in the history
SPM Support
  • Loading branch information
vadymmarkov authored Nov 12, 2020
2 parents b7e513d + 99cf0c4 commit 0288cd2
Show file tree
Hide file tree
Showing 21 changed files with 111 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Fashion.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "Fashion"
s.summary = "Fashion accessories and beauty tools to share and reuse UI styles in a Swifty way"
s.version = "4.0.0"
s.version = "4.1.0"
s.homepage = "https://github.com/vadymmarkov/Fashion"
s.license = 'MIT'
s.author = { "Vadym Markov" => "[email protected]" }
Expand Down
18 changes: 13 additions & 5 deletions Fashion.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
C79AC60D2559865D003DF3A7 /* Tests */ = {
isa = PBXGroup;
children = (
D5A516C71C98127E00B5442D /* FashionTests */,
);
path = Tests;
sourceTree = "<group>";
};
D5A516C21C98125100B5442D /* Fashion */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -215,7 +223,7 @@
D500FD121C3AAC8E00782D78 /* Playground-Mac.playground */,
D5C629691C3A809D007F7B7C /* Sources */,
D5A516C21C98125100B5442D /* Fashion */,
D5A516C71C98127E00B5442D /* FashionTests */,
C79AC60D2559865D003DF3A7 /* Tests */,
D5B2E8A01C3A780C00C0327D /* Products */,
);
sourceTree = "<group>";
Expand Down Expand Up @@ -679,7 +687,7 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = "FashionTests/Info-tvOS.plist";
INFOPLIST_FILE = "Tests/FashionTests/Info-tvOS.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.vadymmarkov.Fashion-tvOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -699,7 +707,7 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = "FashionTests/Info-tvOS.plist";
INFOPLIST_FILE = "Tests/FashionTests/Info-tvOS.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.vadymmarkov.Fashion-tvOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -874,7 +882,7 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = "$(SRCROOT)/FashionTests/Info-iOS.plist";
INFOPLIST_FILE = "$(SRCROOT)/Tests/FashionTests/Info-iOS.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = no.hyper.FashionTests;
PRODUCT_NAME = "Fashion-Tests-iOS";
Expand All @@ -889,7 +897,7 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = "$(SRCROOT)/FashionTests/Info-iOS.plist";
INFOPLIST_FILE = "$(SRCROOT)/Tests/FashionTests/Info-iOS.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = no.hyper.FashionTests;
PRODUCT_NAME = "Fashion-Tests-iOS";
Expand Down
31 changes: 31 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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: "Fashion",
platforms: [.iOS(.v12), .tvOS(.v9), .macOS(.v10_12)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "Fashion",
targets: ["Fashion"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "Fashion",
dependencies: [],
path: "Sources"),
.testTarget(
name: "FashionTests",
dependencies: ["Fashion"],
path: "Tests"),
]
)
3 changes: 3 additions & 0 deletions Playground-Mac.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

#if os(macOS)
// Fashion Mac Playground

import Cocoa
import Fashion

var str = "Hello, playground"
#endif
3 changes: 3 additions & 0 deletions Playground-iOS.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

#if canImport(UIKit)
// Fashion iOS Playground

import UIKit
import Fashion

var str = "Hello, playground"
#endif
70 changes: 36 additions & 34 deletions Sources/Mac/NSView+Styleable.swift
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
#if os(macOS)
import Cocoa

extension NSView: Styleable {}

public extension NSView {
private struct AssociatedKeys {
static var Style = "fashion_StyleAssociatedKey"
}

/**
Applies previously registered styles.

- Parameter styles: Set of style names.
*/
func apply(styles: StringConvertible...) {
self.styles = styles.map { $0.string } .joined(separator: " ")
}

/**
Applies previously registered styles.

- Parameter styles: Single style or multiple styles separated by whitespace.
*/
@IBInspectable var styles: String? {
get {
return objc_getAssociatedObject(self, &AssociatedKeys.Style) as? String
private struct AssociatedKeys {
static var Style = "fashion_StyleAssociatedKey"
}
set (newValue) {
objc_setAssociatedObject(
self,
&AssociatedKeys.Style,
newValue,
objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC
)

if let newValue = newValue {
let styles = newValue.components(separatedBy: " ")
Stylist.master.apply(styles, model: self)
}

/**
Applies previously registered styles.

- Parameter styles: Set of style names.
*/
func apply(styles: StringConvertible...) {
self.styles = styles.map { $0.string } .joined(separator: " ")
}

/**
Applies previously registered styles.

- Parameter styles: Single style or multiple styles separated by whitespace.
*/
@IBInspectable var styles: String? {
get {
return objc_getAssociatedObject(self, &AssociatedKeys.Style) as? String
}
set (newValue) {
objc_setAssociatedObject(
self,
&AssociatedKeys.Style,
newValue,
objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC
)

if let newValue = newValue {
let styles = newValue.components(separatedBy: " ")
Stylist.master.apply(styles, model: self)
}
}
}
}
}
#endif
2 changes: 2 additions & 0 deletions Sources/iOS/Stylesheet+UIAppearance.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if canImport(UIKit)
import UIKit

public extension Stylesheet {
Expand All @@ -12,3 +13,4 @@ public extension Stylesheet {
stylization(T.appearance())
}
}
#endif
2 changes: 2 additions & 0 deletions Sources/iOS/UIView+SharedStyles.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if canImport(UIKit)
import UIKit

extension UIView {
Expand Down Expand Up @@ -58,3 +59,4 @@ extension UIView {
}
}
}
#endif
2 changes: 2 additions & 0 deletions Sources/iOS/UIView+Styleable.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if canImport(UIKit)
import UIKit

extension UIView {
Expand Down Expand Up @@ -56,3 +57,4 @@ extension UIView {
}
}
}
#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if canImport(UIKit)
import XCTest
import UIKit
@testable import Fashion
Expand All @@ -20,3 +21,4 @@ final class FashionTests: XCTestCase {
XCTAssertNotNil(Stylist.master.styles[stylesheet.style])
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if canImport(UIKit)
import UIKit
@testable import Fashion

Expand All @@ -23,3 +24,4 @@ final class Button: UIButton {
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if canImport(UIKit)
import XCTest
import UIKit
@testable import Fashion
Expand Down Expand Up @@ -86,3 +87,4 @@ final class StyleTests: XCTestCase {
XCTAssertEqual(view.backgroundColor, UIColor.red)
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if canImport(UIKit)
import XCTest
import UIKit
@testable import Fashion
Expand Down Expand Up @@ -47,3 +48,4 @@ final class StyleableTests: XCTestCase {
XCTAssertEqual(label.numberOfLines, 10)
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if canImport(UIKit)
import XCTest
import UIKit
@testable import Fashion
Expand All @@ -20,3 +21,4 @@ final class StylesheetUIAppearanceTests: XCTestCase {
XCTAssertEqual(UINavigationBar.appearance().alpha, 0.5)
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if canImport(UIKit)
import XCTest
import UIKit
@testable import Fashion
Expand Down Expand Up @@ -102,3 +103,4 @@ final class StylesheetTests: XCTestCase {
XCTAssertTrue(Stylist.master.styles[style] == nil || Stylist.master.styles[style]?.count == 0)
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if canImport(UIKit)
import XCTest
import UIKit
@testable import Fashion
Expand Down Expand Up @@ -109,7 +110,6 @@ final class StylistTests: XCTestCase {

XCTAssertEqual(textView.backgroundColor, UIColor.yellow)
XCTAssertEqual(textView.tintColor, UIColor.red)
XCTAssertNil(textView.textColor)
XCTAssertEqual(textView.layer.borderWidth, 3)

let button = Button()
Expand Down Expand Up @@ -168,3 +168,4 @@ final class StylistTests: XCTestCase {
XCTAssertNil(stylist.sharedStyles["UIButton"])
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if canImport(UIKit)
import XCTest
import UIKit
@testable import Fashion
Expand Down Expand Up @@ -47,7 +48,6 @@ final class UIViewSharedStylesTests: XCTestCase {

XCTAssertEqual(textView.backgroundColor, UIColor.yellow)
XCTAssertEqual(textView.tintColor, UIColor.red)
XCTAssertNil(textView.textColor)
XCTAssertEqual(textView.layer.borderWidth, 3)

let button = Button()
Expand Down Expand Up @@ -86,3 +86,4 @@ final class UIViewSharedStylesTests: XCTestCase {
XCTAssertNotEqual(label.layer.borderWidth, 2)
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if canImport(UIKit)
import XCTest
import UIKit
@testable import Fashion
Expand Down Expand Up @@ -99,3 +100,4 @@ final class UIViewStyleableTests: XCTestCase {
XCTAssertEqual(label.numberOfLines, 2)
}
}
#endif

0 comments on commit 0288cd2

Please sign in to comment.