IOS 12 WiFi failed to obtain THE SSID(WiFi name) and BSSID(MAC address) 4, [Xcode 10] library not found for -lstdc++.6.0.9 5, [iOS 12.1] tabbar icon and text are not in the correct position when the secondary page is returned 7. [iPhone X]StatusBar internal structure changes, causing crash

The article is from my book Jane: the original is here

  • Update Xcode 10 to produce ‘XXX/info.plist’ Multiple Commands produce ‘XXX/info.plist’, the project has a repeatedly named info.plist file. Solution: (I) Standard solution: delete all duplicate files. Xcode menu bar File -> Workspace Settings -> Build System -> Legacy Build System; Xcodeprj Project: Xcode menu bar File -> Project Settings -> Build System -> Legacy Build System.

  • IOS 12 failed to obtain WiFi SSID(WiFi name) and BSSID(MAC address). After iOS 12, Apple improved the permission control for obtaining WiFi name and MAC address. To obtain these information, you need to manually enable the permission for obtaining WiFi information for an application. For details, see Obtaining the WiFi Name and MAC Address of an iOS Device + Obtaining iOS12 Failed. Solution: In the developer account, check the Access WiFi Infomation option of the App ID of the project; In Xcode’s Capabilities, check the Access WiFi Infomation option for your project.

  • In Xcode 10, you can enter #import to import file/library header file and Xcode will flash back. Or type #import to import the header without prompting. Xcode menu bar File -> Workspace Settings -> Build System -> Legacy Build System; Xcodeprj Project: Xcode menu bar File -> Project Settings -> Build System -> Legacy Build System.

  • Apple removed libstdc++ in Xcode 10 and iOS 12 and replaced it with libc++. Libstdc++ has been marked deprecated for 5 years and is recommended to use the LLVM optimized libc++ library that fully supports C++11. Libstdc++ libraries in Xcode 10 (libstdc++, libstdc++.6, libstdc++6.0.9) have been removed. TARGETS -> Build Phases -> Link Binary With Libraries delete stdc++.6.0.9 and add libc++.tdb. TARGETS -> Build Settings -> Other Linker Flags, delete -l “stdc++.6.0.9”. Change the code to rely on libc++. Import libstdc++ from Xcode 9 into Xcode 10. Copy the libstdc++ library file in Xcode 9 to the lib folder in Xcode 10. Refer to the following path method, which is the runtime file import of the real machine and emulator respectively:

    cp /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libstdc++.* /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/ cp /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib /libstdc++.* /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/us r/lib/Copy the code
  • IOS 12.1 UINavigationController+UITabBarController, UITabBar is sanded, And use pushViewController hidesBottomBarWhenPushed = YES, in the use of popViewController: animated return, return or gestures, can appear tabbar layout disorder, Icon and text offset problem. The immediate cause of this problem is that when the UITabBar is sanded, the tabBar button UITabBarButton is set to the wrong frame when the page is returned. The frame. Size is changed to (0, 0). The simplest solution is:

    [[UITabBar appearance].translucent = NO;
    Copy the code
  • 6. The status bar disappears after the webView plays the video and returns. When the main window becomes KeyWindow, UIStatusBar is still hidden. Solution:

    - (void)videoPlayerFinishedToShowStatusBar
    {
        if(@ the available (iOS 12.0, *)) { [[NSNotificationCenter defaultCenter] addObserverForName:UIWindowDidBecomeKeyNotification object:self.window queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) { [[UIApplication sharedApplication]setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone]; }]; }}Copy the code
  • After apple launched full-screen bangs at the end of 2017, the internal structure of StatusBar at the top of the application changed. If the StatusBar icon is used in the project to obtain the status information of the phone (such as: Get the current network status), a crash will occur on iPhone X (Xs,Xs Max,XR) phones. Note: The model that crashed was the iPhone X (Xs,Xs Max,XR) with bangs. For example, obtain the current network status.

    crash log: *** Terminating app due to uncaught exception'NSUnknownKeyException',
    reason: '[<UIStatusBar_Modern 0x7ffbf2c05670> valueForUndefinedKey:]:
    this class is not key value coding-compliant for the key foregroundView.'
    Copy the code

    The code that causes the above crash is as follows:

    - (NSString *)getiPhoneNetWorkStates
    {
        UIApplication *app = [UIApplication sharedApplication];
        NSString *states = @"UnKnow";
        NSArray *subViews = [[[app valueForKeyPath:@"statusBar"] valueForKeyPath:@"foregroundView"] subviews];
        for (id child in subViews) {
            if ([child isKindOfClass:NSClassFromString(@"UIStatusBarDataNetworkItemView")]) {
                int networkType = [[child valueForKeyPath:@"dataNetworkType"] intValue];
                NSString *networkStatus = @"UnKnow";
                switch (networkType) {
                    case 0:
                        networkStatus = @"UnKnow";
                        break;
                    case 1:
                        networkStatus = @"2G";
                        break;
                    case 2:
                        networkStatus = @"3G";
                        break;
                    case 3:
                        networkStatus = @"4G";
                        break;
                    case 4:
                        networkStatus = @"LTE";
                        break;
                    case 5:
                        networkStatus = @"WiFi";
                        break;
                    default:
                        break; }}}return states;
    }
    Copy the code

    The reason for the crash was that the StatusBar internal structure had changed and the foregroundView did not exist when fetched at line 5 above. Solution: On iPhone X, the StatusBar can only check whether the network is WiFi or cellular. When the network is cellular, it cannot check the specific network status. To obtain more detailed network information, you are advised to use the official Reachability.

    - (NSString *)getiPhoneNetWorkStates
    {
        UIApplication *app = [UIApplication sharedApplication];
        NSString *states = @"UnKnow";
        id statusBar = [app valueForKeyPath:@"statusBar"];
        if ([self checkDeviceIsiPhoneX]) {
            if ([statusBar isKindOfClass:NSClassFromString(@"UIStatusBar_Modern")]) {
                id curData = [statusBar valueForKeyPath:@"statusBar.currentData"];
                BOOL wifiEnable = [[curData valueForKeyPath:@"_wifiEntry.isEnabled"] boolValue];
                BOOL cellEnable = [[curData valueForKeyPath:@"_cellularEntry.isEnabled"] boolValue]; // The StatusBar on iPhone X can only check whether the network is WiFi or cellular // The specific network status cannot be checked when the network is cellularif (wifiEnable) {
                    states = @"WiFi";
                } else if (cellEnable) {
                    states = @"Cellular"; }}}else {
            NSArray *subViews = [[statusBar valueForKeyPath:@"foregroundView"] subviews];
            for (id child in subViews) {
                if ([child isKindOfClass:NSClassFromString(@"UIStatusBarDataNetworkItemView")]) {
                    int networkType = [[child valueForKeyPath:@"dataNetworkType"] intValue];
                    switch (networkType) {
                        case 0:
                            states = @"UnKnow";
                            break;
                        case 1:
                            states = @"2G";
                            break;
                        case 2:
                            states = @"3G";
                            break;
                        case 3:
                            states = @"4G";
                            break;
                        case 4:
                            states = @"LTE";
                            break;
                        case 5:
                            states = @"WiFi";
                            break;
                        default:
                            break; }}}}return states;
    }
    Copy the code