简体   繁体   English

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

[英]iOS Simulator crashes while real device does not

I work on a project that includes several libraries integrated as pods by Cocoapods - it has been a while but I think this error came up first when I integrated Cocoapods and hasn't disappeared ever since (so I started to use a real device for testing my builds). 我正在开发一个项目,其中包括由Cocoapods集成为pod的几个库 - 它已经有一段时间但我认为这个错误首先出现在我整合Cocoapods并且从那时起就没有消失(所以我开始使用真实的设备进行测试我的建设)。

Like I mentioned, I have no problems building on any real device but I constantly face the following error when building on the iOS simulator. 就像我提到的,我在任何真实设备上构建都没有问题但是在iOS模拟器上构建时我经常遇到以下错误。 Xcode completes the build successfully and starts up the simulator which then crashes as soon as it tries to load the build. 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)

I got cautious with changing linking options because when I faced this problem first, it affected also the building of Xcode itself which then failed again and again because of some difficult-for-me-to-understand errors. 我对更改链接选项持谨慎态度,因为当我首先遇到这个问题时,它也影响了Xcode本身的构建,然后由于一些难以理解的错误而一次又一次地失败。 Furthermore I don't make use of any Twitter specific code, it just seems to be part of an integrated library. 此外,我没有使用任何Twitter特定的代码,它似乎只是一个集成库的一部分。

Any help is highly appreciate as I'd very much like to be able to build on the simulator again! 任何帮助都非常感谢,因为我非常希望能够再次在模拟器上构建!

EDIT 1 编辑1

建立阶段

构建设置

EDIT 2 编辑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

Unfortunately, the iOS simulator does not fully support twitter accounts. 不幸的是,iOS模拟器并不完全支持Twitter帐户。 Your phone does. 你的手机呢。 The crash you're getting is for missing the _ACAccountTypeIdentifierTwitter . 您遇到的崩溃是缺少_ACAccountTypeIdentifierTwitter If you want to make sure that does not happen on the simulator, wherever you're checking for ACAccountType , check to make sure that ACAccountTypeIdentifierTwitter is available. 如果要确保在模拟器上没有发生,无论您在哪里检查ACAccountType ,请检查以确保ACAccountTypeIdentifierTwitter可用。 Same for facebook, SinaWeibo, and TencentWeibo. Facebook,新浪微博和腾讯微博也是如此。

Obj-C OBJ-C

You need to import both Twitter and Accounts frameworks. 您需要导入TwitterAccounts框架。

在此输入图像描述

Swift 迅速

The entire project below compiles, builds, links and runs on the iOS Simulator. 下面的整个项目在iOS模拟器上编译,构建,链接和运行。 If you follow these instructions, you can verify in no time the integrity of your development environment. 如果您按照这些说明操作,则可以立即验证开发环境的完整性。

Project 项目

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


Code

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)"
        )}
    }
}

Above code posted on Github for convenience. 为方便起见,上面的代码发布在Github上。


Link, build, run on iOS Simulator 链接,构建,在iOS模拟器上运行

(Verified as far back as Xcode 6.3.2 on Simulator 8.3) (早在模拟器8.3上验证为Xcode 6.3.2)

在此输入图像描述

granted:true error:nil grant:true error:nil

Once OK it tapped, you likely need to iOS Simulator > Reset Content and Settings... > Reset . 一旦确定它点击,您可能需要iOS模拟器>重置内容和设置...>重置

Don't use -undefined dynamic_lookup. 不要使用-undefined dynamic_lookup。 That is causing you to hit the failure at runtime instead of getting a more obvious and helpful error at link time. 这导致您在运行时遇到失败,而不是在链接时获得更明显和有用的错误。 If you remove that from LDFLAGS, you'll likely see an error message about not being able to resolve the _ACAccountTypeIdentifierTwitter symbol and where it's being used. 如果从LDFLAGS中删除它,您可能会看到一条错误消息,指出无法解析_ACAccountTypeIdentifierTwitter符号及其使用位置。

_ACAccountTypeIdentifierTwitter is provided by Accounts.framework: _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.

相关问题 iOS App在Simulator上运行正常,但在真实的iOS设备上崩溃 - iOS App works fine with Simulator but Crashes with a real iOS device Expo 应用程序在 Expo Go 和 iOS 模拟器上工作,但在真实设备上崩溃 - Expo app working on Expo Go and iOS Simulator but crashes on real device Xamarin.ios 不适用于真正的 iOS 设备,但它适用于模拟器 - Xamarin.ios does NOT work on real iOS device but it works on Simulator Firebase 在 ios 模拟器上运行良好,但在真实设备上不起作用 - Firebase works fine on ios simulator but it does't work on real device Simulator上的Xcode应用程序可以在真实设备崩溃时正常工作 - Xcode app on Simulator works, on real device crashes Swift 应用程序在真实设备上崩溃,但在模拟器上运行 - Swift app crashes on real device but works on simulator iOS模拟器在启动时(间歇性地)崩溃,设备上没有崩溃 - iOS simulator crashes at startup (intermittently), no crashes on device 仅在调试时在没有启动设备时iOS App崩溃-不在模拟器中或在正常启动设备应用程序时崩溃 - iOS App crashes on launch no device while debugging only - not in simulator or during normal device app launch userDefaults.setObject在设备上崩溃,但在iOS模拟器中没有崩溃 - userDefaults.setObject crashes on device but not in iOS simulator iOS GL ES 2应用在设备上崩溃,但在模拟器上没有崩溃 - iOS GL ES 2 app crashes on device but not on simulator
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM