iOS開發(fā)-問題總結(jié)

20190729.jpg

前言:工作中可能會(huì)遇到各種各樣的問題,有時(shí)解決完了再次遇到時(shí),如果沒有做筆記且相隔時(shí)間較長(zhǎng)時(shí),會(huì)容易忘記。故在此記錄工作中遇到的一些比較不常見的問題,將持續(xù)更新...

1、Xcode運(yùn)行報(bào)錯(cuò): App installation failed This application’s application-identifier entitlement does not match that of the installed application. These values must match for an upgrade to be allowed. 如下圖:

AppInstallationFailed.jpeg

原因分析
application-identifier沖突。(我出現(xiàn)該問題情況是由于APP轉(zhuǎn)讓之后使用新開發(fā)者賬號(hào)真機(jī)測(cè)試,真機(jī)上還裝有原賬號(hào)安裝的包)

解決方法
將手機(jī)上的相應(yīng)軟件刪除卸載就OK了。

2、Xcode打包上傳iTunes完成后報(bào)警告:
WARNING ITMS-90076: "Potential Loss of Keychain Access. The previous version of software has an application-identifier value of ['BAGPUY4P4E.com.zxww.folk'] and the new version of software being submitted has an application-identifier of ['SH2X52JLPW.com.zxww.folk']. This will result in a loss of keychain access."

原因分析
該APP是從一個(gè)開發(fā)者賬號(hào)轉(zhuǎn)讓到新的開發(fā)者賬號(hào),使用新開發(fā)者賬號(hào)上傳時(shí)報(bào)的警告。該警告意思是會(huì)影響到keychain里存的信息。

解決方法
如果keychain里邊的信息無所謂的話,該警告可以無視,不影響上傳及審核,下次上傳不會(huì)再提示。
如果keychain里邊的信息有用的話,解決辦法是:百度一下。

3、UIButtonUIControlEventTouchDown點(diǎn)擊延遲原因及解決
(1)button添加到UIScrollView
解決:設(shè)置UIScrollViewdelaysContentTouchescanCancelContentTouchesNo
(2)與導(dǎo)航欄右滑返回手勢(shì)沖突
解決:設(shè)置
self.navigationController.interactivePopGestureRecognizer.delaysTouchesBegan = NO;
(3)項(xiàng)目中含有UIButton的分類中實(shí)現(xiàn)了防止重復(fù)點(diǎn)擊的相關(guān)內(nèi)容
解決:在需要用到UIControlEventTouchDown的類中重寫防止重復(fù)點(diǎn)擊的相關(guān)方法,去除防止重復(fù)點(diǎn)擊相關(guān)代碼
(4)與window手勢(shì)沖突
解決:在button所在UIViewController中重寫viewDidAppear如下

- (void)viewDidAppear:(BOOL)animated {
    
    [super viewDidAppear:animated];
    for (UIGestureRecognizer * gesture in self.view.window.gestureRecognizers) {
        
        gesture.delaysTouchesBegan = NO;
    }
}

4、UIView- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event不響應(yīng)
原因分析
UIView的父視圖添加的有UITapGestureRecognizer手勢(shì)
解決方法
父視圖中的UITapGestureRecognizer手勢(shì)設(shè)置代理并實(shí)現(xiàn)如下代理方法

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
    
    if ([touch.view isKindOfClass:[CustomView class]]) {
        
        return NO;
    }
    return YES;
}

CustomView為自定制的需要獲取- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event事件的view。

5、升級(jí)cocoapods報(bào)錯(cuò)如下:

ERROR:  Could not find a valid gem 'cocoapods' (>= 0), here is why:
          Unable to download data from https://gems.ruby-china.org/ - bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)

原因分析
.org域名無法提供RubyGems服務(wù),即.org域名無效,需替換成.com域名。
解決方法
(1)查看當(dāng)前源

$ gem source -l
*** CURRENT SOURCES ***

https://gems.ruby-china.org/

(2)刪除當(dāng)前源

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

(3)添加源

$ gem sources --add https://gems.ruby-china.com/
https://gems.ruby-china.com/ added to sources

接下來使用sudo gem install cocoapods繼續(xù)升級(jí)cocoapods即可

6、使用sudo gem install cocoapods升級(jí)cocoapods報(bào)錯(cuò)如下:

$ sudo gem install cocoapods
Password:
Fetching: httpclient-2.8.3.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/bin directory.

原因分析
沒有用戶權(quán)限所致
解決方法
使用sudo gem install -n /usr/local/bin cocoapods升級(jí)即可。

7、如何檢測(cè)項(xiàng)目中的廣告標(biāo)識(shí)符(IDFA)
1)打開終端cd到需要檢測(cè)的項(xiàng)目路徑下
2)輸入$ grep -r advertisingIdentifier .
3)結(jié)果中會(huì)顯示項(xiàng)目中哪個(gè)庫使用了廣告標(biāo)識(shí)符(DIFA)
eg:

Binary file ./Pods/mob_sharesdk/SDK/ShareSDK/Support/PlatformSDK/SinaWeiboSDK/libWeiboSDK.a matches
Binary file ./Pods/BMKLocationKit/framework/BMKLocationKit.framework/BMKLocationKit matches

如果沒有檢測(cè)到則什么都不會(huì)輸出。

8、友盟分享報(bào)錯(cuò)“2003”
原因分析
對(duì)于該報(bào)錯(cuò)原因,友盟只給出了新浪微博如果報(bào)該錯(cuò)誤是可能因?yàn)轭l繁操作所致。那么分享到其他平臺(tái)的時(shí)候也報(bào)了該錯(cuò)誤,查看友盟錯(cuò)誤碼UMSocialPlatformErrorType只給出了解釋是分享失敗,但并沒有解釋什么原因?qū)е碌摹?br> 首先保證所有配置沒有問題,在調(diào)用分享操作- (void)shareToPlatform:(UMSocialPlatformType)platformType messageObject:(UMSocialMessageObject *)messageObject currentViewController:(id)currentViewController completion:(UMSocialRequestCompletionHandler)completion;時(shí)查看currentViewController是否是self,如果當(dāng)前步驟代碼是在UIViewController里邊調(diào)用的,那么不會(huì)有問題;但是我們經(jīng)常會(huì)把分享的操作進(jìn)行封裝以便于復(fù)用,所以如果是封裝在NSObject類中,那么這里寫self就會(huì)報(bào)錯(cuò)“2003”。
解決方法
在調(diào)用分享操作- (void)shareToPlatform:(UMSocialPlatformType)platformType messageObject:(UMSocialMessageObject *)messageObject currentViewController:(id)currentViewController completion:(UMSocialRequestCompletionHandler)completion;時(shí)currentViewControllernil即可。

9、Xcode打開項(xiàng)目一直loading,顯示Xcode-未響應(yīng),或者編譯時(shí)顯示Xcode-未響應(yīng),嘗試了刪除Xcode之后重新安裝,依然存在該問題
原因分析
可能是保存Xcode時(shí)出錯(cuò)強(qiáng)制退出程序,致使之后每次打開Xcode都會(huì)加載這個(gè)錯(cuò)誤工程導(dǎo)致Xcode未響應(yīng)。
解決方法
退出Xcode,打開終端執(zhí)行以下命令

cd ~/Library/Autosave\ Information/
rm -rf Unsaved\ Xcode*

運(yùn)行結(jié)束重新打開工程即可

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容