繁体   English   中英

iOS模拟器崩溃而真实设备没有崩溃

[英]iOS Simulator crashes while real device does not

我正在开发一个项目,其中包括由Cocoapods集成为pod的几个库 - 它已经有一段时间但我认为这个错误首先出现在我整合Cocoapods并且从那时起就没有消失(所以我开始使用真实的设备进行测试我的建设)。

就像我提到的,我在任何真实设备上构建都没有问题但是在iOS模拟器上构建时我经常遇到以下错误。 Xcode成功完成构建并启动模拟器,然后在尝试加载构建时立即崩溃。

dyld: Symbol not found: _ACAccountTypeIdentifierTwitter
  Referenced from: .../Library/Developer/CoreSimulator/Devices/28482AD6-B0F2-4FBF-B525-C1EA3F2E07FA/data/Containers/Bundle/Application/D9992D1D-FE14-4403-A9DC-E5C1BB787E9E/projectName.app/projectName
  Expected in: flat namespace
 in .../Library/Developer/CoreSimulator/Devices/28482AD6-B0F2-4FBF-B525-C1EA3F2E07FA/data/Containers/Bundle/Application/D9992D1D-FE14-4403-A9DC-E5C1BB787E9E/projectName.app/projectName
(lldb)

我对更改链接选项持谨慎态度,因为当我首先遇到这个问题时,它也影响了Xcode本身的构建,然后由于一些难以理解的错误而一次又一次地失败。 此外,我没有使用任何Twitter特定的代码,它似乎只是一个集成库的一部分。

任何帮助都非常感谢,因为我非常希望能够再次在模拟器上构建!

编辑1

建立阶段

构建设置

编辑2

dyld`_dyld_start:
    0x7fff6431d000 <+0>:   popq   %rdi
    0x7fff6431d001 <+1>:   pushq  $0x0
    0x7fff6431d003 <+3>:   movq   %rsp, %rbp
    0x7fff6431d006 <+6>:   andq   $-0x10, %rsp
    0x7fff6431d00a <+10>:  subq   $0x10, %rsp
    0x7fff6431d00e <+14>:  movl   0x8(%rbp), %esi
    0x7fff6431d011 <+17>:  leaq   0x10(%rbp), %rdx
    0x7fff6431d015 <+21>:  movq   0x37aec(%rip), %r8        ;     _dyld_start_static
    0x7fff6431d01c <+28>:  leaq   -0x23(%rip), %rcx         ; <+0>
    0x7fff6431d023 <+35>:  subq   %r8, %rcx
    0x7fff6431d026 <+38>:  leaq   -0x102d(%rip), %r8
    0x7fff6431d02d <+45>:  leaq   -0x8(%rbp), %r9
    0x7fff6431d031 <+49>:  callq  0x7fff6431d076            ;     dyldbootstrap::start(macho_header const*, int, char const**, long, macho_header const*, unsigned long*)
->  0x7fff6431d036 <+54>:  movq   -0x8(%rbp), %rdi
    0x7fff6431d03a <+58>:  cmpq   $0x0, %rdi
    0x7fff6431d03e <+62>:  jne    0x7fff6431d050            ; <+80>
    0x7fff6431d040 <+64>:  movq   %rbp, %rsp
    0x7fff6431d043 <+67>:  addq   $0x8, %rsp
    0x7fff6431d047 <+71>:  movq   $0x0, %rbp
    0x7fff6431d04e <+78>:  jmpq   *%rax
    0x7fff6431d050 <+80>:  addq   $0x10, %rsp
    0x7fff6431d054 <+84>:  pushq  %rdi
    0x7fff6431d055 <+85>:  movq   0x8(%rbp), %rdi
    0x7fff6431d059 <+89>:  leaq   0x10(%rbp), %rsi
    0x7fff6431d05d <+93>:  leaq   0x8(%rsi,%rdi,8), %rdx
    0x7fff6431d062 <+98>:  movq   %rdx, %rcx
    0x7fff6431d065 <+101>: movq   (%rcx), %r8
    0x7fff6431d068 <+104>: addq   $0x8, %rcx
    0x7fff6431d06c <+108>: testq  %r8, %r8
    0x7fff6431d06f <+111>: jne    0x7fff6431d065            ; <+101>
    0x7fff6431d071 <+113>: jmpq   *%rax
    0x7fff6431d073 <+115>: nop

不幸的是,iOS模拟器并不完全支持Twitter帐户。 你的手机呢。 您遇到的崩溃是缺少_ACAccountTypeIdentifierTwitter 如果要确保在模拟器上没有发生,无论您在哪里检查ACAccountType ,请检查以确保ACAccountTypeIdentifierTwitter可用。 Facebook,新浪微博和腾讯微博也是如此。

OBJ-C

您需要导入TwitterAccounts框架。

在此输入图像描述

迅速

下面的整个项目在iOS模拟器上编译,构建,链接和运行。 如果您按照这些说明操作,则可以立即验证开发环境的完整性。

项目

Xcode> New> Project ...>单视图应用程序SO-TwitterSwift,Universal,Next,Create。


import UIKit
import Twitter
import Accounts

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        let accountStore = ACAccountStore()
        let accountType = accountStore.accountTypeWithAccountTypeIdentifier(
            ACAccountTypeIdentifierTwitter)

        accountStore.requestAccessToAccountsWithType(accountType, options: nil) {(
            granted:Bool, error:NSError!) -> Void in
                println("granted:\(granted) error:\(error)"
        )}
    }
}

为方便起见,上面的代码发布在Github上。


链接,构建,在iOS模拟器上运行

(早在模拟器8.3上验证为Xcode 6.3.2)

在此输入图像描述

grant:true error:nil

一旦确定它点击,您可能需要iOS模拟器>重置内容和设置...>重置

不要使用-undefined dynamic_lookup。 这导致您在运行时遇到失败,而不是在链接时获得更明显和有用的错误。 如果从LDFLAGS中删除它,您可能会看到一条错误消息,指出无法解析_ACAccountTypeIdentifierTwitter符号及其使用位置。

_ACAccountTypeIdentifierTwitter由Accounts.framework提供:

$ nm $(xcrun --sdk iphonesimulator --show-sdk-path)/System/Library/Frameworks/Accounts.framework/Accounts | grep _ACAccountTypeIdentifierTwitter
000000000003bdd0 S _ACAccountTypeIdentifierTwitter

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM