Xcode11.1 踩坑備忘錄


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

1 、環信ChatDemo2.0報錯

這是環信ChatDemo2.0報錯

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

改為

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

 

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

全局配置 在工程的Info.plist的中,增加/修改 UIUserInterfaceStyle為UIUserInterfaceStyleLight或UIUserInterfaceStyleDark

 

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

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

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

 

4、present到登錄頁面時,發現新頁面不能頂到頂部

原因是iOS 13 多了一個新的枚舉類型 UIModalPresentationAutomatic,並且是modalPresentationStyle的默認值。

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

但是需要注意一點PageSheet 與 FullScreen 生命周期並不相同 FullScreen會走完整的生命周期

,PageSheet因為父視圖並沒有完全消失,所以viewWillDisappear及viewWillAppear並不會走,

如果這些方法里有一些處理,還是換個方式,或者用FullScreen

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

 

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

1、獲取SearchBar的textField

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

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

           searchField = _vSearchBar.searchTextField;

    }else{

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

    }

2、修改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;

 

6、Sign in with Apple 第三方登錄

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

想嘗試可以參考https://www.jianshu.com/p/e1284bd8c72a

7、即將廢棄的 LaunchImage

從 iOS 8 的時候,蘋果就引入了 LaunchScreen,我們可以設置 LaunchScreen來作為啟動頁。

當然,現在你還可以使用LaunchImage來設置啟動圖。

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

而使用 LaunchScreen的話,情況會變的很簡單, LaunchScreen是支持AutoLayout+SizeClass的,所以適配各種屏幕都不在話下。

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

8、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 其他坑,我沒踩到

1、廢棄 UISearchDisplayController

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

2、增加一直使用藍牙的權限申請

CBCentralManager,iOS13以前,使用藍牙時可以直接用,不會出現權限提示,iOS13后,再使用就會提示了。

在info.plist里增加NSBluetoothAlwaysUsageDescription 我們要一直使用您的藍牙,具體做什么別問我

3、UISegmentedControl 默認樣式改變

默認樣式變為白底黑字,如果設置修改過顏色的話,頁面需要修改

4、MPMoviePlayerController在iOS13中廢棄

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

參考: https://www.cnblogs.com/vlucht/p/11576294.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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM