Skip to content

Commit fe24cba

Browse files
authored
Feature/swift3 (#235)
* Bump components * Updated dependencies * WIP * Auto conversion * Conversion * Post-Automatic conversion * Conversion WIP2 * Building version * !! Commented classes that crash swift compiler !! * Porting tests WIP * Tests WIP * Fix some runtime crashes introduces by the Swift 3 migrator * Annotate `Button` initializer as nonnull * Tests compilation * Corrected random compilation bug * Fixed ArticleView compilation * ProfileClientViewController compilation * Fixed crashes * Check if AVExportSession initializer returned nil This is to make sure to workaround this issue: http://stackoverflow.com/questions/39539894/avassetsession-initasset-avasset-presetname-string-returns-nil * Fixed tests crashing * Updated correct snapshots * Add NSPhotoLibraryUsageDescription to Info.plist, update dependencies * Location tests fix * Temporarily green all tests * TEMPORARILY disable AVS on simulator * Added request strategy * Removed unnecessary code
1 parent 6a09740 commit fe24cba

File tree

404 files changed

+4445
-4241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

404 files changed

+4445
-4241
lines changed

Cartfile

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
github "wireapp/wire-ios-ziphy" ~> 3.0
1+
github "wireapp/wire-ios-ziphy" ~> 4.0.1
22
github "wireapp/SmoothLineView" "0.1.12-wire-ft"
33
github "wireapp/TSMarkdownParser" ~> 1.0.17
44
github "wireapp/Classy" "v0.2.6"
5-
github "wireapp/CocoaLumberjack" "2.2.1-wire"
6-
github "wireapp/Cartography" "z0.6.1"
5+
github "wireapp/CocoaLumberjack" "2.4.0-swift3"
6+
github "wireapp/Cartography" "z0.6.1-swift3"
77
github "wireapp/TTTAttributedLabel" "2.0.0"
8-
github "wireapp/ZipArchive" ~> 1.3
8+
github "wireapp/ZipArchive" "1.6.1-swift3"
99
github "wireapp/HockeySDK-iOS" "4.0.1"
10-
github "wireapp/wire-ios-sync-engine" ~> 52.7.0
10+
github "wireapp/wire-ios-sync-engine" ~> 53.0.0
1111
github "wireapp/onepassword-app-extension" "framework/1.8.2"
1212
github "wireapp/FormatterKit" ~> 1.8.1
1313
github "wireapp/VIMNetworking" "v6.0.2-wire-carthage-2"

Cartfile.private

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
github "wireapp/ocmock" == 3.1.3
2-
github "wireapp/ios-snapshot-test-case" == 2.1.0
2+
github "wireapp/ios-snapshot-test-case" "2.1.3-swift3"
33

Cartfile.resolved

+17-16
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
github "wireapp/AFNetworking" "2.6.3-iOS8"
2-
github "wireapp/Cartography" "z0.6.1"
2+
github "wireapp/Cartography" "z0.6.1-swift3"
33
github "wireapp/Classy" "v0.2.6"
4-
github "wireapp/CocoaLumberjack" "2.2.1-wire"
4+
github "wireapp/CocoaLumberjack" "2.4.0-swift3"
55
github "wireapp/FormatterKit" "1.8.1"
66
github "wireapp/HockeySDK-iOS" "4.0.1"
77
github "wireapp/PINCache" "2.3"
88
github "wireapp/SmoothLineView" "0.1.12-wire-ft"
99
github "wireapp/TSMarkdownParser" "1.0.17"
1010
github "wireapp/TTTAttributedLabel" "2.0.0"
1111
github "wireapp/VIMNetworking" "v6.0.2-wire-carthage-2"
12-
github "wireapp/ZipArchive" "v1.3"
13-
github "wireapp/ios-snapshot-test-case" "2.1.0"
12+
github "wireapp/ZipArchive" "1.6.1-swift3"
13+
github "wireapp/ios-snapshot-test-case" "2.1.3-swift3"
1414
github "wireapp/libPhoneNumber-iOS" "0.8.12"
1515
github "wireapp/ocmock" "v3.1.3"
1616
github "wireapp/onepassword-app-extension" "framework/1.8.2"
17-
github "wireapp/ono" "1.2.3"
18-
github "wireapp/protobuf-objc" "1.9.11"
19-
github "wireapp/wire-ios-cryptobox" "3.1.4"
20-
github "wireapp/wire-ios-system" "14.40.4"
21-
github "wireapp/wire-ios-ziphy" "3.0.2"
22-
github "wireapp/wire-ios-link-preview" "3.7.0"
23-
github "wireapp/wire-ios-utilities" "10.30.3"
24-
github "wireapp/wire-ios-images" "4.18.5"
25-
github "wireapp/wire-ios-transport" "9.0.1"
26-
github "wireapp/wire-ios-protos" "6.4.2"
27-
github "wireapp/wire-ios-data-model" "17.0.4"
28-
github "wireapp/wire-ios-sync-engine" "52.7.0"
17+
github "wireapp/ono" "1.3.0"
18+
github "wireapp/protobuf-objc" "1.9.12"
19+
github "wireapp/wire-ios-cryptobox" "4.0.0"
20+
github "wireapp/wire-ios-system" "15.0.0"
21+
github "wireapp/wire-ios-ziphy" "4.0.1"
22+
github "wireapp/wire-ios-link-preview" "4.0.1"
23+
github "wireapp/wire-ios-utilities" "11.0.3"
24+
github "wireapp/wire-ios-images" "5.0.0"
25+
github "wireapp/wire-ios-transport" "11.2.2"
26+
github "wireapp/wire-ios-protos" "7.2.1"
27+
github "wireapp/wire-ios-data-model" "18.1.0"
28+
github "wireapp/wire-ios-request-strategy" "2.0.1"
29+
github "wireapp/wire-ios-sync-engine" "53.0.0"

Wire-Sharing-Extension-iOS/ConversationListCell.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ class ConversationListCell: UITableViewCell {
6767
}
6868
}
6969

70-
@IBOutlet private weak var conversationNameLabel: UILabel!
71-
@IBOutlet private weak var conversationAvatarView: AvatarImageView!
70+
@IBOutlet fileprivate weak var conversationNameLabel: UILabel!
71+
@IBOutlet fileprivate weak var conversationAvatarView: AvatarImageView!
7272

7373
override func awakeFromNib() {
7474
super.awakeFromNib()
7575
// Initialization code
7676
}
7777

78-
override func setSelected(selected: Bool, animated: Bool) {
78+
override func setSelected(_ selected: Bool, animated: Bool) {
7979
super.setSelected(selected, animated: animated)
8080

8181
// Configure the view for the selected state

Wire-Sharing-Extension-iOS/ConversationListViewController.swift

+24-24
Original file line numberDiff line numberDiff line change
@@ -26,47 +26,47 @@ import Classy
2626

2727

2828
@objc protocol ConversationListViewControllerDelegate {
29-
optional func conversationList(conversationList: ConversationListViewController, didSelectConversation conversation:Conversation)
29+
optional func conversationList(_ conversationList: ConversationListViewController, didSelectConversation conversation:Conversation)
3030
}
3131

3232

3333

3434
class ConversationListViewController: UITableViewController {
3535

36-
@IBOutlet private weak var backButton: IconButton!
37-
@IBOutlet private weak var cancelButton: IconButton!
36+
@IBOutlet fileprivate weak var backButton: IconButton!
37+
@IBOutlet fileprivate weak var cancelButton: IconButton!
3838

3939
override func viewDidLoad() {
4040
super.viewDidLoad()
4141

4242
self.tableView.estimatedRowHeight = 52.0
4343
self.tableView.rowHeight = UITableViewAutomaticDimension
4444

45-
let image = UIImage(forLogoWithColor: UIColor.accentColor, iconSize: .Medium)
45+
let image = UIImage(forLogoWith: UIColor.accentColor, iconSize: .medium)
4646
self.navigationItem.titleView = UIImageView(image: image)
4747

48-
self.cancelButton.setIcon(.X, withSize: .Tiny, forState: .Normal)
49-
self.backButton.setIcon(.ChevronLeft, withSize: .Tiny, forState: .Normal)
48+
self.cancelButton.setIcon(.X, with: .tiny, for: UIControlState())
49+
self.backButton.setIcon(.chevronLeft, with: .tiny, for: UIControlState())
5050

51-
let barButtonOffset: CGFloat = (self.traitCollection.userInterfaceIdiom == .Phone) ? 8 : 4
51+
let barButtonOffset: CGFloat = (self.traitCollection.userInterfaceIdiom == .phone) ? 8 : 4
5252
if let leftItem = self.navigationItem.leftBarButtonItem {
53-
let leftSpacer = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FixedSpace, target: nil, action: nil)
53+
let leftSpacer = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.fixedSpace, target: nil, action: nil)
5454
leftSpacer.width = barButtonOffset
5555
self.navigationItem.leftBarButtonItems = [leftSpacer, leftItem]
5656
}
5757

5858
if let rightItem = self.navigationItem.rightBarButtonItem {
59-
let rightSpacer = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FixedSpace, target: nil, action: nil)
59+
let rightSpacer = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.fixedSpace, target: nil, action: nil)
6060
rightSpacer.width = barButtonOffset
6161
self.navigationItem.rightBarButtonItems = [rightSpacer, rightItem]
6262
}
6363
}
6464

65-
override func viewWillAppear(animated: Bool) {
65+
override func viewWillAppear(_ animated: Bool) {
6666
super.viewWillAppear(animated)
6767
}
6868

69-
override func viewDidAppear(animated: Bool) {
69+
override func viewDidAppear(_ animated: Bool) {
7070
super.viewDidAppear(animated)
7171

7272
// Following manual Classy update is a workarround for a bug:
@@ -89,29 +89,29 @@ class ConversationListViewController: UITableViewController {
8989
var searchTerm: String = "" {
9090
didSet {
9191
self.tableView.reloadData()
92-
if (self.tableView.numberOfRowsInSection(0) > 0) {
93-
self.tableView.scrollToRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 0), atScrollPosition: .Top, animated: false)
92+
if (self.tableView.numberOfRows(inSection: 0) > 0) {
93+
self.tableView.scrollToRow(at: IndexPath(row: 0, section: 0), at: .top, animated: false)
9494
}
9595
}
9696
}
9797

9898
var excludedConversations: Array<Conversation> = [] {
9999
didSet {
100100
self.tableView.reloadData()
101-
if (self.tableView.numberOfRowsInSection(0) > 0) {
102-
self.tableView.scrollToRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 0), atScrollPosition: .Top, animated: false)
101+
if (self.tableView.numberOfRows(inSection: 0) > 0) {
102+
self.tableView.scrollToRow(at: IndexPath(row: 0, section: 0), at: .top, animated: false)
103103
}
104104
}
105105
}
106106

107107
// MARK: - Actions
108108

109-
@IBAction func backButtonPressed(sender: AnyObject) {
110-
self.navigationController?.popViewControllerAnimated(true)
109+
@IBAction func backButtonPressed(_ sender: AnyObject) {
110+
self.navigationController?.popViewController(animated: true)
111111
}
112112

113-
@IBAction func cancelPressed(sender: AnyObject) {
114-
self.extensionContext!.cancelRequestWithError(NSError(domain: NSCocoaErrorDomain, code: NSUserCancelledError, userInfo: nil))
113+
@IBAction func cancelPressed(_ sender: AnyObject) {
114+
self.extensionContext!.cancelRequest(withError: NSError(domain: NSCocoaErrorDomain, code: NSUserCancelledError, userInfo: nil))
115115
}
116116

117117
// MARK: - API
@@ -158,16 +158,16 @@ class ConversationListViewController: UITableViewController {
158158

159159
// MARK: - Table view data source
160160

161-
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
161+
override func numberOfSections(in tableView: UITableView) -> Int {
162162
return 1
163163
}
164164

165-
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
165+
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
166166
return self.filteredModel.count
167167
}
168168

169-
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
170-
let cell = tableView.dequeueReusableCellWithIdentifier("ConversationListCell", forIndexPath: indexPath) as! ConversationListCell
169+
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
170+
let cell = tableView.dequeueReusableCell(withIdentifier: "ConversationListCell", for: indexPath) as! ConversationListCell
171171

172172
let conversation = self.filteredModel[indexPath.row]
173173
cell.conversation = conversation
@@ -182,7 +182,7 @@ class ConversationListViewController: UITableViewController {
182182

183183
// MARK: - Table view delegate
184184

185-
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
185+
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
186186
self.delegate?.conversationList?(self, didSelectConversation: self.filteredModel[indexPath.row])
187187
}
188188

Wire-Sharing-Extension-iOS/ExtensionHelpers/Analytics.swift

+13-13
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,32 @@ enum AnalyticsEventAttribute {
3737
case cancel(String)
3838

3939
func keyValue() -> (key: String, value: AnyObject) {
40-
var keyValue: (String, AnyObject) = ("", 0)
40+
var keyValue: (String, AnyObject) = ("", 0 as AnyObject)
4141
switch self {
42-
case .numberOfImages(let value): keyValue = ("numberOfImages", value)
43-
case .hasURL(let value): keyValue = ("hasURL", value)
44-
case .hasText(let value): keyValue = ("hasText", value)
45-
case .numberOfRecipients(let value): keyValue = ("numberOfRecipients", value)
46-
case .numberOfGroupRecipients(let value): keyValue = ("numberOfGroupRecipients", value)
47-
case .numberOfOneOnOneRecipients(let value): keyValue = ("numberOfOneOnOneRecipients", value)
48-
case .cancel(let value): keyValue = ("cancel", value)
42+
case .numberOfImages(let value): keyValue = ("numberOfImages", value as AnyObject)
43+
case .hasURL(let value): keyValue = ("hasURL", value as AnyObject)
44+
case .hasText(let value): keyValue = ("hasText", value as AnyObject)
45+
case .numberOfRecipients(let value): keyValue = ("numberOfRecipients", value as AnyObject)
46+
case .numberOfGroupRecipients(let value): keyValue = ("numberOfGroupRecipients", value as AnyObject)
47+
case .numberOfOneOnOneRecipients(let value): keyValue = ("numberOfOneOnOneRecipients", value as AnyObject)
48+
case .cancel(let value): keyValue = ("cancel", value as AnyObject)
4949
}
5050
return keyValue
5151
}
5252
}
5353

5454
extension SharedAnalytics {
5555

56-
func tagEvent(name: String) {
56+
func tagEvent(_ name: String) {
5757
self.tagEvent(name, attributes: nil)
5858
}
5959

60-
func tagEvent(name: String, attributes: [NSObject: AnyObject]?) {
60+
func tagEvent(_ name: String, attributes: [AnyHashable: Any]?) {
6161
self.storeEvent(name, context: ShareExtensionContext, attributes: attributes)
6262
}
6363

64-
func tagEvent(event: AnalyticsEvent, attributes: [AnalyticsEventAttribute]) {
65-
var attributeDict: [NSObject: AnyObject] = [:]
64+
func tagEvent(_ event: AnalyticsEvent, attributes: [AnalyticsEventAttribute]) {
65+
var attributeDict: [AnyHashable: Any] = [:]
6666
for attribute in attributes {
6767
let keyValue = attribute.keyValue()
6868
attributeDict[keyValue.key] = keyValue.value
@@ -71,4 +71,4 @@ extension SharedAnalytics {
7171
self.tagEvent(event.rawValue, attributes: attributeDict)
7272
}
7373

74-
}
74+
}

Wire-Sharing-Extension-iOS/ExtensionHelpers/NSExtensionContext+Attachments.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ extension NSExtensionContext {
4040
return self.providersWithType(kUTTypeImage)
4141
}
4242

43-
func providersWithType(type: CFString) -> [NSItemProvider] {
43+
func providersWithType(_ type: CFString) -> [NSItemProvider] {
4444
var providers: [NSItemProvider] = []
4545
for extensionItem in self.extensionItems {
46-
providers.insertContentsOf(extensionItem.providersWithType(type), at: providers.count)
46+
providers.insert(extensionItem.providersWithType(type), at: providers.count)
4747
}
4848
return providers
4949
}

Wire-Sharing-Extension-iOS/ExtensionHelpers/NSExtensionItem+Attachments.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extension NSExtensionItem {
3636
return self.providersWithType(kUTTypeImage)
3737
}
3838

39-
func providersWithType(type: CFString) -> [NSItemProvider] {
39+
func providersWithType(_ type: CFString) -> [NSItemProvider] {
4040
if let itemProviderAttachments = self.attachments as? [NSItemProvider] {
4141
return itemProviderAttachments.filter { $0.hasItemConformingToTypeIdentifier(type as String) }
4242
}

Wire-Sharing-Extension-iOS/ExtensionHelpers/NSItemProvider+Attachments.swift

+13-13
Original file line numberDiff line numberDiff line change
@@ -24,38 +24,38 @@ import MobileCoreServices
2424

2525
extension NSItemProvider {
2626

27-
func loadText(completion:(String) -> Void) {
27+
func loadText(_ completion:@escaping (String) -> Void) {
2828
self.loadItemForTypeIdentifier(kUTTypePlainText) { (object: NSSecureCoding?, error: NSError!) -> Void in
2929
if let text = object as? String {
30-
dispatch_async(dispatch_get_main_queue()) {
30+
DispatchQueue.main.async {
3131
completion(text)
3232
}
3333
}
34-
}
34+
} as! (NSSecureCoding?, NSError?) -> Void as! (NSSecureCoding?, NSError?) -> Void as! (NSSecureCoding?, NSError?) -> Void as! (NSSecureCoding?, NSError?) -> Void as! (NSSecureCoding?, NSError?) -> Void as! (NSSecureCoding?, NSError?) -> Void
3535
}
3636

37-
func loadURL(completion:(NSURL) -> Void) {
37+
func loadURL(_ completion:@escaping (URL) -> Void) {
3838
self.loadItemForTypeIdentifier(kUTTypeURL) { (object: NSSecureCoding?, error: NSError!) -> Void in
39-
if let url = object as? NSURL {
40-
dispatch_async(dispatch_get_main_queue()) {
39+
if let url = object as? URL {
40+
DispatchQueue.main.async {
4141
completion(url)
4242
}
4343
}
44-
}
44+
} as! (NSSecureCoding?, NSError?) -> Void as! (NSSecureCoding?, NSError?) -> Void as! (NSSecureCoding?, NSError?) -> Void as! (NSSecureCoding?, NSError?) -> Void as! (NSSecureCoding?, NSError?) -> Void as! (NSSecureCoding?, NSError?) -> Void
4545
}
4646

47-
func loadImage(completion:(object: NSSecureCoding) -> Void) {
47+
func loadImage(_ completion:@escaping (_ object: NSSecureCoding) -> Void) {
4848
self.loadItemForTypeIdentifier(kUTTypeImage) { (object: NSSecureCoding?, error: NSError!) -> Void in
4949
if let imageObject = object {
50-
dispatch_async(dispatch_get_main_queue()) {
51-
completion(object: imageObject)
50+
DispatchQueue.main.async {
51+
completion(imageObject)
5252
}
5353
}
54-
}
54+
} as! (NSSecureCoding?, NSError?) -> Void as! (NSSecureCoding?, NSError?) -> Void as! (NSSecureCoding?, NSError?) -> Void as! (NSSecureCoding?, NSError?) -> Void as! (NSSecureCoding?, NSError?) -> Void as! (NSSecureCoding?, NSError?) -> Void
5555
}
5656

57-
private func loadItemForTypeIdentifier(typeIdentifier: CFString, completion:(object: NSSecureCoding?, error: NSError!) -> Void) {
58-
self.loadItemForTypeIdentifier(typeIdentifier as String, options: [:], completionHandler: completion)
57+
fileprivate func loadItemForTypeIdentifier(_ typeIdentifier: CFString, completion:@escaping (_ object: NSSecureCoding?, _ error: NSError?) -> Void) {
58+
self.loadItem(forTypeIdentifier: typeIdentifier as String, options: [:], completionHandler: completion)
5959
}
6060

6161
}

Wire-Sharing-Extension-iOS/ExtensionHelpers/NSString+URL.swift

+18-4
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,28 @@
1919

2020
import Foundation
2121

22-
extension NSString {
22+
public extension NSString {
2323
func containsURL() -> Bool {
2424
do {
25-
let urlDetector = try NSDataDetector(types: NSTextCheckingType.Link.rawValue)
26-
let matches = urlDetector.matchesInString(self as String, options: [], range: NSMakeRange(0, self.length))
25+
let urlDetector = try NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue)
26+
let matches = urlDetector.matches(in: self as String, options: [], range: NSMakeRange(0, self.length))
2727
return matches.count > 0
2828
} catch _ as NSError {
2929
return false
3030
}
3131
}
32-
}
32+
33+
// MARK: - URL Formatting
34+
35+
func removingPrefixWWW() -> String {
36+
return replacingOccurrences(of: "www.", with: "", options: .anchored, range: NSMakeRange(0, self.length))
37+
}
38+
39+
func removingTrailingForwardSlash() -> String {
40+
return replacingOccurrences(of: "/", with: "", options: [.anchored, .backwards], range: NSMakeRange(0, self.length))
41+
}
42+
43+
func removingURLScheme(_ scheme: String) -> String {
44+
return replacingOccurrences(of: scheme + "://", with: "", options: .anchored, range: NSMakeRange(0, self.length))
45+
}
46+
}

0 commit comments

Comments
 (0)