Skip to content

Commit

Permalink
fixed some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
evermeer committed Apr 17, 2019
1 parent 2bff105 commit eefb3c6
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 57 deletions.
16 changes: 10 additions & 6 deletions AppMessage/AppMessage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,13 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0710;
LastUpgradeCheck = 0900;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = mirabeau;
TargetAttributes = {
7F434A2219628D490081F35C = {
CreatedOnToolsVersion = 6.0;
DevelopmentTeam = X356V8CMHF;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
SystemCapabilities = {
com.apple.BackgroundModes = {
enabled = 1;
Expand Down Expand Up @@ -440,6 +440,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand All @@ -448,12 +449,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -494,6 +497,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand All @@ -502,12 +506,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -556,8 +562,7 @@
PROVISIONING_PROFILE = "";
SWIFT_OBJC_BRIDGING_HEADER = "AppMessage/AppMessage-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -580,8 +585,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_OBJC_BRIDGING_HEADER = "AppMessage/AppMessage-Bridging-Header.h";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0920"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -46,7 +45,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
2 changes: 1 addition & 1 deletion AppMessage/AppMessage/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

// Only call this line once. It will make sure the recordType are there in iCloud.
// After this, go to the iCloud dashboard and make all metadata for each recordType queryable and sortable!
Expand Down
2 changes: 2 additions & 0 deletions AppMessage/AppMessage/Async.swift
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,8 @@ public extension DispatchQoS.QoSClass {
case .utility: return "Utility"
case .background: return "Background"
case .unspecified: return "Unspecified"
@unknown default:
return "Unspecified"
}
}
}
Expand Down
23 changes: 12 additions & 11 deletions AppMessage/AppMessage/Controlers/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class ChatViewController: JSQMessagesViewController, UIActionSheetDelegate, Uzys
let filePath = (docDirPaths[0] as NSString).appendingPathComponent("\(id).png")
if let asset = item as? Asset {
if let image = asset.File?.image() {
if let myData = UIImagePNGRepresentation(image) {
if let myData = image.pngData() {
try? myData.write(to: URL(fileURLWithPath: filePath), options: [.atomic])
}
}
Expand Down Expand Up @@ -335,7 +335,7 @@ class ChatViewController: JSQMessagesViewController, UIActionSheetDelegate, Uzys
let docDirPath = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true)[0] as NSString
let filePath = docDirPath.appendingPathComponent("Image_\(i).png")
let image = getUIImageFromCTAsset(asset as! ALAsset)
if let myData = UIImagePNGRepresentation(image) {
if let myData = image.pngData() {
try? myData.write(to: URL(fileURLWithPath: filePath), options: [.atomic])
}

Expand Down Expand Up @@ -399,7 +399,7 @@ class ChatViewController: JSQMessagesViewController, UIActionSheetDelegate, Uzys
let representation: ALAssetRepresentation = (asset as ALAsset).defaultRepresentation()
let img: CGImage = representation.fullResolutionImage().takeUnretainedValue()
let scale: CGFloat = CGFloat(representation.scale())
let orientation: UIImageOrientation = UIImageOrientation(rawValue: representation.orientation().rawValue)!
let orientation: UIImage.Orientation = UIImage.Orientation(rawValue: representation.orientation().rawValue)!
let image: UIImage = UIImage(cgImage: img, scale: scale, orientation: orientation)

return image.resizedImageToFit(in: CGSize(width: 640, height: 640), scaleIfSmaller: true)
Expand Down Expand Up @@ -498,15 +498,15 @@ class ChatViewController: JSQMessagesViewController, UIActionSheetDelegate, Uzys
firstName = (EVCloudData.publicDB.dao.activeUser as? CKUserIdentity)?.nameComponents?.givenName ?? ""
lastName = (EVCloudData.publicDB.dao.activeUser as? CKUserIdentity)?.nameComponents?.familyName ?? ""
} else {
firstName = (EVCloudData.publicDB.dao.activeUser as? CKDiscoveredUserInfo)?.firstName ?? ""
lastName = (EVCloudData.publicDB.dao.activeUser as? CKDiscoveredUserInfo)?.lastName ?? ""
firstName = (EVCloudData.publicDB.dao.activeUser as? CKDiscoveredUserInfo)?.displayContact?.givenName ?? ""
lastName = (EVCloudData.publicDB.dao.activeUser as? CKDiscoveredUserInfo)?.displayContact?.familyName ?? ""
}

initials = "\(String(describing: firstName.characters.first)) \(String(describing: lastName.characters.first))"
initials = "\(String(describing: firstName.first)) \(String(describing: lastName.first))"
//initials = "\(Array(arrayLiteral: firstName)[0]) \(Array(arrayLiteral: lastName)[0])"
} else {
//initials = "\(Array(arrayLiteral: chatWithFirstName)[0]) \(Array(arrayLiteral: chatWithLastName)[0])"
initials = "\(String(describing: chatWithFirstName.characters.first)) \(String(describing: chatWithLastName.characters.first))"
initials = "\(String(describing: chatWithFirstName.first)) \(String(describing: chatWithLastName.first))"
}

let size: CGFloat = 14
Expand Down Expand Up @@ -548,7 +548,7 @@ class ChatViewController: JSQMessagesViewController, UIActionSheetDelegate, Uzys
if data.MessageType == MessageTypeEnum.Picture.rawValue {
viewController.title = "Photo"
let photoView = VIPhotoView(frame:self.navigationController!.view.bounds, andImage:(message.media as? JSQPhotoMediaItem)?.image)
photoView?.autoresizingMask = UIViewAutoresizing(rawValue:1 << 6 - 1)
photoView?.autoresizingMask = UIView.AutoresizingMask(rawValue:1 << 6 - 1)
viewController.view.addSubview(photoView!)
self.navigationController!.pushViewController(viewController, animated: true)
} else if data.MessageType == MessageTypeEnum.Location.rawValue {
Expand All @@ -568,8 +568,9 @@ class ChatViewController: JSQMessagesViewController, UIActionSheetDelegate, Uzys
}
}

func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, didChange newState: MKAnnotationViewDragState, fromOldState oldState: MKAnnotationViewDragState) {
mapView.setRegion(MKCoordinateRegionMakeWithDistance(view.annotation!.coordinate, 1000, 1000), animated: true)
func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, didChange newState: MKAnnotationView.DragState, fromOldState oldState: MKAnnotationView.DragState) {
let region = MKCoordinateRegion(center: view.annotation!.coordinate, latitudinalMeters: 1000, longitudinalMeters: 1000)
mapView.setRegion(region, animated: true)
}

override func collectionView(_ collectionView: JSQMessagesCollectionView!, didTapCellAt indexPath: IndexPath!, touchLocation: CGPoint) {
Expand All @@ -590,7 +591,7 @@ class ChatViewController: JSQMessagesViewController, UIActionSheetDelegate, Uzys
self.localData = [JSQMessage?](repeating: nil, count: count)
}
if id < count {
data = EVCloudData.publicDB.data[self.dataID]![count - id - 1] as! Message
data = EVCloudData.publicDB.data[self.dataID]![count - id - 1] as? Message
} else {
data = Message()
}
Expand Down
4 changes: 2 additions & 2 deletions AppMessage/AppMessage/Controlers/LeftMenuViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ class LeftMenuViewController: UIViewController, UITableViewDataSource, UITableVi
let lastName: String = (user as! CKUserIdentity).nameComponents?.familyName ?? ""
startChat((user as! CKUserIdentity).userRecordID!.recordName, firstName: firstName, lastName: lastName)
} else {
let firstName: String = (user as! CKDiscoveredUserInfo).firstName ?? ""
let lastName: String = (user as! CKDiscoveredUserInfo).lastName ?? ""
let firstName: String = (user as! CKDiscoveredUserInfo).displayContact?.givenName ?? ""
let lastName: String = (user as! CKDiscoveredUserInfo).displayContact?.familyName ?? ""
startChat((user as! CKDiscoveredUserInfo).userRecordID!.recordName, firstName: firstName, lastName: lastName)
}
}
Expand Down
7 changes: 6 additions & 1 deletion AppMessage/AppMessage/Controlers/NewsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class NewsViewController: UIViewController, UITableViewDataSource, UITableViewDe
if let news: News = EVCloudData.publicDB.data["News_All"]![(indexPath as NSIndexPath).row] as? News {
if let url: URL = URL(string: news.ActionUrl) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
UIApplication.shared.open(url, options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
Expand All @@ -91,3 +91,8 @@ class NewsViewController: UIViewController, UITableViewDataSource, UITableViewDe

}
}

// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertToUIApplicationOpenExternalURLOptionsKeyDictionary(_ input: [String: Any]) -> [UIApplication.OpenExternalURLOptionsKey: Any] {
return Dictionary(uniqueKeysWithValues: input.map { key, value in (UIApplication.OpenExternalURLOptionsKey(rawValue: key), value)})
}
2 changes: 1 addition & 1 deletion AppMessage/AppMessage/Controlers/RootViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class RootViewController: UIViewController {
NotificationCenter.default.addObserver(forName: NSNotification.Name.NSUbiquityIdentityDidChange, object: nil, queue: nil) { _ in
EVLog("The user’s iCloud login changed: should refresh all user data.")
Async.main {
self.viewController?.removeFromParentViewController()
self.viewController?.removeFromParent()
}
return
}
Expand Down
6 changes: 3 additions & 3 deletions AppMessage/AppMessage/Controlers/TestsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ class TestsViewController: UIViewController {

func conflictTest() {
let message = Message()
message.recordID = CKRecordID(recordName: "We use this twice")
message.recordID = CKRecord.ID(recordName: "We use this twice")
message.Text = "This is the message text"

let message2 = Message()
message2.recordID = CKRecordID(recordName: "We use this twice")
message2.recordID = CKRecord.ID(recordName: "We use this twice")
message2.Text = "This is an other message text"

self.dao.saveItem(message, completionHandler: {record in
Expand Down Expand Up @@ -199,7 +199,7 @@ class TestsViewController: UIViewController {
})

// Get all records of a recordType that are created by me using a predicate
let predicate = NSPredicate(format: "creatorUserRecordID == %@", CKRecordID(recordName: userId))
let predicate = NSPredicate(format: "creatorUserRecordID == %@", CKRecord.ID(recordName: userId))
dao.query(Message(), predicate:predicate, completionHandler: { results, isFinished in
EVLog("query recordType created by: result count = \(results.count)")
return false
Expand Down
4 changes: 2 additions & 2 deletions AppMessage/AppMessage/DataObjects/CKAsset+UIImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import CloudKit
import UIKit

public extension CKAsset {
public func image() -> UIImage? {
if let data = try? Data(contentsOf: self.fileURL) {
func image() -> UIImage? {
if let data = try? Data(contentsOf: self.fileURL!) {
return UIImage(data: data)
}
return nil
Expand Down
12 changes: 6 additions & 6 deletions AppMessage/AppMessage/DataObjects/Message.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ enum MessageTypeEnum: String {

class Message: CKDataObject {
// From which Channel is this message
var From: CKReference? // = CKReference(recordID: CKRecordID(recordName: "N/A"), action: CKReferenceAction.None)
var From: CKRecord.Reference? // = CKReference(recordID: CKRecordID(recordName: "N/A"), action: CKReferenceAction.None)
var From_ID: String = ""
func setFromFields(_ id: String) {
self.From_ID = id
self.From = CKReference(recordID: CKRecordID(recordName: id), action: CKReferenceAction.deleteSelf)
self.From = CKRecord.Reference(recordID: CKRecord.ID(recordName: id), action: CKRecord.Reference.Action.deleteSelf)
}
var FromFirstName: String = ""
var FromLastName: String = ""

// To what Channel or Group is this message
var To: CKReference? // = CKReference(recordID: CKRecordID(recordName: "N/A"), action: CKReferenceAction.None)
var To: CKRecord.Reference? // = CKReference(recordID: CKRecordID(recordName: "N/A"), action: CKReferenceAction.None)
var To_ID: String = ""
func setToFields(_ id: String) {
self.To_ID = id
self.To = CKReference(recordID: CKRecordID(recordName: id), action: CKReferenceAction.deleteSelf)
self.To = CKRecord.Reference(recordID: CKRecord.ID(recordName: id), action: CKRecord.Reference.Action.deleteSelf)
}
var ToFirstName: String = ""
var ToLastName: String = ""
Expand All @@ -43,11 +43,11 @@ class Message: CKDataObject {
var MessageType: String = MessageTypeEnum.Text.rawValue

// From which Channel is this message
var Asset: CKReference? // = CKReference(recordID: CKRecordID(recordName: "N/A"), action: CKReferenceAction.None)
var Asset: CKRecord.Reference? // = CKReference(recordID: CKRecordID(recordName: "N/A"), action: CKReferenceAction.None)
var Asset_ID: String = ""
func setAssetFields(_ id: String) {
self.Asset_ID = id
self.Asset = CKReference(recordID: CKRecordID(recordName: id), action: CKReferenceAction.none)
self.Asset = CKRecord.Reference(recordID: CKRecord.ID(recordName: id), action: CKRecord.Reference.Action.none)
}

var Latitude: Double = 52.8350711
Expand Down
2 changes: 1 addition & 1 deletion AppMessage/AppMessage/Helper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Helper {
kCRToastAnimationOutDirectionKey : NSNumber(value: CRToastAnimationDirection.bottom.rawValue),
]
Async.main {
CRToastManager.showNotification(options: options as! [AnyHashable: Any], completionBlock: { })
CRToastManager.showNotification(options: options as? [AnyHashable: Any], completionBlock: { })
}
}

Expand Down
Loading

0 comments on commit eefb3c6

Please sign in to comment.