Xcode11.1 踩坑備忘錄

Xcode11.1 踩坑備忘錄(mac系統10.15)

1 、環信ChatDemo2.0報錯

這是環信ChatDemo2.0報錯html

  NSInteger numberOfBeforeSection = [_update[@"oldModel"] numberOfItemsInSection:updateItem.indexPathBeforeUpdate.section];

改成c++

 NSInteger numberOfBeforeSection = [(UICollectionView *)_update[@"oldModel"] numberOfItemsInSection:updateItem.indexPathBeforeUpdate.section];

 

二、暗黑模式暫時不適配的處理

全局配置 在工程的Info.plist的中,增長/修改 UIUserInterfaceStyle爲UIUserInterfaceStyleLight或UIUserInterfaceStyleDarkgit

 

三、library not found for -lstdc++.6.0.9

這個在xcode 10也存在的問題,採用大佬的方式處理,道理同樣把須要的文件放到對應的路徑下。不過大佬寫了一個腳本,更方便github

Xcode 10和Xcode 11中刪除的libstdc++庫    https://github.com/devdawei/libstdc-xcode

 

四、present到登陸頁面時,發現新頁面不能頂到頂部

緣由是iOS 13 多了一個新的枚舉類型 UIModalPresentationAutomatic,而且是modalPresentationStyle的默認值。瀏覽器

UIModalPresentationAutomatic實際是表現是在 iOS 13的設備上被映射成UIModalPresentationPageSheet。 ruby

可是須要注意一點PageSheet 與 FullScreen 生命週期並不相同 FullScreen會走完整的生命週期bash

,PageSheet由於父視圖並無徹底消失,因此viewWillDisappear及viewWillAppear並不會走,app

若是這些方法裏有一些處理,仍是換個方式,或者用FullScreen 字體

設置方法:跟暗黑模式同樣放到 push的時候或者根視圖控制器 self.modalPresentationStyle = UIModalPresentationFullScreen;

 

五、私有API被封禁(KVC限制),禁止訪問

一、獲取SearchBar的textField

因爲在13中把SearchBar中的textField直接暴露給開發者使用,無需在經過kvc獲取。

if ([[[UIDevice currentDevice]systemVersion] floatValue] >=     13.0) {

           searchField = _vSearchBar.searchTextField;

    }else{

       searchField = [self valueForKey:@"_searchField"];

    }

二、修改TextFiled的佔位符字體大小以及顏色,在iOS13中不能經過KVC來進行修改,能夠經過其屬性字符串來進行修改

     [_phone setValue:C6 forKeyPath:@"_placeholderLabel.textColor"];

 

UITextField *textfield = [[UITextField alloc]init];
NSMutableAttributedString *arrStr = [[NSMutableAttributedString alloc]initWithString:textfield.placeholder attributes:@{NSForegroundColorAttributeName : [UIColor redColor],NSFontAttributeName:[UIFont systemFontOfSize:12]}];
textfield.attributedPlaceholder = arrStr;

 

六、Sign in with Apple 第三方登陸

 這個2020年4月前處理了就好

想嘗試能夠參考https://www.jianshu.com/p/e1284bd8c72a

七、即將廢棄的 LaunchImage

從 iOS 8 的時候,蘋果就引入了 LaunchScreen,咱們能夠設置 LaunchScreen來做爲啓動頁。

固然,如今你還可使用LaunchImage來設置啓動圖。

不過使用LaunchImage的話,要求咱們必須提供各類屏幕尺寸的啓動圖,來適配各類設備,隨着蘋果設備尺寸愈來愈多,這種方式顯然不夠 Flexible。

而使用 LaunchScreen的話,狀況會變的很簡單, LaunchScreen是支持AutoLayout+SizeClass的,因此適配各類屏幕都不在話下。

⚠️從2020年4月開始,全部使⽤ iOS13 SDK的 App將必須提供 LaunchScreen,LaunchImage即將退出歷史舞臺。可使用Launch Storyboards來進行解決。

八、tabBarItem 選中狀態的顏色無效,顯示默認的藍色

之前只設置選中狀態的顏色是能夠的,如今能夠這樣設置

    [vc.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: MENU_ITEM_SELECTED_COLOR, NSForegroundColorAttributeName, nil] forState:UIControlStateSelected 
if (@available(iOS 13.0, *)) {
        self.tabBar.tintColor = MENU_ITEM_SELECTED_COLOR;

    } else {
        [vc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName: MENU_ITEM_SELECTED_COLOR} forState:UIControlStateSelected];
    }

 

PS: xcode11 其餘坑,我沒踩到

一、廢棄 UISearchDisplayController

在 iOS 8 以前,咱們在 UITableView 上添加搜索框須要使用 UISearchBar + UISearchDisplayController 的組合方式,而在 iOS 8 以後,蘋果就已經推出了 UISearchController 來代替這個組合方式。在 iOS 13 中,若是還繼續使用 UISearchDisplayController 會直接致使崩潰

二、增長一直使用藍牙的權限申請

CBCentralManager,iOS13之前,使用藍牙時能夠直接用,不會出現權限提示,iOS13後,再使用就會提示了。

在info.plist裏增長NSBluetoothAlwaysUsageDescription 咱們要一直使用您的藍牙,具體作什麼別問我

三、UISegmentedControl 默認樣式改變

默認樣式變爲白底黑字,若是設置修改過顏色的話,頁面須要修改

四、MPMoviePlayerController在iOS13中廢棄

MPMoviePlayerController is no longer available. Use AVPlayerViewController in AVKit.
在iOS13中對於MPMoviePlayerController使用的廢棄,須要使用AVKit中的AVPlayerViewController來達到播放的目的。

參考: http://www.javashuo.com/article/p-tmqfmnkb-cz.html

 

備註:

解決MAC系統升級(10.15)致使COCOAPODS失效問題

pod install 報錯       sudo gem update --system 也不行  
dunkhomedeMacBook-Pro:get dunkhome$ pod install
-bash: /usr/local/bin/pod: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory
dunkhomedeMacBook-Pro:get dunkhome$ sudo gem update --system
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)

竟然是404,因而我用瀏覽器打開https://gems.ruby-china.org,發現其服務域名更換了:

而後刪除gem源:

gem sources --remove https://gems.ruby-china.org/

修改gem源:

gem sources -a https://gems.ruby-china.com

查看gem源是不是最新的:

gem sources -l

升級cocoapods:

sudo gem install -n /usr/local/bin cocoapods --pre

查看升級後的cocoapods版本:

pod --version  

如今最新的是

MacBook-Pro:get dunkhome$ pod --version 

1.8.3

相關文章
相關標籤/搜索