我遇到了一個問題,當我通過Xcode運行它時,我的應用運行良好,但手動啓動時崩潰。我經歷了很多帖子,但我找不到任何具體的答案。我檢查了設備的日誌,這裏是一個片段,我認爲是事故的原因:當不通過Xcode運行時,應用程序崩潰
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x0000000180ff5b9c objc_msgSend +28
1 AppSupport 0x0000000183159f0c _updateDetachedRecord + 32
2 AppSupport 0x0000000183159ffc CPRecordGetProperty + 52
3 AppSupport 0x000000018315a270 CPRecordCopyProperty + 24
4 AddressBook 0x0000000187774498 ABRecordCopyValueUnfiltered + 68
5 AddressBook 0x00000001877743bc ABRecordCopyValue + 68
我試圖訪問我的地址簿,並獲取聯繫人的詳細信息(無論用戶點擊),然後顯示它在彈出窗口中。下面是代碼片段:
NSString *firstName = (__bridge NSString *) ABRecordCopyValue(person, kABPersonFirstNameProperty);
NSString *lastName = (__bridge NSString *) ABRecordCopyValue(person, kABPersonLastNameProperty);
NSString *company = (__bridge NSString *) ABRecordCopyValue(person, kABPersonOrganizationProperty);
NSString *title = (__bridge NSString *) ABRecordCopyValue(person, kABPersonPrefixProperty);
ABMultiValueRef emails = ABRecordCopyValue(person, kABPersonEmailProperty);
NSString *email = (__bridge NSString *)(ABMultiValueCopyValueAtIndex(emails, 0));
ABMultiValueRef phoneNo = ABRecordCopyValue(person, kABPersonPhoneProperty);
NSString *phnNo = (__bridge NSString *)(ABMultiValueCopyValueAtIndex(phoneNo, 0));
ABMultiValueRef skyepeIDs = ABRecordCopyValue(person, kABPersonInstantMessageProperty);
NSDictionary *skyepeID = (__bridge NSDictionary *)(ABMultiValueCopyValueAtIndex(skyepeIDs, 0));
P.S:當我通過Xcode中運行的應用程序運行完全正常。
嘗試關閉Swift編譯器/代碼生成下的構建設置中的發佈版本的Swift編譯器優化,如果仍然存在,那麼嘗試關閉整個模塊優化 – Buntylm
您是否獲取了地址簿在發佈時間? –
或在啓動時做其他事情? –