【问题标题】:Why I am getting Lazy loading NSBundle MobileCoreServices.framework?为什么我会延迟加载 NSBundle MobileCoreServices.framework?
【发布时间】:2018-03-08 11:17:37
【问题描述】:

当我从主 viewController 重定向到另一个 viewController 我收到了

错误:

懒加载NSBundle MobileCoreServices.framework,

已加载 MobileCoreServices.framework,

systemgroup.com.apple.configurationprofiles 的系统组容器 路径是 /Users/develop/Library/Developer/CoreSimulator/Devices/083C0102-C85F-463A-96F4-CA1B9AC7919D/data/Containers/Shared/SystemGroup/ systemgroup.com.apple.configurationprofiles

我的代码是...

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...
}

【问题讨论】:

  • 当我评论这一行时它工作正常..[self.navigationController pushViewController:lpvc animated:NO];
  • 为什么要在 viewDidLoad 中获取主线程? ,我认为 viewDidLoad 本身在主线程上
  • 我想在首次启动时重定向到登录页面...你能为我提供任何解决方案吗
  • 注意:这个问题是 Xcode 9 特有的,在 Swift 中也会发生,或者没有任何导航控制器。

标签: ios objective-c uiviewcontroller appdelegate xcode9


【解决方案1】:

您收到的消息来自 Xcode 9。 Xcode 8 中的等效消息是:

[MC] systemgroup.com.apple.configurationprofiles 路径的系统组容器是 /Users/develop/Library/Developer/CoreSimulator/Devices/083C0102-C85F-463A-96F4-CA1B9AC7919D/data/Containers/Shared/SystemGroup/ systemgroup.com.apple.configurationprofiles

注意[MC]: 这是一条系统消息。可以放心地忽略此消息。

要隐藏此类消息,请按照https://stackoverflow.com/a/42140442/1033581的解决方案:

  1. 在 Product > Scheme > Edit Scheme... > Run 下,将 OS_ACTIVITY_MODE 环境变量设置为 ${DEBUG_ACTIVITY_MODE},如下所示:

  1. 转到您的项目构建设置,然后单击 + 添加名为 DEBUG_ACTIVITY_MODE 的用户定义设置。展开此设置并单击“调试”旁边的 + 以添加特定于平台的值。选择下拉菜单并将其更改为“任何 iOS 模拟器 SDK”。然后将其值设置为“默认”,如下所示:

【讨论】:

  • 您可以将他重定向到您提到的答案:stackoverflow.com/a/39573801/465235
  • @YassineElBadaoui,不,我不推荐使用disable。我推荐default 以避免在 Xcode 9 上丢失您自己的 NSLog。
【解决方案2】:

在您的应用委托中更新代码。

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];
}

【讨论】:

  • 解决方案1遇到同样的问题..对于需要编写此代码的解决方案2
  • 我进入 appdelegate self.storyboard not found 错误
  • self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
  • 是的,你必须为storyboard和window做插座,现在可以了吗?
  • 好的,感谢您为我花费宝贵的时间,但我遇到了同样的错误...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2010-09-07
  • 1970-01-01
  • 1970-01-01
  • 2010-12-01
  • 1970-01-01
  • 2022-01-22
  • 1970-01-01
相关资源
最近更新 更多