平時遇到的錯誤我都會收集起來與大家分享,慢慢積攢中。。。
一.
問題:
You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. Note: This will be an error in the future.
原因:
有第三方庫不兼容
解決:
二.
問題:
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure.
原因:
新特性要求App內訪問網絡請求,要采用 HTTPS 協議。
但是現在使用的是 HTTP 協議,使用私有加密方式保證數據安全。
解決:
三.
問題:
原因:
需要驗證應用程序證書是值得信賴的
解決:
設置->通用->描述文件->開發商應用->信任xxxxx
四.
問題.
打包上傳時出錯
ERROR ITMS-90535: "Unexpected CFBundleExecutable Key. The bundle at 'Payload/OnlineGuardPatrol.app/TencentOpenApi_IOS_Bundle.bundle' does not contain a bundle executable. If this bundle intentionally does not contain an executable, consider removing the CFBundleExecutable key from its Info.plist and using a CFBundlePackageType of BNDL. If this bundle is part of a third-party framework, consider contacting the developer of the framework for an update to address this issue."
原因:
第三方的framework中不包含executable
解決:
找到第三方庫的info.plist文件,刪除箭頭指向的一整行
五.
問題.
打包上傳時出錯
ERROR ITMS-90207: "Invalid Bundle. The bundle at 'OnlineGuardPatrol.app' does not contain a bundle executable."
原因.
結合第四條,由于錯誤的刪除了自己的info.plist文件中的對應行
解決:
重新添加對應行的鍵和值
六.
問題.
打包上傳時的錯誤
原因.
同時在xcode8和xcode7中編碼,并且用xcode7打包上傳
解決.
如下圖
七.
問題.
運行報錯:
原因.
第三方庫不包含bitcode
解決.
在Xcode 7中,我們新建一個iOS程序時,bitcode選項默認是設置為YES的。我們可以在”Build Settings”->”Enable Bitcode”選項中看到這個設置
將Enable Bitcode默認的YES 選項改成NO 就行了
八.
問題.
編譯報錯:
duplicate symbol OBJC_METACLASS$_GTMBase64,duplicatesymbol
原因.
引用庫重復定義
解決.
刪掉 set building->other linker flag-> -all_load,就可以了
九.
錯誤.
duplicate symbols for architecture armv7
原因.
1.有名字重復的文件
2.在#import頭文件的時候,不小心把.h寫成了.m
解決.
找到,改過來就行了
十.
錯誤.
This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes
原因.
在其他線程中更新UI引起
解決.
在dispatch_async(dispatch_get_main_queue(), ^{});
中更新UI
十一.
錯誤.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 255
原因.
不太曉得,我是在xcode8上寫了點代碼,又在xcode7上編譯,就報錯了
解決.
clean項目,完全退出Xcode,再打開就好了
十二.
錯誤.
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFArray insertObject:atIndex:]: mutating method sent to immutable object'
原因.
這個錯誤前半句基本沒用,種類多樣,通過后半句我找到相應的地方,是因為我向數組中添加相同的數據導致
解決.
看著辦就行
十三.
錯誤.
The dependency
****
is not used in any concrete target.
原因.
由于沒有指定target,所以pods不知道把這些第三方用在哪里
解決.
按照這種格式書寫:
platform :ios, '8.0'
#use_frameworks!個別需要用到它,比如reactiveCocoa
target 'MyApp' do
pod 'AFNetworking', '~> 2.6'
pod 'ORStackView', '~> 3.0'
pod 'SwiftyJSON', '~> 2.3'
end
十四.
錯誤.
[!] Invalid
Podfile
file: syntax error, unexpected end-of-input, expecting keyword_end.
原因.
Podfile文件結尾沒有加end
解決.
加end唄。。。。。
十五.
錯誤.
/usr/bin/git clone https://github.com/github/Mantle.git /var/folders/bq/h6x44ktn7ysgjl0t9gp645f40000gp/T/d20161224-3583-mr03ke --template= --single-branch --depth 1 --branch 2.0.7
原因.
系統中含有不止一個xcode
解決.
執行 sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer (-switch 后面加上你的Xcode.app包內容里的Developer的文件夾路徑即可)
十六.
錯誤.
原因.
本地Podfile文件上的第三方版本太低
解決.
執行命令pod update
十七.
錯誤.
[__NSCFString objectForKeyedSubscript:]: unrecognized selector sent to instance 0x140534950
原因.
我在后臺取出來數據,解析成字典之后取字典中的數據出現的,由于后臺的疏忽,這并不是一個字典而是一個字符串,如圖:
紅框代表數據是一個字符串,需要再次解析才可以使用
解決
再次解析,或者要求后臺修改數據格式
十八.
錯誤.
Invalid type in JSON write (NSConcreteMutableData)
原因.
我在上傳數據的json體中直接放入了數組,數組中有不符合json規則的數據,如:自定義的類
解決.
NSData *data=[NSJSONSerialization dataWithJSONObject:muArray options:NSJSONWritingPrettyPrinted
error:nil];
NSString *strs=[[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
此時將strs放入,完美。
十九.
錯誤.
attempt to insert non-property list object
原因.
我用NSUserDefaults儲存了一個字典,字典中含有"<null>"
解決.
將"<null>"改成""
二十.
問題.
真機調試不打印日志
原因.
真機的系統是iOS10以上
解決.
取消圖中的選中。雖然在iOS10以上正常了,但是在iOS10以下會打印一些無效的東西,求解決!!!
二十一.
錯誤.
ARC forbids Objective-C object in struct
原因.
ARC工程中用到非ARC庫,其中有頭文件定義struct中使用Object* o1,類似的對象指針。
解決.
在前面加上__unsafe_unretained
二十二.
錯誤.
ERROR ITMS-90542: "Invalid CFBundleSupportedPlatforms value. The key 'CFBundleSupportedPlatforms' in the Info.plist file in bundle 'Payload/PgapIos.app/GoogleMaps.bundle' contains an invalid value '( "iPhoneSimulator" )'.
原因.
編譯bundle的時候,是用模擬器來編譯的
解決.
在編譯bundle的時候選擇真機
二十三.
錯誤
ERROR ITMS-90683: "Missing Info.plist key. This app attempts to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSHealthShareUsageDescription key with a string value explaining to the user how the app uses this data."
原因.
缺少健康權限請求信息,我只請求了寫的權限,沒有讀的權限
解決.
// 寫
<key>NSHealthUpdateUsageDescription</key>
<string>some string value stating the reason</string>
// 讀
<key>NSHealthShareUsageDescription</key>
<string>some string value stating the reason</string>
二十四.
錯誤.
ld: library not found for -lPods-AFNetworking
原因.
不明
解決.
設置 Project
-> Pods
下所有第三方庫的 Build Active Architecture Only
為 NO
二十五.
錯誤.
終端執行pod install的時候
[!] Unable to add a source with url
https://github.com/CocoaPods/Specs.git
namedmaster
.
You can try adding it manually in~/.cocoapods/repos
or viapod repo add
.
原因.
不明
解決.
執行
pod repo add master https://github.com/CocoaPods/Specs.git
然后根據提示執行pod setup
,
如果出現[!] The `master` repo is not a git repo.
進入/users/你的用戶名/.cocoapods/repos,刪除master文件夾
然后繼續執行pod setup
如果安裝了多個xcode,出現錯誤,上面第十五條有解決方案。
二十六.
錯誤.
as an NSUserDefaults/CFPreferences value for key sadminLOCATION_POINT_DIC
原因.
向NSUserDefaults中存數據時,值為空或者不符合規則
解決.
。。。。
二十七.
錯誤
Error Domain=NSCocoaErrorDomain Code=3840
原因
解析json數據時出現無法解析的特殊符號
解決
找到AFNetworking包中AFURLResponseSerialization.m文件,大概在第250行左右添加如下過濾方法:
BOOL isSpace = [data isEqualToData:[NSData dataWithBytes:" " length:1]];
if (data.length > 0 && !isSpace) {
NSString* sInvalid = [NSString stringWithUTF8String:[data bytes]];
// 從服務器收到的類似上一行的數據
NSData *dataa = [[sInvalid stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\\r\\n"] dataUsingEncoding:NSUTF8StringEncoding];
responseObject = [NSJSONSerialization JSONObjectWithData:dataa options:self.readingOptions error:&serializationError];
} else {
return nil;
}
二十八.
錯誤
The default interactive shell is now zsh.
To update your account to use zsh, please run chsh -s /bin/zsh.
原因
升級mac導致
解決
chsh -s /bin/zsh
二十九.
錯誤
zsh: /usr/local/bin/pod: bad interpreter: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: no such file or directory
原因
升級mac導致
解決
升級pods
sudo gem update --system
sudo gem install cocoapods -n/usr/local/bin
三十.
錯誤
[!] CDN: trunk Repo update failed - 17 error(s):
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/1/d/4/CocoaAsyncSocket/0.0.1/CocoaAsyncSocket.podspec.json, error: Operation timed out - SSL_connect
...
解決
source 'https://github.com/CocoaPods/Specs.git'
####持續更新