Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [iOS][objective-c] when freopen is called, can't pass the next line of code
Forum Updated to NodeBB v4.3 + New Features

[iOS][objective-c] when freopen is called, can't pass the next line of code

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 313 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    ysbaekFox
    wrote on 24 Jun 2021, 03:24 last edited by
    #1

    Hello all.

    I have a problem in qt-iOS environment.

    First, my environnment is below.

    • XCode Version 12.5
    • QT 5.14.2
    • Fixed : https://codereview.qt-project.org/c/qt/qtbase/+/314522/1/mkspecs/features/toolchain.prf
    • I didn't use QT, I used [projectName].xcodeproj generated as a result of QT Build
    • iOS Device 14.6

    I want to save the log output from my app as a file on the device.
    I've found a very simple way to use it in an iOS environment.

    The way I found is to redirect the Console Log and save it to a file.

    • https://stackoverflow.com/questions/3184235/how-to-redirect-the-nslog-output-to-file-instead-of-console

    When I used this solution, I've actually seen it work and create a Log File.
    However, this solution works and doesn't work for some unknown reason. (intermittently does not work)

    Is this a bug in QT? Or is there a problem using my solution?

    @implementation QIOSApplicationDelegate (QTAppDelegate)
    - (BOOL)application:(UIApplication *)application
      didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        NSLog(@"[AppDelegate_Log] didFinishLaunchingWithOptions");
        NSDateFormatter *currrentSystemTime = [[NSDateFormatter alloc] init];
        [currrentSystemTime setDateFormat:@"ddhhmm"];
        NSString *logFileName = @"logcat_";
        NSString *logStartTime = [currrentSystemTime stringFromDate:[NSDate date]];
        logFileName = [logFileName stringByAppendingString:logStartTime];
        logFileName = [logFileName stringByAppendingString:@".log"];
        NSLog(@"[AppDelegate_Log] logFile Name : %@", logFileName);
        
    #if TARGET_IPHONE_SIMULATOR == 0
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSString *logPath = [documentsDirectory stringByAppendingPathComponent:logFileName];
        NSLog(@"[AppDelegate_Log] logFile Path : %@", logPath);
    
        NSFileManager *fileManager = [NSFileManager defaultManager];
        NSArray *fileList = [fileManager contentsOfDirectoryAtPath:documentsDirectory error:NULL];
        NSLog(@"[AppDelegate_Log] fileList!!!! : %@", fileList);
    
        freopen([logPath cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr);
    #endif
    
        NSLog(@"[AppDelegate_Log] Exit");
        return YES;
    }
    @end
    

    log_screenshot.png

    1 Reply Last reply
    0

    1/1

    24 Jun 2021, 03:24

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved