做開發(fā)就會遇到各種各樣的問題,以前都是看看解決了就過了裁奇,有時候遇到同樣的問題桐猬,卻忘了怎么解決,還要重新上網(wǎng)去找刽肠,干脆就留下點痕跡吧溃肪。。音五。
cannot create __weak reference in file using manual reference counting
解決1:
設置項目中的build setting -> Apple LLVM7.1 - Language - Objective C -> Weak References in Manual Retain Release YES
解決2:
用__unsafe_unretained 代替__weak,但是如果用__unsafe_unretained請注意下面的問題惫撰。
__unsafe_unretained specifies a reference that does not keep the referenced object alive and is not set to nil when there are no strong references to the object. If the object it references is deallocated, the pointer is left dangling.
You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
這是一個很早以前遇到的問題了,解決方法很簡單躺涝,
設置項目中的build setting -> All - Combined - 搜索bitcode -> 置為No參考文章
昨天有朋友問我怎么保持藍牙長連接厨钻,就是在后臺也不斷開,其實這問題百度上一搜一大把啊坚嗜,谷歌我就不說了夯膀。
也說下解決方法吧,只要在info.plist中加入新建一行 Required background modes
, 加入下面兩項苍蔬。App shares data using CoreBluetooth
和 App communicates using CoreBluetooth
duplicate symbols for architecture arm64
錯誤原因可能是:1.有重名的文件诱建。2.import
的時候把.h寫成.m。
解決方法:前者搜索該文件名碟绑,改名或刪除均可涂佃。后者改成.h即可。
Implicit declaration of function 'SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO' is invalid in C99
錯誤原因是這樣的蜈敢,我自定義了宏#define SYSTEM_RUNS_IOS7_OR_LATER SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")
解決方法也比較讓我驚奇辜荠,只要在宏定義的地方添加如下代碼即可
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
參考:http://stackoverflow.com/questions/23818606/semantic-issue-implicit-declaration-of-function
Application windows are expected to have a root view controller at the end of application launch
這個報錯現(xiàn)在幾乎是看不到了,我是下載了httpserver的demo,運行出錯抓狭。問題就出在rootViewController
上伯病。
解決方法,只要設置rootViewController
就行了否过。我將[window addSubview:viewController.view];
改成window.rootViewController = viewController;
運行ok...
fatal error: could not build module 'Foundation'
今天運行程序的時候突然冒出27個錯,而且一看是系統(tǒng)的庫,上網(wǎng)查了資料才知道是因為導入了.c的文件而造成的午笛。
解決方法:在.pch文件中加上#ifdef OBJC 和#endif即可。
fatal error: No code signing identities found: No valid signing identities (i.e. certificate and private key pair) matching the team ID “********” were found.
這是我在Archive時遇到的苗桂,一看就知道是證書問題药磺,參考了stackoverflow解決了。解決方法:點左上Xcode > 選擇Preferences煤伟,在Accounts中找到你的Apple ID,然后點擊View Details,等待加載癌佩,時間會有個1?2分鐘的樣子木缝,在Provisioning Profiles欄中,download證書围辙,然后問題解決我碟。
fatal error:Missing iOS Distribution signing identity
還是打包上傳的時候遇到的,依舊是證書問題姚建,就不說原因了矫俺,直接說解決方法:
1.https://developer.apple.com/certificationauthority/AppleWWDRCA.cer下載最新的證書,雙擊安裝
2.到鑰匙串中將過期的證書刪除即可掸冤。(別問我鑰匙串在哪厘托,也別說找不到過期的證書v)
3.沒有第三了,問題已經(jīng)解決了稿湿。
UIWebView手勢無效問題
這幾天用UIWebView添加上滑下滑手勢,發(fā)現(xiàn)沒有效果,查了資料才發(fā)現(xiàn),UIWebView已經(jīng)自帶手勢了,解決問題的方法很簡單,添加一個方法:- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
方法實現(xiàn)起來也很簡單,我看有的人直接return YES;
,但我發(fā)現(xiàn)這樣并不嚴謹,應該加個判斷,如果是你添加的手勢,return YES;否則return NO;
跑一下,OK?
Undefined symbols for architecture x86_64:
缺少庫催烘,缺什么自己補什么就好了。缎罢。伊群。
attempt to insert nil object from objects[1]'
插入數(shù)組或字典中得值為空,可先進行判斷在插入
specifies a non-existent file for the cfbundleexecutable key
這是打包上傳時遇到的策精,原因是我添加了QQ的分享舰始,只要在info.plist文件中刪除executable file 這個key即可
Failed to chmod user/Library/Developer/CoreSimulator/Devices NO Such File Or directory
這個出現(xiàn)的具體原因我也不是很清楚,在so上也能找到咽袜,我重置了一下模擬器就好了( Simulator -> Reset Content and Settings...)丸卷,當然也有人說重置了沒用。询刹。谜嫉。,so鏈接:http://stackoverflow.com/questions/40485155/failed-to-chmod-user-library-developer-coresimulator-devices-no-such-file-or-dir
Failed to chmod user/Library/Developer/CoreSimulator/Devices NO Such File Or directory
這個出現(xiàn)的具體原因我也不是很清楚,在so上也能找到凹联,我重置了一下模擬器就好了( Simulator -> Reset Content and Settings...)沐兰,當然也有人說重置了沒用。蔽挠。住闯。,so鏈接:http://stackoverflow.com/questions/40485155/failed-to-chmod-user-library-developer-coresimulator-devices-no-such-file-or-dir
This action could not be completed.Try again.(-22421)
錯誤是在上傳項目時出現(xiàn)的,就是說你網(wǎng)絡有問題澳淑,繼續(xù)重試即可比原。
PCH was compiled with module cache path
出現(xiàn)這個問題應該是我復制項目所以報錯,說路徑不同了杠巡,只要把but后面的路徑里的文件刪掉量窘,然后clean項目就好了
This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.
出現(xiàn)這個問題是我在iOS 10的手機上調(diào)用系統(tǒng)相機,然后就崩潰了
解決方法:
- 在項目中找到info.plist文件氢拥,右鍵點擊以 Source Code形式打開
- 添加以下鍵值對蚌铜,這里以 PhotoLibrary 作為例子
<key>NSCameraUsageDescription</key>
<string>此 App 需要您的同意才能讀取媒體資料庫</string>
- 注意锨侯,key 是絕對不能寫錯的,而 value 也就是<string></string>你可以隨意寫
member access within misaligned address 0x000000000031 for type 'struct ListNode', which requires 8 byte alignment
這是一個c里面的錯誤,出現(xiàn)的環(huán)境是我做一個鏈表,alloc以后,調(diào)用此列表中的屬性,然后報錯,解決方法也很簡單,alloc以后,對鏈表的每個屬性賦值即可(沒值就賦NULL)
All interface orientations must be supported unless the app requires full screen.
這只是一個警告厘线,但是看著不爽识腿,能解決就解決掉吧出革。這個警告是說App默認是有開啟了多任務功能造壮,而多任務功能是需要App支持所有方向,如果我們App是有需要支持多任務骂束,則需要開啟App對各個方向(上耳璧、下、左展箱、右)的支持;如果App不需要開啟多任務旨枯,則只需要將Target中Status Bar Style中的的 Requires full screen 勾選上就ok
Unable to find a specification for xxxxx
.
這是在cocopods上安裝庫的時候遇到的問題,解決方法可以更新庫pod repo update
當然混驰,也可以把庫刪了pod repo remove master
,然后重裝pod setup
Safe Area Layout Guide before iOS 9.0
出現(xiàn)這個問題是因為iOS11以后出現(xiàn)了Safe Area這個概念攀隔,在sb和xib中默認設置了Safe Area,解決方法有兩個:
方法一:把系統(tǒng)版本提高到9.0或以上栖榨;
方法二:如下圖所示取消Use Safe Area Layout Guides選項即可昆汹。
[framework] CUIThemeStore: No theme registered with id=0
這是在控制臺打印出來的,雖然沒啥影響婴栽,但看著不爽满粗,解決方法很簡單,在 Assets.xcassets 文件夾中添加一張圖片就行了愚争。映皆。。
tabBarItem的位置會從一個偏移位置閃現(xiàn)到正常位置
不影響使用轰枝,但看著很不爽捅彻,解決很簡單,在didFinishLaunchingWithOptions
方法中加一句[[UITabBar appearance] setTranslucent:NO];
即可鞍陨。沟饥。。
libMobileGestalt MobileGestalt.c:890: MGIsDeviceOneOfType is not supported on this platform.
編輯Scheme-> Run - > Arguments湾戳,在Environment Variables里邊添加OS_ACTIVITY_MODE =禁用
來屏蔽這些打印即可贤旷。
不斷更新,未完待續(xù)砾脑。幼驶。。