Skip to content

Commit

Permalink
[dependency-fixes] this is a commit of working state during attempts …
Browse files Browse the repository at this point in the history
…to fix compile-time problems after new xcode version
  • Loading branch information
biblicabeebli committed Oct 10, 2024
1 parent c3774a6 commit bed239d
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 228 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ Private/*

# Firebase Cloud Messaging credentials & configuration file
GoogleService-Info.plist

.sentryclirc
48 changes: 31 additions & 17 deletions Beiwe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@
83F98C4F1C9250A600E0B64B /* Run Script */,
C7A5541B51E06493BA1A7A86 /* [CP] Embed Pods Frameworks */,
AAEA006C2B714C71008DDDC7 /* Run Script */,
74941C0DE4BC4BD2803D0C04 /* Upload Debug Symbols to Sentry */,
);
buildRules = (
);
Expand All @@ -485,7 +486,7 @@
83F98C2E1C923C3600E0B64B /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastSwiftUpdateCheck = 720;
LastUpgradeCheck = 1130;
ORGANIZATIONNAME = "Rocketfarm Studios";
TargetAttributes = {
Expand Down Expand Up @@ -541,6 +542,21 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
74941C0DE4BC4BD2803D0C04 /* Upload Debug Symbols to Sentry */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}",
);
name = "Upload Debug Symbols to Sentry";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# This script is responsable to upload debug symbols and source context for Sentry.\nif which sentry-cli >/dev/null; then\nexport SENTRY_ORG=onnela-lab\nexport SENTRY_PROJECT=ios-development\nERROR=$(sentry-cli debug-files upload --include-sources \"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\nif [ ! $? -eq 0 ]; then\necho \"warning: sentry-cli - $ERROR\"\nfi\nelse\necho \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\nfi\n";
};
83E3DE861CA3A41E00EB5349 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -590,8 +606,8 @@
inputFileListPaths = (
);
inputPaths = (
$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH,
$TARGET_BUILD_DIR/$INFOPLIST_PATH,
"$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH",
"$TARGET_BUILD_DIR/$INFOPLIST_PATH",
);
name = "Run Script";
outputFileListPaths = (
Expand All @@ -616,16 +632,13 @@
"${BUILT_PRODUCTS_DIR}/Hakuba/Hakuba.framework",
"${BUILT_PRODUCTS_DIR}/IDZSwiftCommonCrypto/IDZSwiftCommonCrypto.framework",
"${BUILT_PRODUCTS_DIR}/KeychainSwift/KeychainSwift.framework",
"${BUILT_PRODUCTS_DIR}/ObjcExceptionBridging/ObjcExceptionBridging.framework",
"${BUILT_PRODUCTS_DIR}/ObjectMapper/ObjectMapper.framework",
"${BUILT_PRODUCTS_DIR}/PKHUD/PKHUD.framework",
"${BUILT_PRODUCTS_DIR}/PromisesObjC/FBLPromises.framework",
"${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework",
"${BUILT_PRODUCTS_DIR}/ReachabilitySwift/ReachabilitySwift.framework",
"${BUILT_PRODUCTS_DIR}/ResearchKit/ResearchKit.framework",
"${BUILT_PRODUCTS_DIR}/Sentry/Sentry.framework",
"${BUILT_PRODUCTS_DIR}/SwiftValidator/SwiftValidator.framework",
"${BUILT_PRODUCTS_DIR}/XCGLogger/XCGLogger.framework",
"${BUILT_PRODUCTS_DIR}/XLActionController/XLActionController.framework",
"${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
);
Expand All @@ -638,16 +651,13 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Hakuba.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/IDZSwiftCommonCrypto.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/KeychainSwift.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ObjcExceptionBridging.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ObjectMapper.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PKHUD.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBLPromises.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ReachabilitySwift.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ResearchKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Sentry.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftValidator.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/XCGLogger.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/XLActionController.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
);
Expand Down Expand Up @@ -883,16 +893,17 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2024.24;
CURRENT_PROJECT_VERSION = 2024.25;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 6M52R5C7FT;
ENABLE_BITCODE = NO;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
EXCLUDED_ARCHS = "";
INFOPLIST_FILE = Beiwe/Info.plist;
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.5.1;
MARKETING_VERSION = 2.5.1.1;
PRODUCT_BUNDLE_IDENTIFIER = harvard.lab.onnela.beiwe.ios;
PRODUCT_NAME = Beiwe2;
PROVISIONING_PROFILE = "";
Expand Down Expand Up @@ -983,16 +994,17 @@
CODE_SIGN_ENTITLEMENTS = Beiwe/Beiwe2Release2.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2024.24;
CURRENT_PROJECT_VERSION = 2024.25;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 6M52R5C7FT;
ENABLE_BITCODE = NO;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
EXCLUDED_ARCHS = "";
INFOPLIST_FILE = Beiwe/Info.plist;
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.5.1;
MARKETING_VERSION = 2.5.1.1;
PRODUCT_BUNDLE_IDENTIFIER = harvard.lab.onnela.beiwe.ios;
PRODUCT_NAME = Beiwe2;
PROVISIONING_PROFILE = "";
Expand Down Expand Up @@ -1150,16 +1162,17 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2024.24;
CURRENT_PROJECT_VERSION = 2024.25;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 6M52R5C7FT;
ENABLE_BITCODE = NO;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
EXCLUDED_ARCHS = "";
INFOPLIST_FILE = Beiwe/Info.plist;
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.5.1;
MARKETING_VERSION = 2.5.1.1;
PRODUCT_BUNDLE_IDENTIFIER = lab.onnela.beiwe.ios;
PRODUCT_NAME = Beiwe;
PROVISIONING_PROFILE = "";
Expand Down Expand Up @@ -1188,16 +1201,17 @@
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: Onnela Lab LLC (6M52R5C7FT)";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2024.24;
CURRENT_PROJECT_VERSION = 2024.25;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 6M52R5C7FT;
ENABLE_BITCODE = NO;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
EXCLUDED_ARCHS = "";
INFOPLIST_FILE = Beiwe/Info.plist;
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.5.1;
MARKETING_VERSION = 2.5.1.1;
PRODUCT_BUNDLE_IDENTIFIER = lab.onnela.beiwe.ios;
PRODUCT_NAME = Beiwe;
PROVISIONING_PROFILE = "";
Expand Down
49 changes: 20 additions & 29 deletions Beiwe/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import Alamofire
import BackgroundTasks
import CoreMotion
import Crashlytics
import EmitterKit
import Fabric
import Firebase
import Foundation
import ObjectMapper
import ReachabilitySwift
import ResearchKit
import Sentry
import UIKit
import XCGLogger

let log = XCGLogger(identifier: "advancedLogger", includeDefaultDestinations: false)

extension String: LocalizedError {
public var errorDescription: String? { return self }
Expand Down Expand Up @@ -111,20 +107,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate
// completionHandler(.newData)
// }

func setupLogging() {
// Create a destination for the system console log (via NSLog), add the destination to the logger
let systemLogDestination = AppleSystemLogDestination(owner: log, identifier: "advancedLogger.systemLogDestination")
systemLogDestination.outputLevel = self.debugEnabled ? .debug : .warning
systemLogDestination.showLogIdentifier = true
systemLogDestination.showFunctionName = true
systemLogDestination.showThreadName = true
systemLogDestination.showLevel = true
systemLogDestination.showFileName = true
systemLogDestination.showLineNumber = true
systemLogDestination.showDate = true
log.add(destination: systemLogDestination)
}

// BY THE WAY background app refresh health tasts simply aren't functional as far as it is possible to tell, so we are just rawdogging at and logging everything
// up to the server inside the requests to the backend because the app isn't stable enough to be a reliable source of truth.
func setupBackgroundAppRefresh() {
Expand Down Expand Up @@ -172,7 +154,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate
func initialSetup() {
// initialize Sentry IMMEDIATELY
self.setupSentry()
self.setupLogging()
// setupCrashLytics() // not currently using crashlytics
// appStartLog() // this is too verbose and usually unnecessary, uncomment if you want but don't commit.
self.initializeUI()
Expand Down Expand Up @@ -762,20 +743,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate
////////////////////////////////////////////////////////////////////////////////////////////////

func setupSentry() {


// loads sentry key, prints an error if it doesn't work.
do {
let dsn = SentryConfiguration.sharedInstance.settings["sentry-dsn"] as? String ?? "dev"
if dsn == "release" {
Client.shared = try Client(dsn: SentryKeys.release_dsn)
} else if dsn == "dev" {
Client.shared = try Client(dsn: SentryKeys.development_dsn)
} else {
throw "Invalid Sentry configuration"
let dsn_name = SentryConfiguration.sharedInstance.settings["sentry-dsn"] as? String ?? "dev"
let dsn: String
if dsn_name == "release" {
dsn = SentryKeys.release_dsn
} else if dsn_name == "dev" {
dsn = SentryKeys.development_dsn
} else { throw "Invalid Sentry configuration" }

SentrySDK.start { options in
options.dsn = dsn
options.debug = true // Enabled debug when first installing is always helpful

// Uncomment the following lines to add more data to your events
// options.attachScreenshot = true // This adds a screenshot to the error events
options.attachViewHierarchy = true // This adds the view hierarchy to the error events
}
try Client.shared?.startCrashHandler()
} catch let error {
print("\(error)")
print("Error loading Sentry DSN: \(error)\nSentry will not be enabled.")
}
SentrySDK.capture(message: "This is a new Sentry version check")
}
}

Expand Down Expand Up @@ -832,7 +823,7 @@ extension AppDelegate: MessagingDelegate {
// To enable direct data messages, you can set Messaging.messaging().shouldEstablishDirectChannel to true.
func messaging(_ messaging: Messaging, didReceive remoteMessage: MessagingRemoteMessage) {
// FIXME: what even is this function
log.error("Received data message: \(remoteMessage.appData)")
print("Received data message: \(remoteMessage.appData)")
// remoteMessage.messageID
}
}
33 changes: 9 additions & 24 deletions Beiwe/BeiweBackgroundTasks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@ func scheduleRefreshHeartbeat() {
try BGTaskScheduler.shared.submit(request)
} catch {
// capture and report this error to sentry.
if let sentry_client = Client.shared {
sentry_client.snapshotStacktrace {
let event = Event(level: .error)
event.message = "not a crash - scheduling refresh heartbeat: \(error)"
event.environment = Constants.APP_INFO_TAG
sentry_client.appendStacktrace(to: event)
sentry_client.send(event: event)
}
SentrySDK.capture(message: "not a crash - scheduling refresh heartbeat: \(error)") { (scope: Scope) in
scope.setEnvironment(Constants.APP_INFO_TAG)
scope.setLevel(.error)
}
}
}
Expand All @@ -34,14 +29,9 @@ func scheduleProcessingHeartbeat() {
try BGTaskScheduler.shared.submit(request)
} catch {
// capture and report this error to sentry.
if let sentry_client = Client.shared {
sentry_client.snapshotStacktrace {
let event = Event(level: .error)
event.message = "not a crash - scheduling processing heartbeat: \(error)"
event.environment = Constants.APP_INFO_TAG
sentry_client.appendStacktrace(to: event)
sentry_client.send(event: event)
}
SentrySDK.capture(message: "not a crash - scheduling processing heartbeat: \(error)") { (scope: Scope) in
scope.setEnvironment(Constants.APP_INFO_TAG)
scope.setLevel(.error)
}
}
}
Expand All @@ -58,14 +48,9 @@ func scheduleHealthHeartbeat() {
try BGTaskScheduler.shared.submit(request)
} catch {
// capture and report this error to sentry.
if let sentry_client = Client.shared {
sentry_client.snapshotStacktrace {
let event = Event(level: .error)
event.message = "not a crash - scheduling health heartbeat: \(error)"
event.environment = Constants.APP_INFO_TAG
sentry_client.appendStacktrace(to: event)
sentry_client.send(event: event)
}
SentrySDK.capture(message: "not a crash - scheduling health heartbeat: \(error)") { (scope: Scope) in
scope.setEnvironment(Constants.APP_INFO_TAG)
scope.setLevel(.error)
}
}
}
Expand Down
48 changes: 19 additions & 29 deletions Beiwe/Common.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,34 +115,24 @@ public func print(_ items: Any..., separator: String = " ", terminator: String =
}

func sentry_warning(_ title: String, _ extra1: String? = nil, _ extra2: String? = nil, _ extra3: String? = nil, crash: Bool) {
if let sentry_client = Client.shared {
sentry_client.snapshotStacktrace {
let event = Event(level: .warning)
event.message = title
event.environment = Constants.APP_INFO_TAG

// todo does this always exist?
if event.extra == nil {
event.extra = [:]
}
if var extras = event.extra {
if let extra = extra1 {
extras["extra1"] = extra
}
if let extra = extra2 {
extras["extra2"] = extra
}
if let extra = extra3 {
extras["extra3"] = extra
}
if let patient_id = StudyManager.sharedInstance.currentStudy?.patientId {
extras["user_id"] = StudyManager.sharedInstance.currentStudy?.patientId
}
}
sentry_client.appendStacktrace(to: event)
sentry_client.send(event: event)
}

var extras = [String: String]
if let extra = extra1 {
extras["extra1"] = extra
}
if let extra = extra2 {
extras["extra2"] = extra
}
if let extra = extra3 {
extras["extra3"] = extra
}
if let patient_id = StudyManager.sharedInstance.currentStudy?.patientId {
extras["user_id"] = patient_id
}

SentrySDK.capture(message: "not a crash - Error moving file 1") { (scope: Scope) in
scope.setEnvironment(Constants.APP_INFO_TAG)
scope.setExtras(extras)
scope.setLevel(.warning)
}
}


7 changes: 5 additions & 2 deletions Beiwe/Controllers/RegisterViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,11 @@ class RegisterViewController: FormViewController {
if let patientId = patientId, let phoneNumber = phoneNumber, let newPassword = newPassword, let clinicianPhone = clinicianPhone, let raPhone = raPhone {
let registerStudyRequest = RegisterStudyRequest(patientId: patientId, phoneNumber: phoneNumber, newPassword: newPassword)

// sets tags for Sentry
Client.shared?.tags = ["user_id": patientId, "server_url": server]
// sets tags for Sentry -- we don't actually know for certain that this works
SentrySDK.configureScope { scope in
scope.setTags(["user_id": patientId, "server_url": server])
}

ApiManager.sharedInstance.password = tempPassword ?? ""
ApiManager.sharedInstance.patientId = patientId
ApiManager.sharedInstance.customApiUrl = server
Expand Down
Loading

0 comments on commit bed239d

Please sign in to comment.