diff --git a/.gitignore b/.gitignore index 6e99db1..e58073f 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ playground.xcworkspace # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. # Packages/ .build/ +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata # CocoaPods # diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..d6b6063 --- /dev/null +++ b/Package.swift @@ -0,0 +1,21 @@ +// swift-tools-version:5.5 +import PackageDescription + +let package = Package( + name: "Stylish", + platforms: [ + .macOS(.v10_15), + .iOS(.v9) + ], + products: [ + .library(name: "Stylish", targets: ["Stylish"]) + ], + targets: [ + .target( + name: "Stylish", + path: "Stylish", + exclude: ["Info.plist", "Media.xcassets", "Stylish.h"] + ) + ], + swiftLanguageVersions: [.v5] +) diff --git a/README.md b/README.md index b1c56d9..adedd4d 100644 --- a/README.md +++ b/README.md @@ -15,15 +15,34 @@ For the first time, this provides a single solution for creating and applying st ## Installation -Since Swift has not yet reached ABI or module format stability, Apple does not support or advise distributing Swift libraries compiled outside of your project. Instead, the recommended approach is: +:warning: Because Stylish is a separate module from your app, some special considerations are needed to get IBDesignables and the live rendering of styles in Storyboards playing nicely. Specifically, it requires two extensions that override prepareForInterfaceBuilder in two types. See MainViewController.swift in the StylishExample app for reference implementations of these extensions. +### Manually 1. Include the Stylish repo (this repo) as a git submodule in your project (or just check out the version of the entire Stylish repo you want to use and add it to your project as a subdirectory) 2. Drag Stylish.xcodeproj into your own Xcode project or workspace (see the StylishExample project in this repo as a reference) 3. In your own app target(s) on the "General" tab, scroll down to "Embedded Binaries", click the plus button and choose Stylish.framework. Again, you can refer to the StylishExample project to see what this looks like. These steps will ensure that the Stylish framework is compiled as part of your own app's build phases as needed and that the Stylish.framework will be using the same version of Swift and the Swift compiler as the rest of your project. -4. IMPORTANT! Because Stylish is a separate module from your app, some special considerations are needed to get IBDesignables and the live rendering of styles in Storyboards playing nicely. Specifically, it requires two extensions that override prepareForInterfaceBuilder in two types. See MainViewController.swift in the StylishExample app for reference implementations of these extensions. +### Carthage + +[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate Alamofire into your Xcode project using Carthage, specify it in your `Cartfile`: + +```ogdl +github "daniel-hall/Stylish" "master" +``` + +### Swift Package Manager + +The [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler. + +Once you have your Swift package set up, adding Alamofire as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. + +```swift +dependencies: [ + .package(url: "https://github.com/daniel-hall/Stylish.git", .branch("master")) +] +``` ## Example Project diff --git a/Stylish.xcodeproj/project.pbxproj b/Stylish.xcodeproj/project.pbxproj index ebb92f3..cd5c278 100644 --- a/Stylish.xcodeproj/project.pbxproj +++ b/Stylish.xcodeproj/project.pbxproj @@ -110,7 +110,7 @@ D7C472F41F3E4F8A00B5880A /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1320; TargetAttributes = { D7C472FC1F3E4F8A00B5880A = { CreatedOnToolsVersion = 8.2.1; @@ -189,6 +189,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -214,7 +215,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -252,6 +253,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -271,7 +273,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; @@ -295,7 +297,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = Stylish/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_NO_PIE = NO; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.danielhall.Stylish; @@ -318,7 +320,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = Stylish/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_NO_PIE = NO; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.danielhall.Stylish; diff --git a/Stylish.xcodeproj/xcshareddata/xcschemes/Stylish.xcscheme b/Stylish.xcodeproj/xcshareddata/xcschemes/Stylish.xcscheme index 85cf1f8..627e4a4 100644 --- a/Stylish.xcodeproj/xcshareddata/xcschemes/Stylish.xcscheme +++ b/Stylish.xcodeproj/xcshareddata/xcschemes/Stylish.xcscheme @@ -1,6 +1,6 @@ - - - - UITextAutocapitalizationType? { switch stylesheetValue as? String { case .some("none"): - return .none + return UITextAutocapitalizationType.none case .some("words"): return .words case .some("sentences"): @@ -429,7 +429,7 @@ extension UIBaselineAdjustment: StylesheetParseable { case .some("alignCenters"): return .alignCenters case .some("none"): - return .none + return UIBaselineAdjustment.none default: return nil } @@ -440,7 +440,7 @@ extension UITextField.BorderStyle: StylesheetParseable { public static func parse(from stylesheetValue: Any) -> UITextField.BorderStyle? { switch stylesheetValue as? String { case .some("none"): - return .none + return UITextField.BorderStyle.none case .some("line"): return .line case .some("bezel"): diff --git a/Stylish/Stylish.swift b/Stylish/Stylish.swift index 0a6fc99..afd7418 100644 --- a/Stylish/Stylish.swift +++ b/Stylish/Stylish.swift @@ -29,7 +29,7 @@ import UIKit /// A protocol that view types conform to in order to participate in the Stylish styling process. Requires a "styles" String property which can hold a comma-separated list of style names and "stylesheet" property which can hold an optional override stylesheet other than the global one, which will then be used by this Styleable instance and inherited by its children. Usually both required vars are implemented as IBInspectable properties -public protocol Styleable: class { +public protocol Styleable: AnyObject { var styles: String { get set } var stylesheet: String? { get set } } @@ -40,7 +40,7 @@ public protocol Style { } /// The protocol a type must conform to in order to be used as a Stylesheet. A Stylesheet is simply a dictionary of Styles, each associated with a name. A Stylesheet must also return the bundle it is associated with, in order for Styles / Property Stylers to know what bundle to retrieve images, colors, or other assets from -public protocol Stylesheet: class { +public protocol Stylesheet: AnyObject { var styles: [String: Style] { get } var bundle: Bundle { get } }