前言:工作中可能會(huì)遇到各種各樣的問(wèn)題讼呢,有時(shí)解決完了再次遇到時(shí)帽馋,如果沒(méi)有做筆記且相隔時(shí)間較長(zhǎng)時(shí)棠涮,會(huì)容易忘記谬哀。故在此記錄工作中遇到的一些比較不常見(jiàn)的問(wèn)題,將持續(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.
如下圖:
原因分析
application-identifier
沖突史煎。(我出現(xiàn)該問(wèn)題情況是由于APP轉(zhuǎn)讓之后使用新開(kāi)發(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è)開(kāi)發(fā)者賬號(hào)轉(zhuǎn)讓到新的開(kāi)發(fā)者賬號(hào),使用新開(kāi)發(fā)者賬號(hào)上傳時(shí)報(bào)的警告酝枢。該警告意思是會(huì)影響到keychain里存的信息恬偷。
解決方法
如果keychain里邊的信息無(wú)所謂的話,該警告可以無(wú)視隧枫,不影響上傳及審核喉磁,下次上傳不會(huì)再提示。
如果keychain里邊的信息有用的話官脓,解決辦法是:百度一下协怒。
3、UIButton
的UIControlEventTouchDown
點(diǎn)擊延遲原因及解決
(1)button添加到UIScrollView
上
解決:設(shè)置UIScrollView
的delaysContentTouches
和canCancelContentTouches
為No
(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
域名無(wú)法提供RubyGems
服務(wù)妖滔,即.org
域名無(wú)效,需替換成.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
接下來(lái)使用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.
原因分析
沒(méi)有用戶權(quán)限所致
解決方法
使用sudo gem install -n /usr/local/bin cocoapods
升級(jí)即可。
7陨帆、如何檢測(cè)項(xiàng)目中的廣告標(biāo)識(shí)符(IDFA)
1)打開(kāi)終端cd到需要檢測(cè)的項(xiàng)目路徑下
2)輸入$ grep -r advertisingIdentifier .
3)結(jié)果中會(huì)顯示項(xiàng)目中哪個(gè)庫(kù)使用了廣告標(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
如果沒(méi)有檢測(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
只給出了解釋是分享失敗纲爸,但并沒(méi)有解釋什么原因?qū)е碌摹?br>
首先保證所有配置沒(méi)有問(wèn)題亥鸠,在調(diào)用分享操作- (void)shareToPlatform:(UMSocialPlatformType)platformType messageObject:(UMSocialMessageObject *)messageObject currentViewController:(id)currentViewController completion:(UMSocialRequestCompletionHandler)completion;
時(shí)查看currentViewController
是否是self
,如果當(dāng)前步驟代碼是在UIViewController
里邊調(diào)用的识啦,那么不會(huì)有問(wèn)題负蚊;但是我們經(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í)currentViewController
傳nil
即可灾螃。
9、Xcode打開(kāi)項(xiàng)目一直loading揩徊,顯示Xcode-未響應(yīng),或者編譯時(shí)顯示Xcode-未響應(yīng)嵌赠,嘗試了刪除Xcode之后重新安裝塑荒,依然存在該問(wèn)題
原因分析
可能是保存Xcode時(shí)出錯(cuò)強(qiáng)制退出程序,致使之后每次打開(kāi)Xcode都會(huì)加載這個(gè)錯(cuò)誤工程導(dǎo)致Xcode未響應(yīng)姜挺。
解決方法
退出Xcode齿税,打開(kāi)終端執(zhí)行以下命令
cd ~/Library/Autosave\ Information/
rm -rf Unsaved\ Xcode*
運(yùn)行結(jié)束重新打開(kāi)工程即可