Enable App Center will cause SwiftUI's accent color to disappear.
Closed this issue ยท 7 comments
Description
Enable App Center will cause SwiftUI's accent color to disappear.
Repro Steps
- Build a simple App. ๐
- Set the accent color in the assets.
- Start App Center by adding "AppCenter.start" in the App init function. ๐ง
- Accent color lost. ๐
Details
- Which SDK version are you using?
5.0.3 - Which OS version did you experience the issue on?
iOS 17. But this also happens before that. - Which Xcode version did you build the app with?
Xcode 15. But this also happens before that. - Which Cocoapods version are you using (run
pod --version
)?
SwiftPM, not Cocoapods. - What device version did you see this error on? Were you using an emulator or a physical device?
Both actual device and simulator. iPhone SE is in use. - What language are you using?
- Objective C
- Swift
- What third party libraries are you using?
None. - Please enable verbose logging for your app using
MSAppCenter.setLogLevel(.verbose)
before your call toMSAppCenter.start(...)
for Swift, or[MSAppCenter setLogLevel:MSLogLevelVerbose]
before[MSAppCenter start: ...]
for Objective C and include the logs here:
[AppCenter] VERBOSE: -[MSACDelegateForwarder addTraceBlock:]_block_invoke_2/88 Start buffering traces.
[AppCenter] DEBUG: -[MSACDelegateForwarder setEnabledFromPlistForKey:]_block_invoke/278 Delegate forwarder for info.plist key 'AppCenterAppDelegateForwarderEnabled' enabled. It may use swizzling.
[AppCenter] DEBUG: -[MSACDelegateForwarder swizzleOriginalSelector:withCustomSelector:originalClass:]_block_invoke/205 Selector 'setDelegate:' of class 'UIApplication' is swizzled.
[AppCenter] VERBOSE: +[MSACDelegateForwarder flushTraceBuffer]/106 Stop buffering traces, flushed.
[AppCenter] DEBUG: -[MSACSessionContext init]/42 1 session(s) in the history.
[AppCenter] VERBOSE: -[MSACSessionContext setSessionId:]/66 Stored new session with id:(null) and timestamp: 2023-08-30 11:43:47 +0000.
[AppCenter] DEBUG: -[MSACUserIdContext init]/54 1 userId(s) in the history.
[AppCenter] INFO: -[MSACHttpClient networkStateChanged:]/202 Internet connection is up.
[AppCenter] INFO: -[MSACHttpClient networkStateChanged:]/202 Internet connection is up.
[AppCenter] INFO: -[MSACHttpClient networkStateChanged:]/202 Internet connection is up.
[AppCenter] DEBUG: -[MSACDBStorage initWithSchema:version:filename:]_block_invoke/38 SQLite global configuration successfully updated.
[AppCenter] INFO: -[MSACAppCenter configureWithAppSecret:transmissionTargetToken:fromApplication:]/354 App Center SDK configured successfully.
[AppCenter] VERBOSE: -[MSACAppCenter startServices:withAppSecret:transmissionTargetToken:fromApplication:]/380 Start services MSACCrashes, MSACAnalytics from an application
[AppCenterCrashes] DEBUG: -[MSACCrashes configureCrashReporterWithUncaughtExceptionHandlerEnabled:]/709 EnableUncaughtExceptionHandler is set to YES
[AppCenterCrashes] VERBOSE: -[MSACCrashes configureCrashReporterWithUncaughtExceptionHandlerEnabled:]/719 Enabled Mach exception handler.
[AppCenterCrashes] WARNING: -[MSACCrashes configureCrashReporterWithUncaughtExceptionHandlerEnabled:]/734 Detecting crashes is NOT enabled due to running the app with a debugger attached.
Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
Updating selectors after delegate addition failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}
[AppCenter] VERBOSE: -[MSACSessionContext clearSessionHistoryAndKeepCurrentSession:]/88 Cleared old sessions.
[AppCenter] VERBOSE: -[MSACUserIdContext clearUserIdHistory]/125 Cleared old userIds while keeping current userId.
[AppCenterCrashes] INFO: -[MSACCrashes applyEnabledState:]/454 Crashes service has been enabled but the service cannot detect crashes due to running the application with a debugger attached.
[AppCenterCrashes] VERBOSE: -[MSACCrashes startWithChannelGroup:appSecret:transmissionTargetToken:fromApplication:]/501 Started crash service.
[AppCenter] VERBOSE: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/495 Identifying object <MSACAnalytics: 0x600003004870> removed from pause lane for channel Analytics.
[AppCenter] DEBUG: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/497 Resume channel Analytics.
[AppCenter] VERBOSE: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/495 Identifying object <MSACAnalytics: 0x600003004870> removed from pause lane for channel Analytics/one.
[AppCenter] DEBUG: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/497 Resume channel Analytics/one.
[AppCenter] VERBOSE: -[MSACSessionContext setSessionId:]/66 Stored new session with id:6A1F6975-8760-4A59-AB5A-CBB128952A82 and timestamp: 2023-08-30 11:43:47 +0000.
[AppCenterAnalytics] INFO: -[MSACSessionTracker sendStartSession]/107 New session ID: 6A1F6975-8760-4A59-AB5A-CBB128952A82
[AppCenterCrashes] VERBOSE: -[MSACCrashes channel:didPrepareLog:internalId:flags:]/584 Storing a log to Crashes Buffer: (sid: 6A1F6975-8760-4A59-AB5A-CBB128952A82, type: startSession)
[AppCenterCrashes] VERBOSE: -[MSACCrashes channel:didPrepareLog:internalId:flags:]/595 Found an empty buffer position.
[AppCenterAnalytics] INFO: -[MSACAnalytics applyEnabledState:]/184 Analytics service has been enabled.
[AppCenter] DEBUG: -[MSACChannelUnitDefault enqueueItem:flags:]_block_invoke/156 Saving log, type: startSession, flags: 1.
[AppCenterAnalytics] VERBOSE: -[MSACAnalytics startWithChannelGroup:appSecret:transmissionTargetToken:fromApplication:]/135 Started Analytics service.
[AppCenter] ERROR: +[MSACDBStorage executeNonSelectionQuery:inOpenedDatabase:withValues:]_block_invoke/333 Could not execute the statement, result=5
database is locked
[AppCenter] ERROR: +[MSACDBStorage executeQuery:inOpenedDatabase:withValues:usingBlock:]/357 Failed to finalize SQLite statement, result=5
database is locked
[AppCenterCrashes] VERBOSE: -[MSACCrashes channel:didPrepareLog:internalId:flags:]/584 Storing a log to Crashes Buffer: (sid: (null), type: startService)
[AppCenterCrashes] VERBOSE: -[MSACCrashes channel:didPrepareLog:internalId:flags:]/607 Remembering index 0 for oldest timestamp 1693395827.127185.
[AppCenterCrashes] VERBOSE: -[MSACCrashes channel:didPrepareLog:internalId:flags:]/595 Found an empty buffer position.
[AppCenterCrashes] VERBOSE: -[MSACCrashes channel:didCompleteEnqueueingLog:internalId:]/637 Deleting a log from buffer with id 1157EB0C-162F-4959-A9EE-B3CF93B722B9
[AppCenter] DEBUG: -[MSACChannelUnitDefault enqueueItem:flags:]_block_invoke/156 Saving log, type: startService, flags: 1.
API call with invalid database connection pointer
misuse at line 179926 of [554764a6e7]
[AppCenter] VERBOSE: -[MSACLogDBStorage saveLog:withGroupId:flags:]_block_invoke/134 Log is stored with id: '0'
[AppCenterCrashes] VERBOSE: -[MSACCrashes channel:didCompleteEnqueueingLog:internalId:]/637 Deleting a log from buffer with id 130D3BF3-0852-4D92-893E-3ABEC441AA14
[AppCenter] DEBUG: -[MSACDelegateForwarder swizzleOriginalSelector:withCustomSelector:originalClass:]_block_invoke/205 Selector 'application:openURL:options:' of class 'SwiftUI.AppDelegate' is swizzled.
[AppCenter] VERBOSE: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/495 Identifying object <MSACAppCenter: 0x60000290c0e0> removed from pause lane for channel AppCenter.
[AppCenter] DEBUG: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/497 Resume channel AppCenter.
[AppCenter] VERBOSE: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/495 Identifying object <MSACAppCenter: 0x60000290c0e0> removed from pause lane for channel AppCenter/one.
[AppCenter] DEBUG: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/497 Resume channel AppCenter/one.
[AppCenter] VERBOSE: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/495 Identifying object <MSACAppCenter: 0x60000290c0e0> removed from pause lane for channel Crashes.
[AppCenter] DEBUG: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/497 Resume channel Crashes.
[AppCenter] VERBOSE: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/495 Identifying object <MSACAppCenter: 0x60000290c0e0> removed from pause lane for channel Crashes/one.
[AppCenter] DEBUG: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/497 Resume channel Crashes/one.
[AppCenter] VERBOSE: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/495 Identifying object <MSACAppCenter: 0x60000290c0e0> removed from pause lane for channel CrashesBuffer.
[AppCenter] DEBUG: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/497 Resume channel CrashesBuffer.
[AppCenter] VERBOSE: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/495 Identifying object <MSACAppCenter: 0x60000290c0e0> removed from pause lane for channel CrashesBuffer/one.
[AppCenter] DEBUG: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/497 Resume channel CrashesBuffer/one.
[AppCenter] VERBOSE: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/495 Identifying object <MSACAppCenter: 0x60000290c0e0> removed from pause lane for channel Analytics.
[AppCenter] DEBUG: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/497 Resume channel Analytics.
[AppCenter] VERBOSE: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/495 Identifying object <MSACAppCenter: 0x60000290c0e0> removed from pause lane for channel Analytics/one.
[AppCenter] DEBUG: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/497 Resume channel Analytics/one.
[AppCenter] VERBOSE: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/495 Identifying object <MSACAppCenter: 0x60000290c0e0> removed from pause lane for channel Analytics_critical.
[AppCenter] DEBUG: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/497 Resume channel Analytics_critical.
[AppCenter] VERBOSE: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/495 Identifying object <MSACAppCenter: 0x60000290c0e0> removed from pause lane for channel Analytics_critical/one.
[AppCenter] DEBUG: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/497 Resume channel Analytics_critical/one.
[AppCenter] VERBOSE: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/495 Identifying object <MSACAppCenter: 0x60000290c0e0> removed from pause lane for channel AppCenter/one.
[AppCenter] DEBUG: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/497 Resume channel AppCenter/one.
[AppCenter] VERBOSE: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/495 Identifying object <MSACAppCenter: 0x60000290c0e0> removed from pause lane for channel Crashes/one.
[AppCenter] DEBUG: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/497 Resume channel Crashes/one.
[AppCenter] VERBOSE: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/495 Identifying object <MSACAppCenter: 0x60000290c0e0> removed from pause lane for channel CrashesBuffer/one.
[AppCenter] DEBUG: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/497 Resume channel CrashesBuffer/one.
[AppCenter] VERBOSE: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/495 Identifying object <MSACAppCenter: 0x60000290c0e0> removed from pause lane for channel Analytics/one.
[AppCenter] DEBUG: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/497 Resume channel Analytics/one.
[AppCenter] VERBOSE: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/495 Identifying object <MSACAppCenter: 0x60000290c0e0> removed from pause lane for channel Analytics_critical/one.
[AppCenter] DEBUG: -[MSACChannelUnitDefault resumeWithIdentifyingObjectSync:]/497 Resume channel Analytics_critical/one.
[AppCenter] VERBOSE: -[MSACLogDBStorage loadLogsWithGroupId:limit:excludedTargetKeys:completionHandler:]/224 Load log(s) with id(s) '5','6' as batch Id:033CBE64-BD5A-428C-BEF0-91F750B4E929
[AppCenter] DEBUG: -[MSACChannelUnitDefault sendLogContainer:]/191 Sending 1/2 log, group Id: AppCenter, batch Id: 033CBE64-BD5A-428C-BEF0-91F750B4E929, session Id: (null), payload:
{
"isOneCollectorEnabled" : false,
"device" : {
"screenSize" : "2556x1179",
"appBuild" : "1",
"osName" : "iOS",
"timeZoneOffset" : 540,
"osVersion" : "17.0",
"locale" : "en_US",
"appNamespace" : "com.test",
"osBuild" : "22G74",
"sdkName" : "appcenter.ios",
"oemName" : "Apple",
"model" : "arm64",
"sdkVersion" : "5.0.3",
"appVersion" : "1.0"
},
"timestamp" : "2023-08-30T11:43:41.907Z",
"type" : "startService",
"services" : [
"Crashes",
"Analytics"
]
}
[AppCenter] DEBUG: -[MSACChannelUnitDefault sendLogContainer:]/191 Sending 2/2 log, group Id: AppCenter, batch Id: 033CBE64-BD5A-428C-BEF0-91F750B4E929, session Id: (null), payload:
{
"isOneCollectorEnabled" : false,
"device" : {
"screenSize" : "2556x1179",
"appBuild" : "1",
"osName" : "iOS",
"timeZoneOffset" : 540,
"osVersion" : "17.0",
"locale" : "en_US",
"appNamespace" : "com.test",
"osBuild" : "22G74",
"sdkName" : "appcenter.ios",
"oemName" : "Apple",
"model" : "arm64",
"sdkVersion" : "5.0.3",
"appVersion" : "1.0"
},
"timestamp" : "2023-08-30T11:43:47.128Z",
"type" : "startService",
"services" : [
"Crashes",
"Analytics"
]
}
[AppCenter] VERBOSE: -[MSACAppCenterIngestion willSendHTTPRequestToURL:withHeaders:]/101 URL: https://in.appcenter.ms/logs?api-version=1.0.0
[AppCenter] VERBOSE: -[MSACAppCenterIngestion willSendHTTPRequestToURL:withHeaders:]/102 Headers: Content-Type = application/json, App-Secret = *****41919810, Install-ID = 2EF19D61-1EEF-409F-B546-8BA63D4119C3
[AppCenter] VERBOSE: -[MSACLogDBStorage loadLogsWithGroupId:limit:excludedTargetKeys:completionHandler:]/224 Load log(s) with id(s) '1','4' as batch Id:3A079429-A45A-4935-89F7-CC1884FF29FA
[AppCenter] DEBUG: -[MSACChannelUnitDefault sendLogContainer:]/191 Sending 1/2 log, group Id: Analytics, batch Id: 3A079429-A45A-4935-89F7-CC1884FF29FA, session Id: 9D60D5CB-8BDD-42C5-9371-50812A0574AE, payload:
{
"sid" : "9D60D5CB-8BDD-42C5-9371-50812A0574AE",
"timestamp" : "2023-08-30T11:36:13.382Z",
"device" : {
"screenSize" : "2556x1179",
"appBuild" : "1",
"osName" : "iOS",
"timeZoneOffset" : 540,
"osVersion" : "17.0",
"locale" : "en_US",
"appNamespace" : "com.test",
"osBuild" : "22G74",
"sdkName" : "appcenter.ios",
"oemName" : "Apple",
"model" : "arm64",
"sdkVersion" : "5.0.3",
"appVersion" : "1.0"
},
"type" : "startSession"
}
[AppCenter] DEBUG: -[MSACChannelUnitDefault sendLogContainer:]/191 Sending 2/2 log, group Id: Analytics, batch Id: 3A079429-A45A-4935-89F7-CC1884FF29FA, session Id: CC590E87-DFF8-4B12-A98F-37749747207F, payload:
{
"sid" : "CC590E87-DFF8-4B12-A98F-37749747207F",
"timestamp" : "2023-08-30T11:43:41.906Z",
"device" : {
"screenSize" : "2556x1179",
"appBuild" : "1",
"osName" : "iOS",
"timeZoneOffset" : 540,
"osVersion" : "17.0",
"locale" : "en_US",
"appNamespace" : "com.test",
"osBuild" : "22G74",
"sdkName" : "appcenter.ios",
"oemName" : "Apple",
"model" : "arm64",
"sdkVersion" : "5.0.3",
"appVersion" : "1.0"
},
"type" : "startSession"
}
[AppCenter] VERBOSE: -[MSACAppCenterIngestion willSendHTTPRequestToURL:withHeaders:]/101 URL: https://in.appcenter.ms/logs?api-version=1.0.0
[AppCenter] VERBOSE: -[MSACAppCenterIngestion willSendHTTPRequestToURL:withHeaders:]/102 Headers: Content-Type = application/json, App-Secret = *****41919810, Install-ID = 2EF19D61-1EEF-409F-B546-8BA63D4119C3
+1, Same here.
There is a simple solution which is to move the AppCenter.Start to "onAppear" of the root view. But it took a long time for me to realize this bug was caused by App Center.
Hello @megabitsenmzq, I was able to reproduce this behaviour and confirm that issue exists.
As you say - temporary workaround here - is to move AppCenter.Start to "onAppear" of the root view.
Now I'm working on finding the root cause of this issue. Will update this thread with results.
@megabitsenmzq, I've investigated this case and found the following:
this behaviour related to specific SwiftUI lifecycle. AppCenter SDK uses UIKit lifecycle. So you need to initialize AppCenter in a way of UIKit App Delegate Lifecycle , here is example on how to do it:
import SwiftUI
import UIKit
import AppCenter
import AppCenterDistribute
import AppCenterAnalytics
import AppCenterCrashes
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
AppCenter.start(withAppSecret: "appsecret", services:[
Crashes.self, Analytics.self, Distribute.self])
return true
}
}
@main
struct AccentColorApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
}
Also, as a workaround, you can move AppCenter.Start to "onAppear" of the root view.
I know. But it's still an issue. If it's difficult to fix, it should be mentioned in the documentation. It took almost a year for me to realize this was caused by the AppCenter. I even tried to add a bunch of "accentColor(.accent)" to fix that. Still hope you can find a way. ๐ค
This information has been added to AppCenter documentation. Closing issue.
It works.
func applicationWillEnterForeground(_ application: UIApplication) {
AppCenter.start(withAppSecret: "appsecret", services:[
Crashes.self, Analytics.self, Distribute.self])
}