推薦閱讀:iOS開(kāi)發(fā)——BAT面試題合集(持續(xù)更新中)
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
文章來(lái)自于我的簡(jiǎn)書(shū):原文在這里
-
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)之后,蘋(píng)果提升了獲取WiFi
名稱和mac
地址的權(quán)限控制夷野,要獲取這些信息懊蒸,需要手動(dòng)為應(yīng)用打開(kāi)獲取WiFi信息的權(quán)限。具體操作可以參考《 獲取iOS設(shè)備WiFi名字和mac地址+iOS12系統(tǒng)獲取失敗解決 》悯搔。解決方案:
在開(kāi)發(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
閃退灌曙【盏或者輸入#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蘋(píng)果在
Xcode 10
和iOS 12
中移除了libstdc++
庫(kù)增炭,由libc++
這個(gè)庫(kù)取而代之,蘋(píng)果的解釋是libstdc++已經(jīng)標(biāo)記為廢棄有5年了拧晕,建議大家使用經(jīng)過(guò)了llvm優(yōu)化過(guò)并且全面支持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)入:<pre class="prettyprint hljs awk" style="padding: 0.5em; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; color: rgb(68, 68, 68); border-radius: 4px; display: block; margin: 0px 0px 1.5em; font-size: 14px; line-height: 1.5em; word-break: break-all; word-wrap: break-word; white-space: pre; background-color: rgb(246, 246, 246); border: none; overflow-x: auto;">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/
復(fù)制代碼</pre> -
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)和文字位置偏移的問(wèn)題揖盘。出現(xiàn)這個(gè)問(wèn)題的直接原因是UITabBar
為磨砂的情況下,返回頁(yè)面時(shí)tabBar
內(nèi)的按鈕UITabBarButton
被設(shè)置了錯(cuò)誤的frame
锌奴,frame.size
變?yōu)榱?(0, 0) 兽狭。最簡(jiǎn)單的解決方案是:
<pre class="hljs json" style="padding: 0.5em; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; color: rgb(68, 68, 68); border-radius: 4px; display: block; margin: 0px 0px 0.75em; font-size: 14px; line-height: 1.5em; word-break: break-all; word-wrap: break-word; white-space: pre; background-color: rgb(246, 246, 246); border: none; overflow-x: auto;">[[UITabBar appearance].translucent = NO;
復(fù)制代碼</pre> -
6、
webView
播放視頻返回后狀態(tài)欄消失視頻播放完成主
window
成為KeyWindow
的時(shí)候仍隱藏著UIStatusBar
鹿蜀。解決方案:
<pre class="prettyprint hljs less" style="padding: 0.5em; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; color: rgb(68, 68, 68); border-radius: 4px; display: block; margin: 0px 0px 1.5em; font-size: 14px; line-height: 1.5em; word-break: break-all; word-wrap: break-word; white-space: pre; background-color: rgb(246, 246, 246); border: none; overflow-x: auto;">- (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];
}];
}
}
復(fù)制代碼</pre> -
7箕慧、[
iPhone X
]StatusBar
內(nèi)部結(jié)構(gòu)改變導(dǎo)致crash
蘋(píng)果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)伐庭。<pre class="prettyprint hljs vbnet" style="padding: 0.5em; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; color: rgb(68, 68, 68); border-radius: 4px; display: block; margin: 0px 0px 1.5em; font-size: 14px; line-height: 1.5em; word-break: break-all; word-wrap: break-word; white-space: pre; background-color: rgb(246, 246, 246); border: none; overflow-x: auto;">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.'
復(fù)制代碼</pre>導(dǎo)致上面崩潰的代碼如下:
<pre class="prettyprint hljs objectivec" style="padding: 0.5em; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; color: rgb(68, 68, 68); border-radius: 4px; display: block; margin: 0px 0px 1.5em; font-size: 14px; line-height: 1.5em; word-break: break-all; word-wrap: break-word; white-space: pre; background-color: rgb(246, 246, 246); border: none; overflow-x: auto;">- (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;
}
復(fù)制代碼</pre>導(dǎo)致崩潰的原因是:
StatusBar
內(nèi)部結(jié)構(gòu)發(fā)生變化,在上面代碼第5行獲取foregroundView
的時(shí)候分冈,foregroundView
不存在圾另。解決方案:
iPhone X上通過(guò)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坡椒。
<pre class="prettyprint hljs objectivec" style="padding: 0.5em; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; color: rgb(68, 68, 68); border-radius: 4px; display: block; margin: 0px 0px 1.5em; font-size: 14px; line-height: 1.5em; word-break: break-all; word-wrap: break-word; white-space: pre; background-color: rgb(246, 246, 246); border: none; overflow-x: auto;">- (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上通過(guò)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;
}
復(fù)制代碼</pre>
喜歡的話可以點(diǎn)個(gè)贊+1:或關(guān)注多多支持哦 小編會(huì)經(jīng)常給小伙伴們更新關(guān)于IOS當(dāng)下熱點(diǎn)尤溜。
另外小編給大家推薦一個(gè)iOS技術(shù)交流群:638302184!群內(nèi)提供數(shù)據(jù)結(jié)構(gòu)與算法汗唱、底層進(jìn)階宫莱、swift、逆向哩罪、整合面試題等免費(fèi)資料
附上一份收集的各大廠面試題(附答案) ! 群文件直接獲取
各大廠面試題
文章來(lái)源網(wǎng)絡(luò) 如有侵權(quán)請(qǐng)聯(lián)系小編刪除