ios 常見問題解決

ios 常見問題解決

一,libxml/HTMLparser.h file not find

第一種方法:

點擊左邊項目的根目錄,再點擊右邊的Build Settings,手工輸入文字:“Header search paths”,然后單擊(或雙擊,點擊彈出面板下面的“+”號進行添加)“Header search paths ”右邊的空白處,輸入:/usr/include/libxml2

第二種方法:

點擊左邊項目的根目錄,再點擊右邊的Build Settings,手工輸入文字:“Header search paths”,然后單擊(或雙擊,點擊彈出面板下面的“+”號進行添加)“ Header search paths ”右邊的空白處,輸入:${SDK_DIR}/usr/include/libxml2

二,總是找不到協(xié)議:

第一種方法:沒有引入該協(xié)議,引入該協(xié)議

第二種方法:重復(fù)引入該協(xié)議,重復(fù)引入的地方刪除

三,啟動畫面不顯示

1>,圖片大小尺寸必須符合規(guī)定,把所有的圖片導(dǎo)入工程中

2>,進入工程Images.xcassets文件夾,把圖片拖入對應(yīng)的AppIcon,LaungchImage

四,ld: library not found for -lcrypto

clang: error: linker command failed with exit code 1 (use -v to see invocation)

第一種方法:庫crypto沒有添加進Link Binary With Libraries,添加進去就OK了

第二種方法:庫crypto已經(jīng)添加進Link Binary With Libraries,把crypto刪除再重新添加進去就OK了

五,Unsupported compiler 'com.apple.compilers.llvmgcc42' selected for architecture 'armv7'? Xcode 5

Change your compiler for C/C++/ObjectiveC Go to Build Settings->Build OPtions->compiler for C/C++/ObjectiveC; select Default(Apple LLVM5.0)

六,關(guān)于ld: file is universal (2 slices) but does not contain a(n) armv7s slice

升級了xcode之后,支持iOS6和iPhone5,不過Build項目的時候,出現(xiàn)了標題所示錯誤提示信息。

原因是引用的第三方庫導(dǎo)致了這個鏈接錯誤。

解決辦法有三個,隨便哪種都能解決:

1.升級涉及到的.a文件

2.在target的Build Settings里面,將Build Active Architecture Only改成YES?? (I choose this)

3.在target的Build Settings里面,找到Valid Architectures,刪除其中的armv7s

所以還是覺得,如果是開源庫,直接把源代碼包含進項目比較靠譜。

七,使用第三方插件時,出現(xiàn)contentoffset下移20像素的情況:

解決方案:在使用第三方控件的viewcontroller的viewDidLoad方法中添加下面的代碼即可

if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {

[self setEdgesForExtendedLayout:UIRectEdgeNone];

}

八,提交app的時候會有no indentities were available for signing 提示

1.在Xcode的Organizer 中可以看到你上傳項目的Indetifier

2,在Provisioning中可以建立的文件和Indetifier保持一致

3,下載你所建立的Provisioning文件,然后雙擊

4,再在Organizer中上傳文件就可以了

5,如果在代碼中作了修改,需要重新打包再上傳,上傳的才會是最新的代碼

九,no matching provisioning profiles found

1,到Build Settings里面重新選擇進入code signing

2,重新選擇profiles

十. mutating method sent to immutable object'

從字面上理解:可變的消息發(fā)給了不可變的對象。比如NSDictionary類型的對象調(diào)用setValue方法.應(yīng)該把NSDictionary 改成NSMutableDictionary類型。

十一.Local declaration of 'content' hides instance variable

一般是函數(shù)里面定義的變量和class屬性變量重名了。很少有和系統(tǒng)變量重名的情況

十二.unrecognized selector sent to instance

大部分情況下是因為對象被提前release了,在不希望他release的情況下,指針還在,對象已經(jīng)不在了

很多時候,是因為init初始化函數(shù)中,對屬性賦值沒有使用self.foo賦值,而是直接對foo賦值,導(dǎo)致屬性對象沒有retain(心里以為retain了),而提前釋放。

十三.使用ASIHTTPRequest編譯不通過

原因是一些類庫沒有加進去。把這些庫加進去CFNetwork, SystemConfiguration, MobileCoreServices, and libz.dylib

十四.添加在UIView中的UIButton?? 單擊不起作用

原因是UIbutton的frame超出了UIView的frame范圍。事實上UIView并沒有設(shè)置frame,設(shè)置完后( 范圍一定要在UIButton之外),UIButton單擊就可以了

