From 16625d80932fd9dc7d6dba70d675f982d60b232b Mon Sep 17 00:00:00 2001 From: Felix Schulze Date: Tue, 17 Nov 2015 14:42:42 +0100 Subject: [PATCH] Migrate example app to Swift --- OpenSSL-for-iOS.xcodeproj/project.pbxproj | 45 ++++++------ OpenSSL-for-iOS/AppDelegate.h | 17 ----- OpenSSL-for-iOS/AppDelegate.m | 33 --------- OpenSSL-for-iOS/AppDelegate.swift | 35 +++++++++ .../OpenSSL-for-iOS-Bridging-Header.h | 6 ++ OpenSSL-for-iOS/ViewController.h | 21 ------ OpenSSL-for-iOS/ViewController.m | 71 ------------------- OpenSSL-for-iOS/ViewController.swift | 54 ++++++++++++++ OpenSSL-for-iOS/ViewController.xib | 4 +- OpenSSL-for-iOS/ViewController~tv.xib | 4 +- OpenSSL-for-iOS/main.m | 19 ----- OpenSSL-for-tvOS/Info.plist | 2 - README.md | 2 +- 13 files changed, 123 insertions(+), 190 deletions(-) delete mode 100644 OpenSSL-for-iOS/AppDelegate.h delete mode 100644 OpenSSL-for-iOS/AppDelegate.m create mode 100644 OpenSSL-for-iOS/AppDelegate.swift create mode 100644 OpenSSL-for-iOS/OpenSSL-for-iOS-Bridging-Header.h delete mode 100644 OpenSSL-for-iOS/ViewController.h delete mode 100644 OpenSSL-for-iOS/ViewController.m create mode 100644 OpenSSL-for-iOS/ViewController.swift delete mode 100644 OpenSSL-for-iOS/main.m diff --git a/OpenSSL-for-iOS.xcodeproj/project.pbxproj b/OpenSSL-for-iOS.xcodeproj/project.pbxproj index b347e02..2282fd5 100644 --- a/OpenSSL-for-iOS.xcodeproj/project.pbxproj +++ b/OpenSSL-for-iOS.xcodeproj/project.pbxproj @@ -7,21 +7,19 @@ objects = { /* Begin PBXBuildFile section */ - 2A1DDC8D1BFB1C5D00F7722A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 533ED30B1528C4840005C6FA /* main.m */; }; 2A1DDC8F1BFB1DF600F7722A /* ViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2A1DDC8E1BFB1DF600F7722A /* ViewController.xib */; }; + 2A3821001BFB5EEB00328618 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A3820FF1BFB5EEB00328618 /* AppDelegate.swift */; }; + 2A3821021BFB607A00328618 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A3821011BFB607A00328618 /* ViewController.swift */; }; + 2A3821161BFB641E00328618 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A3820FF1BFB5EEB00328618 /* AppDelegate.swift */; }; + 2A3821171BFB642000328618 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A3821011BFB607A00328618 /* ViewController.swift */; }; 2A8A9A7E1BFA59F7002944B4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2A8A9A7D1BFA59F7002944B4 /* Assets.xcassets */; }; 2A8A9A851BFA5AFF002944B4 /* ViewController~tv.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2A8A9A841BFA5AFF002944B4 /* ViewController~tv.xib */; }; - 2A8A9A861BFA5B04002944B4 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 533ED3121528C4840005C6FA /* ViewController.m */; }; 2A8A9A871BFA5B6A002944B4 /* FSOpenSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = D1E97EE2A904D58DAE4231E2 /* FSOpenSSL.m */; }; 2A8A9A8A1BFA5B85002944B4 /* libcrypto-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A8A9A881BFA5B85002944B4 /* libcrypto-tvOS.a */; }; 2A8A9A8B1BFA5B85002944B4 /* libssl-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A8A9A891BFA5B85002944B4 /* libssl-tvOS.a */; }; - 2A8A9A8D1BFA7B79002944B4 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 533ED30F1528C4840005C6FA /* AppDelegate.m */; }; 533ED3001528C4840005C6FA /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 533ED2FF1528C4840005C6FA /* UIKit.framework */; }; 533ED3021528C4840005C6FA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 533ED3011528C4840005C6FA /* Foundation.framework */; }; 533ED3041528C4840005C6FA /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 533ED3031528C4840005C6FA /* CoreGraphics.framework */; }; - 533ED30C1528C4840005C6FA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 533ED30B1528C4840005C6FA /* main.m */; }; - 533ED3101528C4840005C6FA /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 533ED30F1528C4840005C6FA /* AppDelegate.m */; }; - 533ED3131528C4840005C6FA /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 533ED3121528C4840005C6FA /* ViewController.m */; }; 533ED32C1528C53B0005C6FA /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 533ED32A1528C53B0005C6FA /* libcrypto.a */; }; 533ED32D1528C53B0005C6FA /* libssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 533ED32B1528C53B0005C6FA /* libssl.a */; }; 534FB2AE180975D700B5F868 /* Icons.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 534FB2AD180975D700B5F868 /* Icons.xcassets */; }; @@ -45,6 +43,9 @@ /* Begin PBXFileReference section */ 2A1DDC8E1BFB1DF600F7722A /* ViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ViewController.xib; sourceTree = ""; }; + 2A3820FE1BFB5EEA00328618 /* OpenSSL-for-iOS-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "OpenSSL-for-iOS-Bridging-Header.h"; sourceTree = ""; }; + 2A3820FF1BFB5EEB00328618 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 2A3821011BFB607A00328618 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 2A8A9A6F1BFA59F7002944B4 /* OpenSSL-for-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "OpenSSL-for-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 2A8A9A7D1BFA59F7002944B4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 2A8A9A7F1BFA59F7002944B4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -56,12 +57,7 @@ 533ED3011528C4840005C6FA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 533ED3031528C4840005C6FA /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 533ED3071528C4840005C6FA /* OpenSSL-for-iOS-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "OpenSSL-for-iOS-Info.plist"; sourceTree = ""; }; - 533ED30B1528C4840005C6FA /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 533ED30D1528C4840005C6FA /* OpenSSL-for-iOS-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "OpenSSL-for-iOS-Prefix.pch"; sourceTree = ""; }; - 533ED30E1528C4840005C6FA /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; - 533ED30F1528C4840005C6FA /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 533ED3111528C4840005C6FA /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; - 533ED3121528C4840005C6FA /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 533ED32A1528C53B0005C6FA /* libcrypto.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcrypto.a; path = lib/libcrypto.a; sourceTree = ""; }; 533ED32B1528C53B0005C6FA /* libssl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libssl.a; path = lib/libssl.a; sourceTree = ""; }; 534FB2AD180975D700B5F868 /* Icons.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Icons.xcassets; sourceTree = ""; }; @@ -163,10 +159,8 @@ 533ED3051528C4840005C6FA /* OpenSSL-for-iOS */ = { isa = PBXGroup; children = ( - 533ED30E1528C4840005C6FA /* AppDelegate.h */, - 533ED30F1528C4840005C6FA /* AppDelegate.m */, - 533ED3111528C4840005C6FA /* ViewController.h */, - 533ED3121528C4840005C6FA /* ViewController.m */, + 2A3820FF1BFB5EEB00328618 /* AppDelegate.swift */, + 2A3821011BFB607A00328618 /* ViewController.swift */, 2A1DDC8E1BFB1DF600F7722A /* ViewController.xib */, 2A8A9A841BFA5AFF002944B4 /* ViewController~tv.xib */, 533ED3061528C4840005C6FA /* Supporting Files */, @@ -181,8 +175,8 @@ isa = PBXGroup; children = ( 533ED3071528C4840005C6FA /* OpenSSL-for-iOS-Info.plist */, - 533ED30B1528C4840005C6FA /* main.m */, 533ED30D1528C4840005C6FA /* OpenSSL-for-iOS-Prefix.pch */, + 2A3820FE1BFB5EEA00328618 /* OpenSSL-for-iOS-Bridging-Header.h */, ); name = "Supporting Files"; sourceTree = ""; @@ -360,9 +354,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2A8A9A8D1BFA7B79002944B4 /* AppDelegate.m in Sources */, - 2A8A9A861BFA5B04002944B4 /* ViewController.m in Sources */, - 2A1DDC8D1BFB1C5D00F7722A /* main.m in Sources */, + 2A3821161BFB641E00328618 /* AppDelegate.swift in Sources */, + 2A3821171BFB642000328618 /* ViewController.swift in Sources */, 2A8A9A871BFA5B6A002944B4 /* FSOpenSSL.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -371,9 +364,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 533ED30C1528C4840005C6FA /* main.m in Sources */, - 533ED3101528C4840005C6FA /* AppDelegate.m in Sources */, - 533ED3131528C4840005C6FA /* ViewController.m in Sources */, + 2A3821001BFB5EEB00328618 /* AppDelegate.swift in Sources */, + 2A3821021BFB607A00328618 /* ViewController.swift in Sources */, D1E978031547EE765CD39AD2 /* FSOpenSSL.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -431,6 +423,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "de.felixschulze.OpenSSL-for-tvOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; + SWIFT_OBJC_BRIDGING_HEADER = "OpenSSL-for-iOS/OpenSSL-for-iOS-Bridging-Header.h"; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -461,6 +454,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "de.felixschulze.OpenSSL-for-tvOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; + SWIFT_OBJC_BRIDGING_HEADER = "OpenSSL-for-iOS/OpenSSL-for-iOS-Bridging-Header.h"; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -546,15 +540,19 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + CLANG_ENABLE_MODULES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "OpenSSL-for-iOS/OpenSSL-for-iOS-Prefix.pch"; INFOPLIST_FILE = "OpenSSL-for-iOS/OpenSSL-for-iOS-Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/lib\"", ); PRODUCT_BUNDLE_IDENTIFIER = "de.felixschulze.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = OpenSSL; + SWIFT_OBJC_BRIDGING_HEADER = "OpenSSL-for-iOS/OpenSSL-for-iOS-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; WRAPPER_EXTENSION = app; }; name = Debug; @@ -564,15 +562,18 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + CLANG_ENABLE_MODULES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "OpenSSL-for-iOS/OpenSSL-for-iOS-Prefix.pch"; INFOPLIST_FILE = "OpenSSL-for-iOS/OpenSSL-for-iOS-Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/lib\"", ); PRODUCT_BUNDLE_IDENTIFIER = "de.felixschulze.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = OpenSSL; + SWIFT_OBJC_BRIDGING_HEADER = "OpenSSL-for-iOS/OpenSSL-for-iOS-Bridging-Header.h"; WRAPPER_EXTENSION = app; }; name = Release; diff --git a/OpenSSL-for-iOS/AppDelegate.h b/OpenSSL-for-iOS/AppDelegate.h deleted file mode 100644 index 1e31642..0000000 --- a/OpenSSL-for-iOS/AppDelegate.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// AppDelegate.h -// OpenSSL-for-iOS -// -// Created by Felix Schulze on 04.12.2010. -// Updated by Schulze Felix on 01.04.12. -// Copyright (c) 2012 Felix Schulze . All rights reserved. -// Web: http://www.felixschulze.de -// - -#import - -@interface AppDelegate : UIResponder - -@property (strong, nonatomic) UIWindow *window; - -@end diff --git a/OpenSSL-for-iOS/AppDelegate.m b/OpenSSL-for-iOS/AppDelegate.m deleted file mode 100644 index 04952f5..0000000 --- a/OpenSSL-for-iOS/AppDelegate.m +++ /dev/null @@ -1,33 +0,0 @@ -// -// AppDelegate.m -// OpenSSL-for-iOS -// -// Created by Felix Schulze on 04.12.2010. -// Updated by Schulze Felix on 01.04.12. -// Copyright (c) 2012 Felix Schulze . All rights reserved. -// Web: http://www.felixschulze.de -// - -#import "AppDelegate.h" -#import "ViewController.h" - -@implementation AppDelegate - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions -{ - self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - - UIViewController *viewController = [[ViewController alloc] init]; -#if TARGET_OS_TV - self.window.rootViewController = viewController; -#else - UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController]; - navigationController.navigationBar.translucent = NO; - self.window.rootViewController = navigationController; -#endif - [self.window makeKeyAndVisible]; - return YES; -} - - -@end diff --git a/OpenSSL-for-iOS/AppDelegate.swift b/OpenSSL-for-iOS/AppDelegate.swift new file mode 100644 index 0000000..64192a1 --- /dev/null +++ b/OpenSSL-for-iOS/AppDelegate.swift @@ -0,0 +1,35 @@ +// +// AppDelegate.swift +// OpenSSL-for-iOS +// +// Created by Felix Schulze on 04.12.2010. +// Updated by Felix Schulze on 17.11.2015. +// Copyright © 2015 Felix Schulze. All rights reserved. +// Web: http://www.felixschulze.de +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + + self.window = UIWindow(frame: UIScreen.mainScreen().bounds) + + #if os(tvOS) + self.window?.rootViewController = ViewController(nibName: "ViewController~tv", bundle: nil) + #else + let navigationController = UINavigationController(rootViewController: ViewController()) + navigationController.navigationBar.translucent = false + self.window?.rootViewController = navigationController + #endif + + self.window?.makeKeyAndVisible() + return true + } + +} + diff --git a/OpenSSL-for-iOS/OpenSSL-for-iOS-Bridging-Header.h b/OpenSSL-for-iOS/OpenSSL-for-iOS-Bridging-Header.h new file mode 100644 index 0000000..a822272 --- /dev/null +++ b/OpenSSL-for-iOS/OpenSSL-for-iOS-Bridging-Header.h @@ -0,0 +1,6 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + +#import "FSOpenSSL.h" +#include \ No newline at end of file diff --git a/OpenSSL-for-iOS/ViewController.h b/OpenSSL-for-iOS/ViewController.h deleted file mode 100644 index 5876f69..0000000 --- a/OpenSSL-for-iOS/ViewController.h +++ /dev/null @@ -1,21 +0,0 @@ -// -// ViewController.h -// OpenSSL-for-iOS -// -// Created by Felix Schulze on 04.12.2010. -// Updated by Schulze Felix on 01.04.12. -// Copyright (c) 2012 Felix Schulze . All rights reserved. -// Web: http://www.felixschulze.de -// - -#import - -@interface ViewController : UIViewController - -@property (nonatomic, strong) IBOutlet UITextField *textField; -@property (nonatomic, strong) IBOutlet UILabel *md5TextField; -@property (nonatomic, strong) IBOutlet UILabel *sha256TextField; - -- (IBAction)showInfo; - -@end diff --git a/OpenSSL-for-iOS/ViewController.m b/OpenSSL-for-iOS/ViewController.m deleted file mode 100644 index 05c0aa6..0000000 --- a/OpenSSL-for-iOS/ViewController.m +++ /dev/null @@ -1,71 +0,0 @@ -// -// ViewController.m -// OpenSSL-for-iOS -// -// Created by Felix Schulze on 04.12.2010. -// Updated by Schulze Felix on 01.04.12. -// Copyright (c) 2012 Felix Schulze . All rights reserved. -// Web: http://www.felixschulze.de -// - -#import "ViewController.h" -#import "FSOpenSSL.h" -#include - -@implementation ViewController - -- (instancetype)init -{ - NSString *nibName = @"ViewController"; -#if TARGET_OS_TV - nibName = @"ViewController~tv"; -#endif - self = [super initWithNibName:nibName bundle:nil]; - if (self) { - - } - return self; -} - -- (void)viewDidLoad -{ - self.title = @"OpenSSL-for-iOS"; - UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight]; - [infoButton addTarget:self action:@selector(showInfo) forControlEvents:UIControlEventTouchUpInside]; - self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:infoButton]; - - [_textField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged]; - - [self calculateHash]; - - [super viewDidLoad]; -} - -- (IBAction)textFieldDidChange:(id)sender -{ - [self calculateHash]; -} - -- (void)calculateHash -{ - if (_textField.text.length > 0) - { - _md5TextField.text = [FSOpenSSL md5FromString:_textField.text]; - _sha256TextField.text = [FSOpenSSL sha256FromString:_textField.text]; - } - else - { - _md5TextField.text = nil; - _sha256TextField.text = nil; - } -} - -- (IBAction)showInfo -{ - NSString *message = [NSString stringWithFormat:@"OpenSSL-Version: %@\nLicense: See include/LICENSE\n\nCopyright 2010-2015 by Felix Schulze\n http://www.felixschulze.de", @OPENSSL_VERSION_TEXT]; - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"OpenSSL-for-iOS" message:message preferredStyle:UIAlertControllerStyleAlert]; - [alertController addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleCancel handler:nil]]; - [self presentViewController:alertController animated:YES completion:nil]; -} - -@end diff --git a/OpenSSL-for-iOS/ViewController.swift b/OpenSSL-for-iOS/ViewController.swift new file mode 100644 index 0000000..32c7e33 --- /dev/null +++ b/OpenSSL-for-iOS/ViewController.swift @@ -0,0 +1,54 @@ +// +// ViewController.swift +// OpenSSL-for-iOS +// +// Created by Felix Schulze on 04.12.2010. +// Updated by Felix Schulze on 17.11.2015. +// Copyright © 2015 Felix Schulze. All rights reserved. +// Web: http://www.felixschulze.de +// + +import UIKit + +class ViewController: UIViewController { + + @IBOutlet var textField: UITextField! + @IBOutlet var md5Label: UILabel! + @IBOutlet var sh256Label: UILabel! + + @IBAction + func showInfo() { + let message = "OpenSSL-Version: \(OPENSSL_VERSION_TEXT)\nLicense: See include/LICENSE\n\nCopyright 2010-2015 by Felix Schulze\n http://www.felixschulze.de" + let alertController = UIAlertController(title: "OpenSSL-for-iOS", message: message, preferredStyle: .Alert) + alertController.addAction(UIAlertAction(title: "Ok", style: .Cancel, handler: nil)) + self.presentViewController(alertController, animated: true, completion: nil) + } + + override func viewDidLoad() { + super.viewDidLoad() + + self.title = "OpenSSL-for-iOS" + let infoButton = UIButton(type: .InfoLight) + infoButton.addTarget(self, action: "showInfo", forControlEvents: .TouchDown) + self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: infoButton) + + self.textField.addTarget(self, action: "textFieldDidChange", forControlEvents: .EditingChanged) + self.calculateHash() + } + + func textFieldDidChange() { + self.calculateHash() + } + + func calculateHash() { + if textField.text!.characters.count > 0 { + md5Label.text = FSOpenSSL.md5FromString(textField.text) + sh256Label.text = FSOpenSSL.sha256FromString(textField.text) + } + else { + md5Label.text = nil + sh256Label.text = nil + } + } + +} diff --git a/OpenSSL-for-iOS/ViewController.xib b/OpenSSL-for-iOS/ViewController.xib index eabb087..4e2862e 100644 --- a/OpenSSL-for-iOS/ViewController.xib +++ b/OpenSSL-for-iOS/ViewController.xib @@ -7,8 +7,8 @@ - - + + diff --git a/OpenSSL-for-iOS/ViewController~tv.xib b/OpenSSL-for-iOS/ViewController~tv.xib index b5dad3b..8b9d1ff 100644 --- a/OpenSSL-for-iOS/ViewController~tv.xib +++ b/OpenSSL-for-iOS/ViewController~tv.xib @@ -6,8 +6,8 @@ - - + + diff --git a/OpenSSL-for-iOS/main.m b/OpenSSL-for-iOS/main.m deleted file mode 100644 index f7ab801..0000000 --- a/OpenSSL-for-iOS/main.m +++ /dev/null @@ -1,19 +0,0 @@ -// -// main.m -// OpenSSL-for-iOS -// -// Created by Felix Schulze on 04.12.2010. -// Updated by Schulze Felix on 01.04.12. -// Copyright (c) 2012 Felix Schulze . All rights reserved. -// Web: http://www.felixschulze.de -// - -#import -#import "AppDelegate.h" - -int main(int argc, char *argv[]) -{ - @autoreleasepool { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); - } -} diff --git a/OpenSSL-for-tvOS/Info.plist b/OpenSSL-for-tvOS/Info.plist index 4f33860..4aa5d31 100644 --- a/OpenSSL-for-tvOS/Info.plist +++ b/OpenSSL-for-tvOS/Info.plist @@ -22,8 +22,6 @@ 1 LSRequiresIPhoneOS - UIMainStoryboardFile - Main UIRequiredDeviceCapabilities arm64 diff --git a/README.md b/README.md index 8b7b833..62ae4a6 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ If you have problems building for arm64 please uninstall MacPorts (see #28). * ## Changelog -* 2015-11-17: tvOS example app +* 2015-11-17: tvOS example app, Migrate to Swift for example app * 2015-11-16: tvOS support * 2015-10-25: Xcode 7.1 support * 2015-08-06: iOS 9.0 support, Bitcode support