6

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).

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. Xcode completes the build successfully and starts up the simulator which then crashes as soon as it tries to load the build.

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. Furthermore I don't make use of any Twitter specific code, it just seems to be part of an integrated library.

Any help is highly appreciate as I'd very much like to be able to build on the simulator again!

EDIT 1

Build Phases

Build Settings

EDIT 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
SwiftArchitect
  • 47,376
  • 28
  • 140
  • 179
alexeis
  • 2,152
  • 4
  • 23
  • 30
  • Put Exception Breakpoint & debug in device that will show you in which line it crashes. Put that code here. – cyberlobe Jul 30 '15 at 12:48
  • @Alexei S. Hi. See that http://stackoverflow.com/questions/24043532/dyld-symbol-not-found-nsurlauthenticationmethodclientcertificate-when-trying `OTHER_LDFLAGS = -framework Foundation -ObjC …` – Serge Maslyakov Jul 30 '15 at 13:14
  • @Mozilla Thanks for your input, unfortunately it doesn't help, problem stays the same. Put some extra info in edit 1. – alexeis Jul 30 '15 at 20:34
  • @cyberlobe Even though I've been programming for almost a year now I'm not too experienced with this kind of debugging yet. What steps (exactly) should I do, because I don't think you're looking for an output like the one in Edit 2 (adding an exceptional break point with "all"), right? – alexeis Jul 30 '15 at 20:58
  • I notice in other articles mention that you should add the `${inherited}` flag in your Other Linker Flags section when using pods. – Rory McKinnel Aug 04 '15 at 13:24
  • @AlexeiS. Probably you removed `Accounts.framework` from disk by mistake. First of all try to reset simulator: open simulator -> go to top menu -> iOS Simulator -> Reset Contents and Settings... . If it doesn't help I will suggest to reinstall Xcode. – Vlad Papko Aug 04 '15 at 15:33
  • 1
    Xcode's simulator's are buggy and you'll often run into issues that aren't actually due to something 'wrong' in your code. Before making any drastic changes to your project, be sure to close Xcode and reset your content and settings in the simulator. @Visput 's steps are easy enough to follow – ChrisHaze Aug 10 '15 at 15:23
  • Not only would I recommend @ChrisHaze suggestion, I would not waste much time on a corrupted project. It is healthy to create a new Xcode proj from scratch and simply drag your files over. You will find that it is a bit like rebooting. In the test I outline in my response, you can get up and running in about 1 minute ; a lot less than chasing an elusive error. – SwiftArchitect Aug 12 '15 at 05:54
  • @ChrisHaze I did so, didn't help - the problem has been around for many months now. Furthermore the error is only occurring when using the simulator why I haven't thought to rebuild the whole project from scratch again. And again, I think it has to do with the integration of cocoapods. It would be interesting to know where this error happens and why this code is processed. – alexeis Aug 12 '15 at 19:39
  • @SwiftArchitect ...the latest when I integrate cocoapods again, I'll face the same problem again - I don't think the project is corrupted. – alexeis Aug 12 '15 at 19:45
  • @AlexeiS.: Please post your Podfile. I am certain we can figure out what breaks. Also specify what is your iOS target, which device you are building against, and you Xcode, Sim and OS X versions. – SwiftArchitect Aug 13 '15 at 03:10

3 Answers3

3

Unfortunately, the iOS simulator does not fully support twitter accounts. Your phone does. The crash you're getting is for missing the _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. Same for facebook, SinaWeibo, and TencentWeibo.

Fennelouski
  • 2,411
  • 1
  • 18
  • 26
0

Obj-C

You need to import both Twitter and Accounts frameworks.

enter image description here

Swift

The entire project below compiles, builds, links and runs on the iOS Simulator. 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.


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.


Link, build, run on iOS Simulator

(Verified as far back as Xcode 6.3.2 on Simulator 8.3)

enter image description here

granted:true error:nil

Once OK it tapped, you likely need to iOS Simulator > Reset Content and Settings... > Reset.

Community
  • 1
  • 1
SwiftArchitect
  • 47,376
  • 28
  • 140
  • 179
  • Thanks for your answer. I built that sample project and it works without error. Still, how exactly do you tell me to avoid the error in my other project? I have Twitter and Accounts in my Build Phases (but don't use it anywhere in my code). My own experience tells me this error comes up as soon as you make use of cocoapods, it can regularly lead to linker problems. – alexeis Aug 12 '15 at 10:50
  • First things first: Since you and I are able to build my sample project above, and run the line `accountTypeWithAccountTypeIdentifier`, we must agree that @Fennelouski response is erroneous. It states that the Simulator does not support `ACAccountTypeIdentifierTwitter `, which is incorrect. It is easy to figure out which Pod is failing: search for `ACAccountTypeIdentifierTwitter` in your entire project. Ensure your Project builds for iOS 5 or better, and that your Podfile requires iOS 8. – SwiftArchitect Aug 13 '15 at 03:03
  • I am recommending you take my project above, add your Pods to it (`pod init`, set the OS, add Pods, `pod install`) and you will see very quickly which one is the culprit. As suggested by many comments, it may just be a Xcode snafu, and starting a fresh project may solve this corruption challenge. – SwiftArchitect Aug 13 '15 at 03:05
0

Don't use -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.

_ACAccountTypeIdentifierTwitter is provided by Accounts.framework:

$ nm $(xcrun --sdk iphonesimulator --show-sdk-path)/System/Library/Frameworks/Accounts.framework/Accounts | grep _ACAccountTypeIdentifierTwitter
000000000003bdd0 S _ACAccountTypeIdentifierTwitter
Jeremy Huddleston Sequoia
  • 22,938
  • 5
  • 78
  • 86