How do I disable Parse Analytics during development. I tried commenting out the setApplicationId: clientKey: call but as there are events being tracked throughout my code this causes an exception.
Parse doesn't have a native functionality for disabling analytics during development, but you can wrap your events code using an #ifdef - #else - #endif statement
#ifdef DEBUG
#else
[PFAnalytics trackEvent:#"eventName" dimensions:#{ #"parameter": #"value" }];
#endif
As long as you are running with DEBUG enabled (dev environments), this event tracker will not run.
You may also need to check the settings for your build to ensure it is DEBUG mode. See this answer for help:
Xcode / iOS: How to determine whether code is running in DEBUG / RELEASE build?
Related
I am running Flutter integration tests on iOS Simulator using Bitrise.
Each time I need to start new instance of iOS. Due to Apple's privacy policy, I get the alert "Allow app to track your activity across other companies' apps and website?" on each new start of my app. And it blocks my tests.
I there a way to get rid of this alert on start of iOS Simulator?
How to disable the option with a single command?
There is something called a "pre processor flag" that you can use to wrap the code that executes in a special kind of if statement. By default you can do:
#if DEBUG
// do something if it's not production
#else
// trigger the alert
#endif
However, that won't let you test it manually on your device unless you build a production release. You can add special flags to your test target's build settings that will only trigger in that target.
Then we could write:
#if UITEST
// do nothing here
#else
// launch the alert
#endif
I want to disable OSLog for my iOS app (release build). I am not using OSLog in my app but I still see some logs in the console app logged by the apple frameworks (like libnetwork, Corefoundation, SystemConfiguration etc.,). Is there is a way to completely turn off all the logs for the app?
I added the below values to the environment variable but still, it disables the logs only when I ran the application from XCode however, I still see OSLog for my app on the console app when I launch it by clicking the App Icon.
OS_ACTIVITY_MODE=disable
Note: My app uses both Objective C and Swift programming language and disabled NSLog(Objective C) and print(Swift) and I do not have an issue with it. I want to disable all the logs including logs from the Apple framework for my release build.
just a quick solution but not the most comfortable..
#ifndef DEBUG
#define OSLog(FORMAT, ...) {}
#endif
if DEBUG mode is not used, which should be RELEASE then, OSLog() will be exchanged with void function content at compile time. Which will apply to code you wrote, not turning off Logs in general outside your sources scope.
To Disable OSLog on Release Builds
You could create a global function like:
func customLogger(_ category: String) -> OSLog {
#if DEBUG
return OSLog(subsystem: Bundle.main.bundleIdentifier!, category: category)
#else
return OSLog.disabled
#endif
}
For more detailed and advanced scenarios please check Apple's official documentation.
are events from the debug builds included in Firebase Analytics reports by default?
If they're included, how can I disable Firebase Analytics for the iOS debug builds?
Currently I use the following code to configure the Firebase Analytics:
analyticsEnabled = // Fetch whether the analytics should be enabled
FirebaseApp.configure()
// analyticsEnabled = false can be added here for DEBUG builds
updateDataCollectionConfiguration()
}
#objc public static func updateDataCollectionConfiguration() {
Analytics.setAnalyticsCollectionEnabled(analyticsEnabled)
}
I've added a line, where I can force disable analytics for debug builds, but the two questions are still relevant - whether it's needed (is such analytics data even collected for debug builds) and is there any "simpler" way to achieve the same goal, e.g. filter debug-data in the Firebase Console?
Firebase collects data for debug mode also.
You can check for debug mode using :
#ifdef DEBUG
analyticsEnabled = false
updateDataCollectionConfiguration()
My application is frequently receiving memory warnings and crashes with I enable NSLog statements and run it via XCode 6.1. It works fine in release mode by disabling NSLog statements. I am not able to memory profile the app using instruments as even instrument hangs when I run with NSLog statements enabled.
Has anyone faced this issue and know of a workaround?
This is how I am defining a macro to enable logs when running in DEBUG mode.
#ifdef DEBUG
#define MYLOG(...) NSLog(__VA_ARGS__)
....
MYLOG(#"Log something");
I am using the following and It works fine for me.
#ifdef DEBUG
#define MYLOG(format, ...) NSLog(format, ##__VA_ARGS__)
#else
#define MYLOG(...)
#endif
Found the issue. It was not NSLog. Application was crashing in Debug mode only and it was because NSZombie was enabled. Once I disabled NSZombie, it worked!
I use TestFlight for crash reporting and logging check points for testing in development. But for live app, I want to use crash reporting only.
To disable check points I can use preprocessor macro.e.g.
#ifdef TESTFLIGHT
[TestFlight passCheckpoint:#"Some event occurred"];
#endif
But problem with this approach is that I need to use this condition every time I send check point to TestFlight. I have around 70 check points.
I am looking for a way where I need to configure at one or two places in project and don't need to care about adding if condition for each new check point I add to project.
Please note that I do want to use TestFlight for crash reporting so I cannot completely disable TestFlight.
In some common header:
#ifdef TESTFLIGHT
#define TF_PASSCHECKPOINT(s) [TestFlight passCheckpoint:(s)];
#else
#define TF_PASSCHECKPOINT(s)
#endif
Then just say:
- (void)someFunction {
TF_PASSCHECKPOINT(#"entered someFunction");
...
}