2

I'm using XCode 8.2.1 with Swift 3.0.1

I'm deploying DEBUG builds to Fabric/Crashlytics from my local machine using fastlane, so I do have appropriate .xcarchive's in XCode organizer.

I'm able to attach to process of my application on iPhone using XCode > Debug > Attach to process by PID or name

Now the problem is that the whole Swift stuff is unavailable for me to debug. Neither symbolic breakpoints, no po is working for Swift. Moreover, lldb expects Objective-C syntax so I'm able to do stuff like po [[UIApplication sharedApplication] delegate] etc.

Now I'm trying to access calculatable properties from protocol extensions and have no luck. So the question is:

Given: Imagine I have

protocol Some {
    var some: String { get }
}

extension Some {
   var some: String {
       get {
           return "Hello"
       }
   }
}

class AppDelegate: UIResponder, Some {
}

Needed: access AppDelegate's some property from lldb

po [[[UIApplication sharedApplication] delegate] some] results in error:

error: Execution was interrupted, reason: Attempted to dereference an invalid ObjC Object or send it an unrecognized selector. The process has been returned to the state before expression evaluation.

Any chance to use Swift syntax or some other suggestion? Thanks!

1 Answer 1

1

It is not possible to debug Swift/ObjC mixed code that was not built locally.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks Jim! I've mentioned that I have made a build on the same machine so I have an archive. Isn't this enough and build should be run directly from XCode? Do you have any explanation references?
The swift debug format is a serialization of the compiler's internal state, so one requirement is that the compiler you built the code with must match the version linked into the debugger. If you have ObjC-Swift bindings, the debugger also has to rebuild the clang modules that presented that binding to the swift compiler. That generally means the SDK used to compile the app must be present when you debug, and any ObjC headers of yours that were used must also be present. And since lots of paths get directly recorded in the process, these bits must all be in their original locations.
If those two requirements are met, you should be able to debug your archived code. This was discussed in the session on lldb at last year's (2016) WWDC. It doesn't say much more than I just said, however.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.