Can't get DYLD_PRINT_STATISTICS environment variable working

See original GitHub issue

The problem

We are trying to use DYLD_PRINT_STATISTICS environment variable in our scenarios be we can’t get it working. We are successfully sending launch arguments but environment is causing us issues.

Environment

  • Appium version (or git revision) that exhibits the issue: 1.6.4
  • Last Appium version that did not exhibit the issue (if applicable):
  • Desktop OS/version used to run Appium: macOS
  • Node.js version (unless using Appium.app|exe): v7.9.0
  • Mobile platform/version under test: iOS
  • Real device or emulator/simulator: simulator
  • Appium CLI or Appium.app|exe: Appium CLI

Details

We spent quite a lot of time trying different combinations like putting env inside of processArguments, outside of it, prefixing SIMCTL_CHILD_, … It seems like right way to pass it should be:

"processArguments": {"args": [], "env": {"DYLD_PRINT_STATISTICS": 1}}

If this flag is successfully applied, logs should contain something like this:

Total pre-main time: 1.1 seconds (100.0%)
         dylib loading time: 372.25 milliseconds (31.4%)
        rebase/binding time: 646.09 milliseconds (54.6%)
            ObjC setup time:  79.70 milliseconds (6.7%)
           initializer time:  85.07 milliseconds (7.1%)
           slowest intializers :
               libSystem.dylib :   3.25 milliseconds (0.2%)

Are we missing something here or it is Appium issue?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
jcavarcommented, Jul 13, 2017

@sukeshmlr this is what we do:

void __attribute__ ((constructor)) premain() {
    // Redirect logs only if console is not attached
    if (!isatty(STDERR_FILENO)) {
        const char *redirect_log_path_char = [redirectLogPath cStringUsingEncoding:NSUTF8StringEncoding];
        NSLog(@"----Redirect stderr Path-----");
        NSLog(@"%s", redirect_log_path_char);
        NSLog(@"----Redirect stderr Path-----");
        freopen(redirect_log_path_char, "a+", stderr);
    }
}

You can put this somewhere in main.m

0reactions
lock[bot]commented, Jul 4, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DYLD_PRINT_STATISTICS not working - Apple Developer
Hello! I'm working on a new app, and DYLD_PRINT_STATISTICS=1 is not working - i.e., not producing any output. Build platform: MacBook Pro (15-inch,...
Read more >
ios - DYLD_PRINT_STATISTICS not showing anything
I've added the environment variables DYLD_PRINT_STATISTICS and DYLD_PRINT_LIBRARIES to see what the linker is doing, but all the output I get is ...
Read more >
Start iOS app with DYLD_PRINT_STATISTICS=YES - 睿论坛
How to pass custom environment variables to iOS UI app? For example, DYLD_PRINT_STATISTICS=YES. I've tried open package from Cydia (com.conradkramer.open):
Read more >
Code Injection with Dyld Interposing | by Noah Martin - Medium
DYLD_INSERT_LIBRARIES is an environment variable that allows you to add code to an app's process. The format is just a colon separated list ......
Read more >
jtool - Taking the O out of otool(1), and so much more
The SLC is located in /var/db/dyld (OS X) and /System/Library/Caches/com.apple.dyld (iOS). The OS X cache also has a "map", but the iOS one...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found