Skip to content

ViacomInc/ViaSwiftUtils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ViaSwiftUtils

Swift 5.0 Carthage compatible Version Platform Build Status License

What can ViaSwiftUtils do for you? Here are some examples we compiled:

Tired of spelling out NSLocalizedString every time you localize a string?

title = "HomePage.title".localized
print(title) // 'Main', '頭版', 'صفحه نخست', 'Startseite'

Want to find the longest word in a string?

print(germanText.longestWord())
// 'Verkehrsinfrastrukturfinanzierungsgesellschaft'

Need an array (or any other MutableCollection) shuffled? [^3]

var numbers = [1, 2, 3, 4, 5, 6]
numbers.shuffleInPlace() //e.g. [4, 1, 5, 2, 6, 3]

Want all the unique entries in a Sequence with Hashable elements?

let emojis = ["😀", "👀", "😱", "😡", "👀", "😀", "👀", "😱"]
let uniqueEmojis = emojis.unique() // ["😀", "👀", "😱", "😡"]

Is dealing with TimeInterval inconvenient?

let twelveDays = 12 * TimeInterval.day
let minutes = twelveDays / TimeInterval.minute // 17280

Need to create an image with rounded corners from an existing image?

Rounded image


Does one of the views in your app need to rotate?

someView.startRotating()
// ...
someView.stopRotating()

And more date helper methods & variables:

let components = DateComponents(calendar: gregorian, era: 0,
                                year: 44, month: 3, day: 15, hour: 13)
let idesOfMarch = gregorian.date(from: components)!
let weekDay = idesOfMarch.dayOfWeek // 6
let daysSince = idesOfMarch.days(to: Date()) // 752533

 

These are just a few examples. We are expanding the library continuously and we accept Pull-Requests ☺️

 

Requirements

Versions support

Swift Xcode ViaSwiftUtils
4.2 - 5.0 10.X, 11.X 2.1.0
4.0 10.X 2.0.5
3.2 - 4.1 9.X 2.0.5

 

How to install ViaSwiftUtils

Via Cocoapods

Add the following line to your Podfile. Remember you'll need to enable use_frameworks!.

pod 'ViaSwiftUtils', '2.1.0'

Via Carthage

Add the following line to your Cartfile

github "ViacomInc/ViaSwiftUtils" == 2.1.0

Via Swift package manager

Add the following to your Package.swift

dependencies: [
  .package(url: "https://github.com/ViacomInc/ViaSwiftUtils.git", .exact("2.1.0")),
]

.target(name: <#yourTarget#>, dependencies: ["ViaSwiftUtils"]),

I should mention that only the Foundation functions that are part of ViaSwiftUtils work via SPM, as UIKit is not available on Linux or MacOS.

Importing

After you installed the framework via one of the 3 above methods, import it in your .swift file.

import ViaSwiftUtils

 

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

Utilities for Building Applications in Swift

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages