Skip to content

Commit

Permalink
fix: Remove all warnings and clean up project (#128)
Browse files Browse the repository at this point in the history
* clean up warnings

* Bump CareKitEssentials

* Bump CareKitEssentials version

* Bump min macOS version

* Build for latest OS's
  • Loading branch information
cbaker6 authored Dec 24, 2024
1 parent 5a23cce commit ac7bc48
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 99 deletions.
28 changes: 19 additions & 9 deletions OCKSample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -937,17 +937,22 @@
);
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
INFOPLIST_FILE = "$(SRCROOT)/OCKSample/Supporting Files/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 18.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = edu.uky.netrecon.ParseCarekitSample;
MACOSX_DEPLOYMENT_TARGET = 15.0;
PRODUCT_BUNDLE_IDENTIFIER = edu.usc.netrecon.ParseCarekitSample;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_TREAT_WARNINGS_AS_ERRORS = NO;
TARGETED_DEVICE_FAMILY = "1,2,7";
XROS_DEPLOYMENT_TARGET = 2.0;
};
name = Release;
};
Expand All @@ -957,7 +962,7 @@
CODE_SIGN_STYLE = Automatic;
DEBUG_INFORMATION_FORMAT = dwarf;
INFOPLIST_FILE = OCKSampleUITests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 18.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -1017,7 +1022,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = OCKSampleUITests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 18.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -1054,14 +1059,14 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = edu.uky.netrecon.ParseCarekitSample.watchkitapp;
PRODUCT_BUNDLE_IDENTIFIER = edu.usc.netrecon.ParseCarekitSample.watchkitapp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 9.0;
WATCHOS_DEPLOYMENT_TARGET = 11.0;
};
name = Debug;
};
Expand All @@ -1081,13 +1086,13 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = edu.uky.netrecon.ParseCarekitSample.watchkitapp;
PRODUCT_BUNDLE_IDENTIFIER = edu.usc.netrecon.ParseCarekitSample.watchkitapp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 9.0;
WATCHOS_DEPLOYMENT_TARGET = 11.0;
};
name = Release;
};
Expand Down Expand Up @@ -1174,17 +1179,22 @@
);
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
INFOPLIST_FILE = "$(SRCROOT)/OCKSample/Supporting Files/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 18.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = edu.uky.netrecon.ParseCarekitSample;
MACOSX_DEPLOYMENT_TARGET = 15.0;
PRODUCT_BUNDLE_IDENTIFIER = edu.usc.netrecon.ParseCarekitSample;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_TREAT_WARNINGS_AS_ERRORS = NO;
TARGETED_DEVICE_FAMILY = "1,2,7";
XROS_DEPLOYMENT_TARGET = 2.0;
};
name = Debug;
};
Expand Down Expand Up @@ -1235,7 +1245,7 @@
repositoryURL = "https://github.com/netreconlab/CareKitEssentials";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = "1.0.0-alpha.31";
minimumVersion = "1.0.0-alpha.34";
};
};
70202EBF2807333900CF73FB /* XCRemoteSwiftPackageReference "CareKit" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/netreconlab/CareKitEssentials",
"state" : {
"revision" : "8df6c52a65d7881611acb23178b39d08c44ebd21",
"version" : "1.0.0-alpha.32"
"revision" : "5c1535887bb9d567a5a084820e6d3c7a87864acd",
"version" : "1.0.0-alpha.34"
}
},
{
Expand Down
9 changes: 5 additions & 4 deletions OCKSample/Extensions/AppDelegate+ParseRemoteDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ extension AppDelegate: ParseRemoteDelegate {
NotificationCenter.default.post(.init(name: Notification.Name(rawValue: Constants.requestSync)))
}

@MainActor
func successfullyPushedToRemote() {
if isFirstTimeLogin {
// BAKER: @MainActor not working (shows purple warning), leave async.
Expand All @@ -29,9 +28,11 @@ extension AppDelegate: ParseRemoteDelegate {
// watchOS 9 needs to be sent messages for updates on real devices
if isSendingPushUpdatesToWatch {
let message = Utility.prepareSyncMessageForWatch()
WCSession.default.sendMessage(message,
replyHandler: nil,
errorHandler: nil)
WCSession.default.sendMessage(
message,
replyHandler: nil,
errorHandler: nil
)
}
#endif
}
Expand Down
27 changes: 20 additions & 7 deletions OCKSample/Extensions/OCKStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,26 @@ extension OCKStore {
stretch.impactsAdherence = true
stretch.asset = "figure.walk"

try await addTasksIfNotPresent([nausea, doxylamine, kegels, stretch])
try await addTasksIfNotPresent(
[
nausea,
doxylamine,
kegels,
stretch
]
)

var contact1 = OCKContact(
id: "jane",
givenName: "Jane",
familyName: "Daniels",
carePlanUUID: nil
)
contact1.asset = "JaneDaniels"
contact1.title = "Family Practice Doctor"
contact1.role = "Dr. Daniels is a family practice doctor with 8 years of experience."
contact1.emailAddresses = [OCKLabeledValue(label: CNLabelEmailiCloud, value: "[email protected]")]
contact1.phoneNumbers = [OCKLabeledValue(label: CNLabelWork, value: "(800) 257-2000")]
contact1.messagingNumbers = [OCKLabeledValue(label: CNLabelWork, value: "(800) 357-2040")]

contact1.address = {
let address = OCKPostalAddress()
address.street = "1500 San Pablo St"
Expand All @@ -184,9 +189,12 @@ extension OCKStore {
return address
}()

var contact2 = OCKContact(id: "matthew", givenName: "Matthew",
familyName: "Reiff", carePlanUUID: nil)
contact2.asset = "MatthewReiff"
var contact2 = OCKContact(
id: "matthew",
givenName: "Matthew",
familyName: "Reiff",
carePlanUUID: nil
)
contact2.title = "OBGYN"
contact2.role = "Dr. Reiff is an OBGYN with 13 years of experience."
contact2.phoneNumbers = [OCKLabeledValue(label: CNLabelWork, value: "(800) 257-1000")]
Expand All @@ -200,6 +208,11 @@ extension OCKStore {
return address
}()

try await addContactsIfNotPresent([contact1, contact2])
try await addContactsIfNotPresent(
[
contact1,
contact2
]
)
}
}
21 changes: 13 additions & 8 deletions OCKSample/Main/Care/CareView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
// Created by Corey Baker on 11/24/20.
// Copyright © 2020 Network Reconnaissance Lab. All rights reserved.
//
// swiftlint:disable:next line_length
// This file embeds a UIKit View Controller inside of a SwiftUI view. I used this tutorial to figure this out https://developer.apple.com/tutorials/swiftui/interfacing-with-uikit
// This file embeds a UIKit View Controller inside of a SwiftUI view.
// Look at this tutorial for reference:
// https://developer.apple.com/tutorials/swiftui/interfacing-with-uikit

import CareKit
import CareKitStore
import os.log
import SwiftUI
import UIKit

Expand All @@ -19,10 +19,16 @@ struct CareView: UIViewControllerRepresentable {
@Environment(\.appDelegate) private var appDelegate
@Environment(\.careStore) private var careStore

func makeUIViewController(context: Context) -> some UIViewController {
func makeUIViewController(
context: Context
) -> some UIViewController {
let viewController = createViewController()
let navigationController = UINavigationController(rootViewController: viewController)
navigationController.navigationBar.backgroundColor = UIColor { $0.userInterfaceStyle == .light ? #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1): #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1) }
let navigationController = UINavigationController(
rootViewController: viewController
)
navigationController.navigationBar.backgroundColor = UIColor {
$0.userInterfaceStyle == .light ? #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1): #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)
}
return navigationController
}

Expand All @@ -32,8 +38,7 @@ struct CareView: UIViewControllerRepresentable {
) {
guard let navigationController = uiViewController as? UINavigationController,
let careViewController = navigationController.viewControllers.first as? CareViewController else {
Logger.feed.error("CareView should have been a UINavigationController")
return
fatalError("CareView should have been a UINavigationController")
}
guard careViewController.store !== careStore ||
appDelegate?.isFirstTimeLogin == true else {
Expand Down
83 changes: 49 additions & 34 deletions OCKSample/Main/Care/CareViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,42 @@ class CareViewController: OCKDailyPageViewController {

override func viewDidLoad() {
super.viewDidLoad()
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .refresh,
target: self,
action: #selector(synchronizeWithRemote))
NotificationCenter.default.addObserver(self, selector: #selector(synchronizeWithRemote),
name: Notification.Name(rawValue: Constants.requestSync),
object: nil)
NotificationCenter.default.addObserver(self,
selector: #selector(updateSynchronizationProgress(_:)),
name: Notification.Name(rawValue: Constants.progressUpdate),
object: nil)
NotificationCenter.default.addObserver(self,
selector: #selector(reloadView(_:)),
name: Notification.Name(rawValue: Constants.finishedAskingForPermission),
object: nil)
NotificationCenter.default.addObserver(self,
selector: #selector(reloadView(_:)),
name: Notification.Name(rawValue: Constants.shouldRefreshView),
object: nil)
navigationItem.rightBarButtonItem = UIBarButtonItem(
barButtonSystemItem: .refresh,
target: self,
action: #selector(synchronizeWithRemote)
)
NotificationCenter.default.addObserver(
self,
selector: #selector(synchronizeWithRemote),
name: Notification.Name(
rawValue: Constants.requestSync
),
object: nil
)
NotificationCenter.default.addObserver(
self,
selector: #selector(updateSynchronizationProgress(_:)),
name: Notification.Name(rawValue: Constants.progressUpdate),
object: nil
)
NotificationCenter.default.addObserver(
self,
selector: #selector(reloadView(_:)),
name: Notification.Name(rawValue: Constants.finishedAskingForPermission),
object: nil
)
NotificationCenter.default.addObserver(
self,
selector: #selector(reloadView(_:)),
name: Notification.Name(rawValue: Constants.shouldRefreshView),
object: nil
)
}

@objc private func updateSynchronizationProgress(_ notification: Notification) {
@objc private func updateSynchronizationProgress(
_ notification: Notification
) {
guard let receivedInfo = notification.userInfo as? [String: Any],
let progress = receivedInfo[Constants.progressUpdate] as? Int else {
return
Expand Down Expand Up @@ -191,6 +206,21 @@ class CareViewController: OCKDailyPageViewController {
}
}

private func fetchTasks(on date: Date) async -> [OCKAnyTask] {
var query = OCKTaskQuery(for: date)
query.excludesTasksWithNoEvents = true
do {
let tasks = try await store.fetchAnyTasks(query: query)
let orderedTasks = TaskID.ordered.compactMap { orderedTaskID in
tasks.first(where: { $0.id == orderedTaskID })
}
return orderedTasks
} catch {
Logger.feed.error("Could not fetch tasks: \(error, privacy: .public)")
return []
}
}

private func taskViewControllers(
_ task: OCKAnyTask,
on date: Date
Expand Down Expand Up @@ -340,21 +370,6 @@ class CareViewController: OCKDailyPageViewController {
self.isLoading = false
}
}

private func fetchTasks(on date: Date) async -> [OCKAnyTask] {
var query = OCKTaskQuery(for: date)
query.excludesTasksWithNoEvents = true
do {
let tasks = try await store.fetchAnyTasks(query: query)
let orderedTasks = TaskID.ordered.compactMap { orderedTaskID in
tasks.first(where: { $0.id == orderedTaskID })
}
return orderedTasks
} catch {
Logger.feed.error("Could not fetch tasks: \(error, privacy: .public)")
return []
}
}
}

private extension View {
Expand Down
22 changes: 11 additions & 11 deletions OCKSample/Main/Care/CustomCards/TipView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if os(iOS)

import UIKit
import CareKit
import CareKitUI
Expand Down Expand Up @@ -97,25 +95,27 @@ class TipView: OCKView, OCKCardable {
imageView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
imageHeightConstraint
])

registerForTraitChanges(
[UITraitPreferredContentSizeCategory.self],
handler: { (self: Self, previousTraitCollection: UITraitCollection) in
let traitCollection = self.traitCollection
// swiftlint:disable:next line_length
if previousTraitCollection.preferredContentSizeCategory != traitCollection.preferredContentSizeCategory {
self.imageHeightConstraint.constant = self.scaledImageHeight(compatibleWith: traitCollection)
}
}
)
}

func scaledImageHeight(compatibleWith traitCollection: UITraitCollection) -> CGFloat {
return UIFontMetrics.default.scaledValue(for: 200, compatibleWith: traitCollection)
}

override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
if previousTraitCollection?.preferredContentSizeCategory != traitCollection.preferredContentSizeCategory {
imageHeightConstraint.constant = scaledImageHeight(compatibleWith: traitCollection)
}
}

override func styleDidChange() {
super.styleDidChange()
let cachedStyle = style()
enableCardStyling(true, style: cachedStyle)
directionalLayoutMargins = cachedStyle.dimension.directionalInsets1
}
}

#endif
Loading

0 comments on commit ac7bc48

Please sign in to comment.