十五.當使用presentViewController和dismissPresentViewController時,如果報這個錯 : while? presentation is in progress

修改方法為[mainView dismissModalViewControllerAnimated:NO];? 將參數(shù)Animated改為NO;如果報這個錯while a presentation or dismiss is in progress,試試這樣

if (![[mainView modalViewController] isBeingDismissed]) {

[mainView dismissModalViewControllerAnimated:NO];

}

十六.調(diào)用系統(tǒng)相冊的時候,非常容易出現(xiàn)內(nèi)存警告,加入綠色代碼就會好點

UIImagePickerController * picker = [[UIImagePickerController alloc]init];

picker.delegate = self;

picker.allowsEditing = NO;? //是否可編輯

picker.videoQuality=UIImagePickerControllerQualityTypeLow;

//攝像頭

picker.sourceType = UIImagePickerControllerSourceTypeCamera;

[self presentModalViewController:picker animated:YES];

[picker release];

十七.ios開發(fā)者都遇見過得錯誤:EXC_BAD_ACCESS 。這個和第二個比較類似。通常的調(diào)試方法就是加入NSZombieEnabled變量,加入方法自行百度。

并且開發(fā)過程中使用[[NSNotificationCenterdefaultCenter]

來發(fā)布本地消息,這個也經(jīng)常會出現(xiàn)EXC_BAD_ACCESS錯誤。這個時候只需要在你的view活著viewControllers的dealloc的方法里面加入

[[NSNotificationCenterdefaultCenter]removeObserver:selfname:@"yourNotification"object:nil];就ok了

十八.遇見一個蛋疼的問題"linker command failed with exit code 1 (use -v to see invocation)" 。

翻遍了找不到原因。然后還有這樣的警告duplicate symbol _OBJC_CLASS 。原來是在導(dǎo)入某個類的時候?qū)?m文件,而不是.h文件

十九:clang failed with exit code 254

檢測代碼中 是否 有 NSLog 打印了 返回 void 的值.

二十:Verify exit code of build task with internal identifier 'CopyPNGFile 123.png'

一:將出錯的png,用PhotoShZ喎?"http://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vcNbY0MLXqru70ru0ziwgIMjnuftQaG90b1Nob3C08rK7v6osuMS689e6zqpKcGcgytTK1C4g16q7u8qxLMfryrnTwyA6PHN0cm9uZz605rSizqpXZWK78snosbjL+cq508O1xCYjMjY2ODQ7yr08L3N0cm9uZz4mIzI2Njg0O8q916q7u7PJPHN0cm9uZz4gUE5HLTI0PC9zdHJvbmc+1eLR+bXEzbzGrLTz0KGxyL3Pus/KyjwvcD4KPHA+Cjxicj4KPC9wPgo8cD4KPHN0cm9uZz4zOjwvc3Ryb25nPjwvcD4KPHA+CjxpbWcgc3JjPQ=="http://www.2cto.com/uploadfile/2014/0509/20140509112551421.png" alt="\">

一:確定靜態(tài)庫中是否有自定義的類文件,如果一個也沒有,就會出現(xiàn)這種錯誤,這也是為什么新建的靜態(tài)庫都包含一個默認的類.

二十一: _OBJC_CLASS_$_UIMainKpiXML", referenced from:

1:檢測類文件是否已經(jīng)指定了Project Target

2:檢測類文件是否在Bulid Phases中的Compile Source是否包含了這個類文件

以上兩步都檢查完成以后,如果編譯還報錯誤,請嘗試徹底關(guān)閉XCode 再次編譯試試.

二十二: for architecture armv7s

以下摘自: http://stackoverflow.com/questions/12570116/what-is-the-difference-between-arm7-and-arm7s

Yes you are right about armv7s is about the iPhone 5. Here some summary info I found on the web:

ARMv6 ISA (used by the ARM11 core in the iPhone 2G and iPhone 3G)

ARMv7 (used by modern ARM cores, iPhone 3GS, iPhone 4 and 4S)

ARMv7s (new A6 SoC for iPhone 5).

注:錯誤含義表示 指定的framework 不支持對 armv7s 的支持, 也就不支持搭載A6處理器的iPhone 5.

如果在編譯framework或者靜態(tài)庫的工程中依舊編譯時,可能是以下設(shè)置導(dǎo)致,設(shè)置為NO即可

二十三: Local declaration of "' hides instance variable

私有變量與屬性變量同名所致

二十四:Instance variable '' accessed in class method

