Skip to content

Commit

Permalink
Merge pull request #14 from hyperoslo/fix/swift4
Browse files Browse the repository at this point in the history
Update to swift 4
  • Loading branch information
onmyway133 authored Oct 20, 2017
2 parents bc64abc + 8e9f19a commit 313171d
Show file tree
Hide file tree
Showing 18 changed files with 492 additions and 53 deletions.
4 changes: 0 additions & 4 deletions .slather.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
4.0
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions Keychains.podspec
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Pod::Spec.new do |s|
s.name = "Keychains"
s.summary = "A keychain wrapper that is so easy to use that your cat could use it."
s.version = "1.0.0"
s.version = "2.0.0"
s.homepage = "https://github.com/hyperoslo/Keychains"
s.license = 'MIT'
s.author = { "Hyper Interaktiv AS" => "[email protected]" }
s.source = { :git => "https://github.com/hyperoslo/Keychains.git", :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/hyperoslo'

s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.9'
s.ios.deployment_target = '9.0'
s.osx.deployment_target = '10.10'

s.requires_arc = true
s.ios.source_files = 'Source/{iOS,Shared}/**/*'
Expand Down
196 changes: 181 additions & 15 deletions Keychains.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
BuildableIdentifier = "primary"
BlueprintIdentifier = "BDA447E11C294B45003FDEAD"
BuildableName = "Keychains.framework"
BlueprintName = "Keychains-Mac"
BlueprintName = "Keychains-macOS"
ReferencedContainer = "container:Keychains.xcodeproj">
</BuildableReference>
</BuildActionEntry>
Expand All @@ -34,8 +34,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BDA447EA1C294B45003FDEAD"
BuildableName = "Tests-Mac.xctest"
BlueprintName = "Tests-Mac"
BuildableName = "Tests-macOS.xctest"
BlueprintName = "Tests-macOS"
ReferencedContainer = "container:Keychains.xcodeproj">
</BuildableReference>
</TestableReference>
Expand All @@ -45,7 +45,7 @@
BuildableIdentifier = "primary"
BlueprintIdentifier = "BDA447E11C294B45003FDEAD"
BuildableName = "Keychains.framework"
BlueprintName = "Keychains-Mac"
BlueprintName = "Keychains-macOS"
ReferencedContainer = "container:Keychains.xcodeproj">
</BuildableReference>
</MacroExpansion>
Expand All @@ -68,7 +68,7 @@
BuildableIdentifier = "primary"
BlueprintIdentifier = "BDA447E11C294B45003FDEAD"
BuildableName = "Keychains.framework"
BlueprintName = "Keychains-Mac"
BlueprintName = "Keychains-macOS"
ReferencedContainer = "container:Keychains.xcodeproj">
</BuildableReference>
</MacroExpansion>
Expand All @@ -86,7 +86,7 @@
BuildableIdentifier = "primary"
BlueprintIdentifier = "BDA447E11C294B45003FDEAD"
BuildableName = "Keychains.framework"
BlueprintName = "Keychains-Mac"
BlueprintName = "Keychains-macOS"
ReferencedContainer = "container:Keychains.xcodeproj">
</BuildableReference>
</MacroExpansion>
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Keychain
# Keychains

[![CI Status](http://img.shields.io/travis/hyperoslo/Keychain.svg?style=flat)](https://travis-ci.org/hyperoslo/Keychain)
[![Version](https://img.shields.io/cocoapods/v/Keychain.svg?style=flat)](http://cocoadocs.org/docsets/Keychain)
[![Version](https://img.shields.io/cocoapods/v/Keychains.svg?style=flat)](http://cocoadocs.org/docsets/Keychains)
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![License](https://img.shields.io/cocoapods/l/Keychain.svg?style=flat)](http://cocoadocs.org/docsets/Keychain)
[![Platform](https://img.shields.io/cocoapods/p/Keychain.svg?style=flat)](http://cocoadocs.org/docsets/Keychain)
[![License](https://img.shields.io/cocoapods/l/Keychains.svg?style=flat)](http://cocoadocs.org/docsets/Keychains)
[![Platform](https://img.shields.io/cocoapods/p/Keychains.svg?style=flat)](http://cocoadocs.org/docsets/Keychains)
![Swift](https://img.shields.io/badge/%20in-swift%204.0-orange.svg)

A keychain wrapper that is so easy to use that your cat could use it.

Expand All @@ -23,18 +23,18 @@ Keychain.deletePassword(forAccount: account)

## Installation

**Keychain** is available through [CocoaPods](http://cocoapods.org). To install
**Keychains** is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:

```ruby
pod 'Keychain'
pod 'Keychains'
```

**Keychain** is also available through [Carthage](https://github.com/Carthage/Carthage).
To install just write into your Cartfile:

```ruby
github "hyperoslo/Keychain"
github "hyperoslo/Keychains"
```

## Author
Expand All @@ -43,4 +43,4 @@ Hyper Interaktiv AS, [email protected]

## License

**Keychain** is available under the MIT license. See the LICENSE file for more info.
**Keychains** is available under the MIT license. See the LICENSE file for more info.
16 changes: 12 additions & 4 deletions Source/Shared/Keychain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ public struct Keychain {
/// - service: The service, this is for kSecAttrService
/// - accessGroup: The access group, this is for kSecAttrAccessGroup
/// - Returns: The password
public static func password(forAccount account: String, service: String = bundleIdentifier, accessGroup: String = "") -> String {
guard !service.isEmpty && !account.isEmpty else { return "" }
public static func password(forAccount account: String,
service: String = bundleIdentifier,
accessGroup: String = "") -> String? {
guard !service.isEmpty && !account.isEmpty else {
return nil
}

var query = [
kSecAttrAccount as String : account,
Expand All @@ -55,7 +59,9 @@ public struct Keychain {
/// - accessGroup: The access group, this is for kSecAttrAccessGroup
/// - Returns: True if the password can be set successfully
@discardableResult public static func setPassword(_ password: String, forAccount account: String, service: String = bundleIdentifier, accessGroup: String = "") -> Bool {
guard !service.isEmpty && !account.isEmpty else { return false }
guard !service.isEmpty && !account.isEmpty else {
return false
}

var query = [
kSecAttrAccount as String : account,
Expand All @@ -78,7 +84,9 @@ public struct Keychain {
/// - service: The service, this is for kSecAttrService
/// - Returns: True if the password can be safely deleted
@discardableResult public static func deletePassword(forAccount account: String, service: String = bundleIdentifier, accessGroup: String = "") -> Bool {
guard !service.isEmpty && !account.isEmpty else { return false }
guard !service.isEmpty && !account.isEmpty else {
return false
}

var query = [
kSecAttrAccount as String: account,
Expand Down
46 changes: 46 additions & 0 deletions TestHost_iOS/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// AppDelegate.swift
// TestHost_iOS
//
// Created by Khoa Pham on 20.10.2017.
// Copyright © 2017 Hyper Interaktiv AS. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

93 changes: 93 additions & 0 deletions TestHost_iOS/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
25 changes: 25 additions & 0 deletions TestHost_iOS/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
24 changes: 24 additions & 0 deletions TestHost_iOS/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>
Loading

0 comments on commit 313171d

Please sign in to comment.