16

When I redirect from main viewController to another viewController I'm getting this

Error:

Lazy loading NSBundle MobileCoreServices.framework,

Loaded MobileCoreServices.framework,

System group container for systemgroup.com.apple.configurationprofiles path is /Users/develop/Library/Developer/CoreSimulator/Devices/083C0102-C85F-463A-96F4-CA1B9AC7919D/data/Containers/Shared/SystemGroup/ systemgroup.com.apple.configurationprofiles

My code is...

Appdelegate.m

if (![[NSUserDefaults standardUserDefaults] boolForKey:@"HasLaunchedOnce"]) {
    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"HasLaunchedOnce"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    NSLog(@"Launched first time");
} else {
    NSLog(@"Already launched");
    [self getData];
}

viewDidLoad

if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HasLaunchedOnce"]) {

    dispatch_async(dispatch_get_main_queue(), ^{
        LoginPageViewController *lpvc = [self.storyboard instantiateViewControllerWithIdentifier:@"LPVC"];
        [self.navigationController pushViewController:lpvc animated:NO];
    });
} else {
    // My code...
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
Naresh
  • 16,698
  • 6
  • 112
  • 113
  • When I commenting this line it's working properly..[self.navigationController pushViewController:lpvc animated:NO]; – Naresh Sep 27 '17 at 05:14
  • why geting the main thread in viewDidLoad? , I think viewDidLoad itself is on main thread – MOHAMMAD ISHAQ Sep 27 '17 at 05:38
  • I want to redirect to login page when it's first launch...can u give any solution for me – Naresh Sep 27 '17 at 05:43
  • 1
    Notes: this issue is specific to Xcode 9 and happens in Swift as well or without any navigationcontroller. – Cœur Sep 27 '17 at 15:32

2 Answers2

26

The message you have is from Xcode 9. The equivalent message in Xcode 8 would be:

[MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/develop/Library/Developer/CoreSimulator/Devices/083C0102-C85F-463A-96F4-CA1B9AC7919D/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles

Note the [MC]: It is a system message. This message can safely be ignored.

To hide this kind of messages, follow the solution from https://stackoverflow.com/a/42140442/1033581:

  1. Under Product > Scheme > Edit Scheme... > Run, set the OS_ACTIVITY_MODE environment variable to ${DEBUG_ACTIVITY_MODE} so it looks like this:

OS_ACTIVITY_MODE environment variable to ${DEBUG_ACTIVITY_MODE}

  1. Go to your project build settings, and click + to add a User-Defined Setting named DEBUG_ACTIVITY_MODE. Expand this setting and Click the + next to Debug to add a platform-specific value. Select the dropdown and change it to "Any iOS Simulator SDK". Then set its value to "default" so it looks like this:

User-Defined setting DEBUG_ACTIVITY_MODE

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • 1
    You could just redirect him to the answer you mentioned: https://stackoverflow.com/a/39573801/465235 – Yassine ElBadaoui Oct 30 '17 at 07:21
  • 3
    @YassineElBadaoui, no, using `disable` is not what I recommend. I recommend `default` to avoid losing your own NSLog on Xcode 9. – Cœur Oct 30 '17 at 07:35
0

Update code in your app delegate.

if (![[NSUserDefaults standardUserDefaults] boolForKey:"HasLaunchedOnce"]){
       LoginPageViewController *lpvc = [self.storyboard instantiateViewControllerWithIdentifier:@"LPVC"];
       self.window.rootViewController = lpvc;
       NSLog(@"Launched first time");
      [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"HasLaunchedOnce"];
      [[NSUserDefaults standardUserDefaults] synchronize];

}else {
      MainViewController *mainVC = [self.storyboard instantiateViewControllerWithIdentifier:@"MainVC"];
      self.window.rootViewController = mainVC;
     NSLog(@"Already launched");
     [self getData];
}
MOHAMMAD ISHAQ
  • 988
  • 7
  • 15