1:在靜態(tài)方法不能使用到類的屬性變量,否則就報上面的錯誤

二十五:ld: symbol(s) not found for architecture i386

1:里面意思說:"_stroyboard" 這個屬性在目標類中 根本就沒聲明!

那就聲明一下咯? 注:XCode4.5 會默認聲明了,但是只是針對自定義類,系統(tǒng)類還沒有. 所以,小心

@synthesize storyboard;

二十六:PerformSelector may cause a leak because its selector is unknow

通過如下代碼解決產(chǎn)生的編譯器警告

#pragma clang diagnostic push

#pragma clang diagnostic ignored "-Warc-performSelector-leaks"

[self performSelector:nextView];

#pragma clang diagnostic pop

來源:(http://www.ooso.net/archives/620)

二十七:unable to open executable

1:檢測同一個靜態(tài)庫或工程中是否有兩個或以上的想同類文件存在

2:刪除模擬器中的應(yīng)用,刪除DerivedData文件夾 重新啟動XCode.

二十八: Property's synthesized getter follows Cocoa naming convention for returning 'owned' objects

不要在頭文件聲明變量命名是以new copy開頭

參考:http://kongbei888.blog.163.com/blog/static/24326613201261902510652/

二十九:ld: file not found:

1:指向的靜態(tài)庫沒有找到

三十: _utf8_countTrailBytes

add library libicucore.dylib

三十一:Stray "@" in program

工程使用的編譯器版本過低所致. 修改編譯器版本至最新版本,如下圖:

參考:http://stackoverflow.com/questions/12821938/stray-in-program-with-nsdictionary-definition

三十二.解決真機調(diào)試iPad Air設(shè)備時的錯誤:architecture not supported的辦法

1.將Build Settings 中Architectures ——> Valid Architectures的arm64刪掉,只留armv7、armv7s

2.同上,將Architectures ——>Architectures改為 $(ARHS_STANDARD)armv7,armv7s

3.把Build ActiveArchitectureOnly 改為NO

4.編譯即可

三十三.編譯時出現(xiàn):Not supported ARMarchitecture

解決辦法:在./configure 時加入 -D__ARM_ARCH_5TEJ__

三十四.Couldn"t register xxx.xx.xx with the bootstrap server. Error: unknown error code.

This generally means that another instance of this process was already running or is hung in the debugger.

每個在xcode下用ios模擬器做開發(fā)的開發(fā)者都應(yīng)該會遇到過上面所示的錯誤,目前找到最行之有效的解決辦法是重啟手機。不行了也順便把電腦重啟下。 建議以后記得stop就行了 不要正運行著就直接卸載了程序

三十五.duplicate symbol _protobuf_c buffer_simple_append in ...錯誤解決

選中工程,target,切換到buildsetting標簽,定位到other link flag,

輸入: 去除-all_load,即可

三十六.ld: symbol dyld_stub_binding_helper not found, normally in crt1.o/dylib1.o/bundle1.o for architectur

錯誤:ld: symbol dyld_stub_binding_helper not found, normally in crt1.o/dylib1.o/bundle1.o for architecture i386

原因:不支持低版本的系統(tǒng)如3.0

解決:Deployment Target was 3.0. Changing it to 4.3 fixed it.

三十七.當一個tableViewCell被選中的時候,改變一個button的title,這個button有背景圖片,改變title不成功

把該button的selected設(shè)為NO

三十八.CUICatalog: Invalid asset name supplied: , or invalid scale factor: 2.000000

這個提示的意思是說你用了這個方法

[UIImageimageNamed:name];但是這個name卻是空的,所以就報了這個錯了。

解決方法,在項目中搜索[UIImageimageNamed:,然后打印看看所謂的name是否為空。找到后替換。

三十九.XCode開發(fā)遇到的“Could not inspect the application package”解決方案

出現(xiàn)這種情況的原因是:項目里含有 Resources 文件夾。解決方案:

1>在項目里把這個 Resources 文件夾 改為別的名字(不要在項目里改文件夾的名字,這是偽改,要進入工程文件夾再改 Resources 名字),再重新引入這個文件夾

2>按住 option 鍵 ,點擊 Xcode 的product 菜單,選中 Clean Build Folder ,然后確定 clean 就OK了

四十.Xcode?has?encountered?an?unexpected?error?(0xC002)

Xcode has encountered an unexpected error (0xC002)

No such file or directory, at ‘/SourceCache/DTDeviceKit/DTDeviceKit-867/DTDeviceKit/DTDeviceKit_Utilities.m:864’解決方法

cd ~/Library/Developer/Xcode/iOS\ DeviceSupport/4.2.1\ \(8C148\)/Symbols/System/Library/Caches/com.apple.dyld/

touch .copied_dyld_shared_cache_armv6

touch .processed_dyld_shared_cache_armv6

touch dyld_shared_cache_armv6

有些可能是

touch .copied_dyld_shared_cache_armv6

touch .processed_dyld_shared_cache_armv6

touch dyld_shared_cache_armv6

四十一.An error was encountered while running(Domain=LaunchSerivcesError, Code=0)

解決方案:重置模擬器

四十二.Undefined symbols for architecture i386:

"_NSFileTypeForHFSTypeCode", referenced from:

-[FMDatabase(FMDatabaseAdditions) applicationIDString] in FMDatabaseAdditions.o

"_NSHFSTypeCodeFromFileType", referenced from:

-[FMDatabase(FMDatabaseAdditions) setApplicationIDString:] in FMDatabaseAdditions.o

ld: symbol(s) not found for architecture i386

clang: error: linker command failed with exit code 1 (use -v to see invocation)

解決辦法:把FMDatabase文件刪除了,再重新導(dǎo)入所有的文件

四十三.fatal error: malformed or corrupted AST file: 'Unable to load module "/Users/xxx/Library/Developer/Xcode/DerivedData/ModuleCache/XYZYIE6ZV0OP/Darwin.pcm": file not found' note: after modifying system headers, please delete the module cache at '/Users/me/Library/Developer/Xcode/DerivedData/ModuleCache/XYZYIE6ZV0OP' 1 error generated.

解決辦法:

只需要清除繼承數(shù)據(jù)文件夾即可。具體操作為:進入XCode的Window,選擇Organizer->Projects,然后選擇出現(xiàn)問題的 project ,點擊delete button刪除Derived data.

重新編譯項目,即可。

四十四.Command /usr/bin/codesign failed with exit code 1

進入xcode 的偏好設(shè)置 -》Account如下圖

點擊第二張圖右下角的刷新按鈕,重新編譯打包,就OK了

四十四.the ipa is invalid.it does not include a payload directory

需要在info-plist 文件中 添加或者修改 LSRequiresIPhoneOS value 為 YES

四十四.iOS9 beta 請求出現(xiàn)App Transport Security has blocked a cleartext HTTP (http://)

錯誤描述:

App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via yourapp‘s Info.plist file.

在iOS9beta中,蘋果將原h(huán)ttp協(xié)議改成了https協(xié)議,使用 TLS1.2 SSL加密請求數(shù)據(jù)。

解決方法:

在info.plist 加入key

NSAppTransportSecurity

NSAllowsArbitraryLoads

四十五.Could not find Developer Disk Image

真機系統(tǒng)太高,Xcode支持不到這個系統(tǒng),要有這個系統(tǒng)版本的鏡像文件 ,/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport ,會列出支持的設(shè)備,然后在網(wǎng)上下載對應(yīng)的文件

四十六.UICollectionView 會在APP再次打開時下沉64像素

方案一:在Storyboard中取消勾選Controller的Adjust Scroll View Insets。或者

1

self.automaticallyAdjustsScrollViewInsets = NO;

方案二:

self.edgesForExtendedLayout = UIRectEdgeNone;

四十六.dyld: Library not loaded: @rpath/libswiftAVFoundation.dylib

Referenced from: /var/mobile/Containers/Bundle/Application/AC4B5FD7-43B3-4743-9682-60A026C5CAE2/NewFoodiPad.app/NewFoodiPad

rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"

rm -rf ~/Library/Developer/Xcode/DerivedData

rm -rf ~/Library/Caches/com.apple.dt.Xcode

四十七.swift項目 ios8系統(tǒng) SVProgressHud crash在?self.hudView.motionEffects = @[];

self.hudView.motionEffects = [NSArray array];

四十八.swift項目 ios8dyld: Symbolnot found: ___NSArray0__

1

2

3

4dyld: Symbol not found: ___NSArray0__

Referencedfrom: /private/var/mobile/Containers/Bundle/Application/5C6F5D69-5D14-4C07-BEA4-F410C18C66CC/DGBao.app/DGBao

Expectedin: /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation

in/private/var/mobile/Containers/Bundle/Application/5C6F5D69-5D14-4C07-BEA4-F410C18C66CC/DGBao.app/DGBao

解決辦法:

改為 optinal

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容