Skip to content

Commit

Permalink
Merge pull request #27 from tattn/swift5.1
Browse files Browse the repository at this point in the history
Swift 5.1 and Swift Package Manager support
  • Loading branch information
tattn authored Oct 21, 2019
2 parents 3a72860 + 12b1bdd commit e65dd38
Show file tree
Hide file tree
Showing 31 changed files with 327 additions and 46 deletions.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: tattn
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
147 changes: 113 additions & 34 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
### https://raw.github.com/github/gitignore/e6dd3a81e6037cc923e503e372c80326f65ccb25/Global/macos.gitignore

*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


### https://raw.github.com/github/gitignore/e6dd3a81e6037cc923e503e372c80326f65ccb25/Global/xcode.gitignore
### https://raw.github.com/github/gitignore/e313e296c1e284d908adcb95bf4f2812617d4de1/Global/macOS.gitignore

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


### https://raw.github.com/github/gitignore/e313e296c1e284d908adcb95bf4f2812617d4de1/Swift.gitignore

# Xcode
#
Expand All @@ -53,8 +53,87 @@ xcuserdata/
*.moved-aside
*.xccheckout
*.xcscmblueprint
UserInterfaceState.xcuserstate

#Carthage/Build
Carthage
## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output

# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/


### https://raw.github.com/github/gitignore/e313e296c1e284d908adcb95bf4f2812617d4de1/Global/Xcode.gitignore

# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3


Expand Down
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
29 changes: 29 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// swift-tools-version:5.0

import PackageDescription

let package = Package(
name: "SwiftExtensions",
platforms: [
.macOS(.v10_12),
.iOS(.v10),
.tvOS(.v10),
.watchOS(.v3)
],
products: [
.library(
name: "SwiftExtensions",
targets: ["SwiftExtensions"])
],
targets: [
.target(
name: "SwiftExtensions",
path: "Sources"),
.testTarget(
name: "SwiftExtensionsTests",
dependencies: ["SwiftExtensions"],
path: "Tests"),
],
swiftLanguageVersions: [.v5]
)

7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ SwiftExtensions

[![Build Status](https://app.bitrise.io/app/e58694b1fa46a551/status.svg?token=E2FYmP02umcT9pjF4NKDSw)](https://app.bitrise.io/app/e58694b1fa46a551)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Swift Version](https://img.shields.io/badge/Swift-5-F16D39.svg)](https://developer.apple.com/swift)
[![Swift Package Manager compatible](https://img.shields.io/badge/SwiftPackageManager-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Swift Version](https://img.shields.io/badge/Swift-5.1-F16D39.svg)](https://developer.apple.com/swift)

My favorite Swift extensions.

# Installation

## Swift Package Manager

You can install this package with Swift Package Manager in Xcode 11.

## Carthage

```ruby
Expand Down
4 changes: 2 additions & 2 deletions Sources/NSObject+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public protocol ClassNameProtocol {

public extension ClassNameProtocol {
static var className: String {
return String(describing: self)
String(describing: self)
}

var className: String {
return type(of: self).className
Self.className
}
}

Expand Down
3 changes: 3 additions & 0 deletions Sources/NibInstantiatable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
// Copyright © 2017年 tattn. All rights reserved.
//

#if canImport(UIKit)
import Foundation
import UIKit

public protocol NibInstantiatable {
static var nibName: String { get }
Expand Down Expand Up @@ -44,3 +46,4 @@ public extension EmbeddedNibInstantiatable where Self: UIView, Embedded: UIView
view.fillSuperview()
}
}
#endif // canImport(UIKit)
2 changes: 2 additions & 0 deletions Sources/StoryboardInstantiatable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2017年 tattn. All rights reserved.
//

#if canImport(UIKit)
import UIKit

public enum StoryboardInstantiateType {
Expand Down Expand Up @@ -47,3 +48,4 @@ public extension StoryboardInstantiatable where Self: UIViewController {
}
}
}
#endif // canImport(UIKit)
2 changes: 2 additions & 0 deletions Sources/UIApplication+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2017年 tattn. All rights reserved.
//

#if canImport(UIKit)
import UIKit

public extension UIApplication {
Expand All @@ -23,3 +24,4 @@ public extension UIApplication {
return topViewController as? UINavigationController
}
}
#endif // canImport(UIKit)
2 changes: 2 additions & 0 deletions Sources/UICollectionView+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2017年 tattn. All rights reserved.
//

#if canImport(UIKit)
import UIKit

public extension UICollectionView {
Expand Down Expand Up @@ -44,3 +45,4 @@ public extension UICollectionView {
return dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: type.className, for: indexPath) as! T
}
}
#endif // canImport(UIKit)
13 changes: 13 additions & 0 deletions Sources/UIColor+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2017年 tattn. All rights reserved.
//

#if canImport(UIKit)
import UIKit

public extension UIColor {
Expand All @@ -30,6 +31,17 @@ public extension UIColor {
convenience init(red: Int, green: Int, blue: Int, alpha: Double = 1.0) {
self.init(red: CGFloat(red) / 255, green: CGFloat(green) / 255, blue: CGFloat(blue) / 255, alpha: CGFloat(alpha))
}

/// Create a dynamic color.
/// - Parameter light: a color in light mode
/// - Parameter dark: a color in dark mode
convenience init(light: UIColor, dark: UIColor) {
if #available(iOS 13, *) {
self.init { $0.userInterfaceStyle == .dark ? dark : light }
} else {
self.init(cgColor: light.cgColor)
}
}
}

public extension UIColor {
Expand All @@ -50,3 +62,4 @@ public extension UIColor {
return Components(_base: self)
}
}
#endif // canImport(UIKit)
2 changes: 2 additions & 0 deletions Sources/UIImage+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2017年 tattn. All rights reserved.
//

#if canImport(UIKit)
import UIKit

public extension UIImage {
Expand Down Expand Up @@ -145,3 +146,4 @@ extension UIImage {
}
}
}
#endif // canImport(UIKit)
2 changes: 2 additions & 0 deletions Sources/UINavigationController+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2019 tattn. All rights reserved.
//

#if canImport(UIKit)
import UIKit

extension UINavigationController {
Expand Down Expand Up @@ -43,3 +44,4 @@ extension UINavigationController {
coordinator.animate(alongsideTransition: nil) { _ in completion() }
}
}
#endif // canImport(UIKit)
2 changes: 2 additions & 0 deletions Sources/UITableView+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2017年 tattn. All rights reserved.
//

#if canImport(UIKit)
import UIKit

public extension UITableView {
Expand All @@ -23,3 +24,4 @@ public extension UITableView {
return self.dequeueReusableCell(withIdentifier: type.className, for: indexPath) as! T
}
}
#endif // canImport(UIKit)
2 changes: 2 additions & 0 deletions Sources/UIView+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2017年 tattn. All rights reserved.
//

#if canImport(UIKit)
import UIKit

public extension UIView {
Expand Down Expand Up @@ -44,3 +45,4 @@ public extension UIView {
return image
}
}
#endif // canImport(UIKit)
2 changes: 2 additions & 0 deletions Sources/UIViewController+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2018年 tattn. All rights reserved.
//

#if canImport(UIKit)
import UIKit

public extension UIViewController {
Expand Down Expand Up @@ -39,3 +40,4 @@ public extension UIViewController {
case custom((UIView, UIView) -> Void)
}
}
#endif // canImport(UIKit)
Loading

0 comments on commit e65dd38

Please sign in to comment.