diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7e326a2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,40 @@ +# SPM defaults +.DS_Store +/.build +/Packages +.swiftpm/ + +# Build generated +build/ +DerivedData/ + +# Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 + +# Other +*.moved-aside +*.xccheckout +*.xcscmblueprint + +# Obj-C/Swift specific +*.hmap +*.ipa +*.dSYM.zip +*.dSYM + +# Bundler +.bundle + +# Fastlane +Fastlane/report.xml +Fastlane/Preview.html +Fastlane/screenshots +Fastlane/test_output +Fastlane/README.md diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 0000000..e6ca7e9 --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,8 @@ +disabled_rules: + - trailing_whitespace + - type_name + - vertical_whitespace + +included: + - Sources + - Tests diff --git a/DSSwiftKit.podspec b/DSSwiftKit.podspec new file mode 100644 index 0000000..03bcf35 --- /dev/null +++ b/DSSwiftKit.podspec @@ -0,0 +1,24 @@ +# Run `pod lib lint SwiftKit.podspec' to ensure this is a valid spec. + +Pod::Spec.new do |s| + s.name = 'DSSwiftKit' + s.version = '0.1.0' + s.swift_versions = ['5.2'] + s.summary = 'SwiftKit contains extra functionality for Swift.' + + s.description = <<-DESC + SwiftKit contains extra functionality for Swift, like extensions, utils etc. + DESC + + s.homepage = 'https://github.com/danielsaidi/SwiftKit' + s.license = { :type => 'MIT', :file => 'LICENSE' } + s.author = { 'Daniel Saidi' => 'daniel.saidi@gmail.com' } + s.source = { :git => 'https://github.com/danielsaidi/SwiftKit.git', :tag => s.version.to_s } + s.social_media_url = 'https://twitter.com/danielsaidi' + + s.swift_version = '5.2' + s.ios.deployment_target = '11.0' + s.tvos.deployment_target = '13.0' + s.watchos.deployment_target = '6.0' + s.source_files = 'Sources/**/*.swift' +end diff --git a/Fastlane/Fastfile b/Fastlane/Fastfile new file mode 100644 index 0000000..c42bbb3 --- /dev/null +++ b/Fastlane/Fastfile @@ -0,0 +1,31 @@ +fastlane_version "2.129.0" + +default_platform :ios + +platform :ios do + + desc "Create a new version" + lane :version do |options| + ensure_git_status_clean + ensure_git_branch(branch: 'master') + + bump_type = options[:type] + if bump_type == nil or bump_type.empty? + bump_type = "patch" + end + + version = version_bump_podspec(path: "DSSwiftKit.podspec", bump_type: bump_type) + increment_version_number(version_number: version) + + git_commit( + path: "*", + message: "Bump to #{version}" + ) + + add_git_tag(tag: version) + push_git_tags() + push_to_git_remote() + pod_push() + end + +end diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2ffa01a --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Daniel Saidi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..d3420c2 --- /dev/null +++ b/Package.swift @@ -0,0 +1,27 @@ +// swift-tools-version:5.1 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "SwiftKit", + platforms: [ + .iOS(.v11), + .tvOS(.v13) + .watchOS(.v13) + ], + products: [ + .library( + name: "SwiftKit", + targets: ["SwiftKit"]), + ], + dependencies: [], + targets: [ + .target( + name: "SwiftKit", + dependencies: []), + .testTarget( + name: "SwiftKitTests", + dependencies: ["SwiftKit"]), + ] +) diff --git a/README.md b/README.md index 4443661..3927819 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,80 @@ -# SwiftKit -SwiftUIKit contains additional functionality for Swift. +

+ +

+ +

+ + Version + + Swift UI + Swift 5.1 + License + + Twitter: @danielsaidi + +

+ + +## About SwiftKit + +`SwiftKit` adds functionality to `Swift`, both extensions to existing types and components, as well as custom useful functionality. + +You can read more about the different parts of `SwiftKit` in separate readmes: + +* [Extensions][Extensions] + +If things that exist in this library are added to `Swift`, the corresponding functionality in this library will be deprecated and refer to those new features. + + +## Demo App + +This project contains a demo app that shows all available system blur styles. To run the demo app, just open and run the `SwiftKit.xcodeproj` project. + + +## Installation + +### Swift Package Manager + +``` +https://github.com/danielsaidi/SwiftKit.git +``` + +### CocoaPods + +``` +pod DSSwiftKit +``` + + +## Why a big "Kit"? + +Having a big "kit" is a bad idea, since it may become too generic and hard to overview. For instance, if I want to modify dates, I'm probably not going to dig around in SwiftKit looking for extensions, but rather use the best single-purpose date library. + +The GitHub stars confirm this as well. Many years ago, I started putting reusable iOS functionality into a library I call [iExtra](https://github.com/danielsaidi/iExtra). I think it's an amazing library and I use it in most of my apps. To this day, it has 12 stars. + +However, each project comes with overhead. If I decided to create a new library for each little thing I make, I'd spend a lot of time setting up each new project. There are funny names to come up with, icons and logos to be made, maintenance etc. + +SO instead of honoring every little idea with a new library, I'm going to put most here until they are either too large or too good to be a part of this library. When that happens, they'll break out of their little cage and move into a library of their own. + + +## Contact me + +Feel free to reach out if you have questions or if you want to contribute in any way: + +* E-mail: [daniel.saidi@gmail.com][Email] +* Twitter: [@danielsaidi][Twitter] +* Web site: [danielsaidi.com][Website] + + +## License + +SwiftKit is available under the MIT license. See [LICENSE][License] file for more info. + +[Email]: mailto:daniel.saidi@gmail.com +[Twitter]: http://www.twitter.com/danielsaidi +[Website]: http://www.danielsaidi.com + +[GitHub]: https://github.com/danielsaidi/SwiftKit +[License]: https://github.com/danielsaidi/SwiftKit/blob/master/LICENSE + +[Extensions]: Readmes/Extensions.md diff --git a/Readmes/Extensions.md b/Readmes/Extensions.md new file mode 100644 index 0000000..4b44e0a --- /dev/null +++ b/Readmes/Extensions.md @@ -0,0 +1,5 @@ +# Extension + +`SwiftKit` contains additional logic in the form of extensions to native `Swift` types. + +Since this namespace will probably grow much and fast, extensions are not listed or described here. Instead, have a look at the source code to see what kind of extensions this library contains. They should all be pretty well documented. \ No newline at end of file diff --git a/Release Notes.md b/Release Notes.md new file mode 100644 index 0000000..c208393 --- /dev/null +++ b/Release Notes.md @@ -0,0 +1,84 @@ +# Release notes + + +## 0.5.0 + +This release adds: + +* An `ImagePicker` that can be used to present a `UIImagePickerController`. +* An `FilePicker` that can be used to present a `UIDocumentPickerViewController`. +* An `ShareSheet` that can be used to present a `UIActivityViewController`. +* An `UserDefaultsPersisted` property wrapper that lets you persist data to `UserDefaults`. + + +## 0.4.1 + +This release changes the `View` geometry extensions and replaces `bindGeometry(to: ...)` with: + +* `bindSafeAreaInsets(to: ...)` +* `bindSize(to: ...)` + +You can use them like this: + +```swift +@State private var size: CGSize = .zero +@State private var size: CGSize = .zero +UIColor.red.bindGeometry(to: $height) { $0.size.height } +``` + + +## 0.4.0 + +This release adds a new geometry `View` extension: + +* `bindGeometry(to: ...)` lets you bind any `CGFloat` geometry value for a view. + +The extension injects a `GeometryReader` and provides values to the provided binding. + + +## 0.3.0 + +This release adds some new toast features: + +* `ToastContext` is an observable object can be used to manage a view's toast. +* `ToastStyle` is a new struct that contains all available styles for a toast. + +This release makes some small api changes: + +* The `SwipeGesture` initializer has been made public. +* `Toast` now uses `ToastStyle` instead of separate style properties. +* The `Toast` extensions now require you to specify a background. +* The text-based `Toast` extension automatically centers the text. + + +## 0.2.1 + +This release adds a new `FontIdentifier`. + +It can be implemented by any font provider, e.g. `SwiftGen`s `FontConvertible`. + + +## 0.2.0 + +This release adds new style structs: + +* `CornerRadiusStyle` style can be used to specify corner radii. +* `FontStyle` style can be used to specify custom fonts. +* `ShadowStyle` style can be used to specify drop shadow styles. + +These view modifiers simplifies using these styles: + +* `cornerRadius(_ style:)` can be used to apply a `CornerRadiusStyle`. +* `font(_ style: FontStyle)` can be used to apply a `FontStyle`. +* `font(name:, style:, weight:)` can also be used to apply custom fonts. +* `shadow(_ style:)` can be used to apply a `ShadowStyle`. + +The release also adds new view extensions: + +* `blur(...)` simplifies using the system blur styles that are specified in this library. +* `border(content:,width:,cornerRadius:)` can be used to apply borders with a certain content (e.g. Color.red), width and corner radius. + + +## 0.1.0 + +This is the very first release of SwiftUIKit. It contains a bunch of features, which are described in the readme. diff --git a/Resources/Icon.sketch b/Resources/Icon.sketch new file mode 100644 index 0000000..ad8561c Binary files /dev/null and b/Resources/Icon.sketch differ diff --git a/Resources/Logo.png b/Resources/Logo.png new file mode 100644 index 0000000..fb82d58 Binary files /dev/null and b/Resources/Logo.png differ diff --git a/Resources/Logo.sketch b/Resources/Logo.sketch new file mode 100644 index 0000000..c13a5c2 Binary files /dev/null and b/Resources/Logo.sketch differ diff --git a/Sources/SwiftKit/SwiftKit.swift b/Sources/SwiftKit/SwiftKit.swift new file mode 100644 index 0000000..0486ae9 --- /dev/null +++ b/Sources/SwiftKit/SwiftKit.swift @@ -0,0 +1,3 @@ +struct SwiftKit { + var text = "Hello, World!" +} diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift new file mode 100644 index 0000000..33b4bb0 --- /dev/null +++ b/Tests/LinuxMain.swift @@ -0,0 +1,7 @@ +import XCTest + +import SwiftKitTests + +var tests = [XCTestCaseEntry]() +tests += SwiftKitTests.allTests() +XCTMain(tests) diff --git a/Tests/SwiftKitTests/SwiftKitTests.swift b/Tests/SwiftKitTests/SwiftKitTests.swift new file mode 100644 index 0000000..1491e0a --- /dev/null +++ b/Tests/SwiftKitTests/SwiftKitTests.swift @@ -0,0 +1,15 @@ +import XCTest +@testable import SwiftKit + +final class SwiftKitTests: XCTestCase { + func testExample() { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct + // results. + XCTAssertEqual(SwiftKit().text, "Hello, World!") + } + + static var allTests = [ + ("testExample", testExample), + ] +} diff --git a/Tests/SwiftKitTests/XCTestManifests.swift b/Tests/SwiftKitTests/XCTestManifests.swift new file mode 100644 index 0000000..c5513ab --- /dev/null +++ b/Tests/SwiftKitTests/XCTestManifests.swift @@ -0,0 +1,9 @@ +import XCTest + +#if !canImport(ObjectiveC) +public func allTests() -> [XCTestCaseEntry] { + return [ + testCase(SwiftKitTests.allTests), + ] +} +#endif