一些问题的解决方案


Multiple commands produce 'xxx/Info.plist'

原因:项目中存在重复命名的info.plist文件

方案:

  • xcworkspace项目: Xcode左上角菜单栏 File –> Workspace Settings –> Build System – >Legacy Build System
  • xcodeproj项目:Xcode左上角菜单栏 –> File –> Project Settings –> Build System –> Legacy Build System


library not found for -l”stdc++.6.0.9

原因:Xcode10去除了C++6.0.9的支持

方案:

  • TARGETS–Build Phases–Link Binary With Libraries,删除6.0.9依赖,需要的话对应添加libc++.tdb、libstdc++.tdb
  • TARGETS–Build Settings–Other Linker Flags,删除 -l”stdc++.6.0.9”
  • 如果是第三库引用了C++6.0.9库,那就只能联系服务方修改了


WebView播放视频返回后状态栏不见了

原因:视频播放完成主window成为KeyWindow的时候仍隐藏着UIStatusBar

方案:

- (void)videoPlayerFinishedToShowStatusBar {
    if (@available(iOS 12.0, *)) {
        [[NSNotificationCenter defaultCenter] addObserverForName:UIWindowDidBecomeKeyNotification
                                                          object:self.window
                                                           queue:[NSOperationQueue mainQueue]
                                                      usingBlock:^(NSNotification * _Nonnull note) {
                                                          [[UIApplication sharedApplication] setStatusBarHidden:NO
                                                                                                  withAnimation:UIStatusBarAnimationNone];
                                                      }];
    }
}


wifi获取SSID(wifi名称)失败

原因:需要加权限

方案:

  • 到开发者界面 在App IDs对应的bundleID中勾选Access WiFi Infomation

  • 然后在Xcode的Capabilities中,激活Access WiFi Infomation项。


statusBar结构变化导致原来通过状态栏获取网络连接信息代码crash

方案:

+ (NSString *)getIphoneXNetWorkStates {    
    UIApplication *app = [UIApplication sharedApplication];
    id statusBar = [[app valueForKeyPath:@"statusBar"] valueForKeyPath:@"statusBar"];
    id one = [statusBar valueForKeyPath:@"regions"];
    id two = [one valueForKeyPath:@"trailing"];
    NSArray *three = [two valueForKeyPath:@"displayItems"];
    NSString *state = @"无网络";
    for (UIView *view in three) {
        //alert: iOS12.0 情况下identifier的变成了类"_UIStatusBarIdentifier"而不是NSString,所以会在调用“isEqualToString”方法时发生crash,
        //修改前
//        NSString *identifier = [view valueForKeyPath:@"identifier"];
        //修改后
        NSString *identifier = [[view valueForKeyPath:@"identifier"] description];
        if ([identifier isEqualToString:@"_UIStatusBarWifiItem.signalStrengthDisplayIdentifier"]) {
            id item = [view valueForKeyPath:@"_item"];

            //alert: 这个问题和上边一样itemId是_UIStatusBarIdentifier 类型,不是string
            NSString *itemId = [[item valueForKeyPath:@"identifier"] description];
            if ([itemId isEqualToString:@"_UIStatusBarWifiItem"]) {
                state = @"WIFI";
            }
            state = @"不确定";

        } else if ([identifier isEqualToString:@"_UIStatusBarCellularItem.typeDisplayIdentifier"]) {
            UIView *statusBarStringView = [view valueForKeyPath:@"_view"];
            // 4G/3G/E
            state = [statusBarStringView valueForKeyPath:@"text"];
        }

    }

    return state;
}
另附上Xcode10缺少libstdc++解决方法:

压缩包
文件夹1的文件放的位置: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/

文件夹2的文件放的位置:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/

文件夹3的文件放的位置:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/

文件夹4的文件放的位置:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/

升级Xcode后xib报错 Failed to find or create execution context for description ...

方案:

  1. 重启

  2. 不想重启就试试在终端执行下面命令

sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService

# 将你xcode中Developer文件夹位置放进来
sudo xcode-select -s  /Applications/Xcode.app/Contents/Developer

xcrun simctl erase all

你可能感兴趣的:(一些问题的解决方案)