1、Multiple commands produce 'xxx/Info.plist'
2、iOS 12系統(tǒng)WiFi獲取SSID(wifi名稱)和BSSID(mac地址)失敗
3、Xcode 10中#import的時(shí)候閃退或?qū)腩^文件不提示
4、[Xcode 10] library not found for -lstdc++.6.0.9
5、[iOS 12.1] 二級(jí)頁(yè)面返回時(shí)tabbar圖標(biāo)和文字位置偏移
6、webView播放視頻返回后狀態(tài)欄消失
7、[iPhone X]StatusBar內(nèi)部結(jié)構(gòu)改變導(dǎo)致crash
1、Multiple commands produce 'xxx/Info.plist'
升級(jí)Xcode 10之后,編譯之前的項(xiàng)目,發(fā)生編譯錯(cuò)誤:Multiple commands produce 'xxx/Info.plist',項(xiàng)目中存在重復(fù)命名的info.plist文件。
解決方案:
(I)標(biāo)準(zhǔn)方案:刪除所有重復(fù)命名的文件。
(II)臨時(shí)方案:
xcworkspace項(xiàng)目:Xcode菜單欄File->Workspace Settings->Build System->Legacy Build System;
xcodeprj項(xiàng)目:Xcode菜單欄File->Project Settings->Build System->Legacy Build System。2、
iOS 12系統(tǒng)WiFi獲取SSID(wifi名稱)和BSSID(mac地址)失敗
在iOS 12系統(tǒng)之后,蘋果提升了獲取WiFi名稱和mac地址的權(quán)限控制,要獲取這些信息,需要手動(dòng)為應(yīng)用打開獲取WiFi信息的權(quán)限。具體操作可以參考《獲取iOS設(shè)備WiFi名字和mac地址+iOS12系統(tǒng)獲取失敗解決》。
解決方案:
在開發(fā)者賬號(hào)中,勾選項(xiàng)目的App ID的Access WiFi Infomation選項(xiàng);
在Xcode的Capabilities中,勾選項(xiàng)目的Access WiFi Infomation選項(xiàng)。3、
Xcode 10中#import的時(shí)候閃退或?qū)腩^文件不提示
在Xcode 10中出現(xiàn)輸入#import引入文件/類庫(kù)頭文件的時(shí)候Xcode閃退?;蛘咻斎?code>#import導(dǎo)入頭文件時(shí)不提示。
解決方案:
xcworkspace項(xiàng)目:Xcode菜單欄File->Workspace Settings->Build System->Legacy Build System;
xcodeprj項(xiàng)目:Xcode菜單欄File->Project Settings->Build System->Legacy Build System。-
4、[
Xcode 10] library not found for -lstdc++.6.0.9
蘋果在Xcode 10和iOS 12中移除了libstdc++庫(kù),由libc++這個(gè)庫(kù)取而代之,蘋果的解釋是libstdc++已經(jīng)標(biāo)記為廢棄有5年了,建議大家使用經(jīng)過了llvm優(yōu)化過并且全面支持C++11的libc++庫(kù)。所以Xcode 10中l(wèi)ibstdc++相關(guān)的3個(gè)庫(kù)(libstdc++、libstdc++.6、libstdc++6.0.9)都已被移除,不可再使用。
解決方案:
(I)調(diào)整代碼為依賴libc++
更改c++庫(kù)文件,TARGETS->Build Phases->Link Binary With Libraries,刪除stdc++.6.0.9依賴,添加libc++.tdb;TARGETS->Build Settings->Other Linker Flags,刪除-l "stdc++.6.0.9"。修改代碼為依賴libc++。
(II)從Xcode 9中導(dǎo)入libstdc++到Xcode 10中。
找到Xcode 9中的libstdc++庫(kù)文件copy到Xcode 10的lib文件夾下。參考路徑方法如下,分別是真機(jī)和模擬器的運(yùn)行庫(kù)文件導(dǎo)入: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/usr/lib/ -
5、[
iOS 12.1] 二級(jí)頁(yè)面返回時(shí)tabbar圖標(biāo)和文字位置偏移
iOS 12.1系統(tǒng)中UINavigationController+UITabBarController,UITabBar為磨砂,并且pushViewController的時(shí)候使用hidesBottomBarWhenPushed = YES,則在使用popViewController:animated返回,或者手勢(shì)返回的時(shí)候,就會(huì)出現(xiàn)tabbar布局錯(cuò)亂,圖標(biāo)和文字位置偏移的問題。出現(xiàn)這個(gè)問題的直接原因是UITabBar為磨砂的情況下,返回頁(yè)面時(shí)tabBar內(nèi)的按鈕UITabBarButton被設(shè)置了錯(cuò)誤的frame,frame.size變?yōu)榱?(0, 0) 。
最簡(jiǎn)單的解決方案是:[[UITabBar appearance].translucent = NO; -
6、
webView播放視頻返回后狀態(tài)欄消失
視頻播放完成主window成為KeyWindow的時(shí)候仍隱藏著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]; }]; } } -
7、[
iPhone X]StatusBar內(nèi)部結(jié)構(gòu)改變導(dǎo)致crash
蘋果17年底推出全面屏劉海手機(jī)之后,應(yīng)用頂部StatusBar內(nèi)部結(jié)構(gòu)發(fā)生改變,如果項(xiàng)目中使用狀態(tài)欄中圖標(biāo)獲取手機(jī)狀態(tài)信息(如:獲取當(dāng)前網(wǎng)絡(luò)的狀態(tài)),則在iPhone X (Xs,Xs Max,XR)手機(jī)上會(huì)發(fā)生崩潰。
注意:發(fā)生崩潰的機(jī)型是有劉海的手機(jī)iPhone X (Xs,Xs Max,XR)。
例如獲取當(dāng)前網(wǎng)絡(luò)狀態(tài)。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.'導(dǎo)致上面崩潰的代碼如下:
- (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; }導(dǎo)致崩潰的原因是:
StatusBar內(nèi)部結(jié)構(gòu)發(fā)生變化,在上面代碼第5行獲取foregroundView的時(shí)候,foregroundView不存在。
解決方案:
iPhone X上通過StatusBar只能獲取到網(wǎng)絡(luò)是WiFi還是蜂窩網(wǎng),當(dāng)網(wǎng)絡(luò)為蜂窩網(wǎng)的時(shí)候,無(wú)法獲取到具體的網(wǎng)絡(luò)狀態(tài)。要獲取更具體的網(wǎng)絡(luò)狀況,建議使用官方提供的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]; // iPhone X上通過StatusBar只能獲取到網(wǎng)絡(luò)是WiFi還是蜂窩網(wǎng) // 當(dāng)網(wǎng)絡(luò)為蜂窩網(wǎng)的時(shí)候,無(wú)法獲取到具體的網(wǎng)絡(luò)狀態(tài) if (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; }