error: invalid target, create a target using the 'target create' command

The actual issue is that Xcode 13 does stop at breapoints, but using the debugger (po someObject) does not print but gives us an error:

warning: Swift error in scratch context: error: 
/Path/To/OurApp/OurApp-Bridging-Header.h:14:9:
 error: 'SomeSucessfulyUsedDependency.h' file not found

This issue happens on parts of our code, other parts work fine. This is reproducible.

The same project works fine with Xcode 12

Starting with Xcode 13, when running our app in DEBUG config on sim or device (both iOS 15, but we have tested sims <iOS15 too), the first line in console is:

error: invalid target, create a target using the 'target create' command

It looks like Xcode 13 is unable to create a target in LLDB. But maybe the console output is misleading and unrelated.

That obviously make debugging a none-nice process ...

Any help appreciated.

Post not yet marked as solved Up vote post of pEpee Down vote post of pEpee
2.9k views

Replies

If you create a new test app from one of the built-in templates, does it have the same problem?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

@eskimo: I have updated the question. Was partly wrong.

If you create a new test app from one of the built-in templates, does it have the same problem?

A new, plain iOS app shows the same console output. using the debugger (po ...) works though.

We could work around this error by replacing #import "SomeSucessfullyUsedDependency.h" with #import <SomeSucessfullyUsedDependency.h> in /Path/To/OurApp/OurApp-Bridging-Header.h.

But now we get a different error using po someObject:

Looking for "@rpath/BackgroundTasks.framework/BackgroundTasks", error: dlopen failed for unknown reasons.

Failed to find framework for "BackgroundTasks" looking along paths:

/Users/me/Library/Developer/Xcode/DerivedData/OurApp-cmnmsqemuyxojlavehflywtxguqr/Build/Products/Debug-iphonesimulator/BackgroundTasks.framework/

Looking for 
"/Users/me/Library/Developer/Xcode/DerivedData/OurApp-cmnmsqemuyxojlavehflywtxguqr/Build/Products/Debug-iphonesimulator/BackgroundTasks.framework/"

,    error: dlopen failed for unknown reasons.

error: <EXPR>:3:1: error: cannot find 'someObject' in scope

Very deep cleaning (rm derived data, caches, ++) fixes the missing BackgroundTask console output.

So whats left is that Xcode 13 LLDB does not print objects in most places of out code. Reproducible for the complete team.

error: invalid target, create a target using the 'target create' command

// ...

(lldb) po someObject
error: <EXPR>:3:1: error: cannot find 'someObject' in scope

While Xcode 12.x works as expected.

Due to the fact the internet did not explode yet, I assume this is not a general Xcode issue but something related to our Xcode Project.

Any hint highly appreciated o/

Due to the fact the internet did not explode yet, I assume this is not a general Xcode issue but something related to our Xcode Project.

Indeed. Which is why I asked what happens when you try this with a new target. You responded with:

A new, plain iOS app shows the same console output. using the debugger (po ...) works though.

Which same console output? The invalid target message? Is that still the case after your ‘deep clean’?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Which same console output? The invalid target message?

Yes.

error: invalid target, create a target using the 'target create' command

Is that still the case after your ‘deep clean’?

Yes. As said also shows up on vanilla iOS "Single View App"

(I also have another issue which I assume is caused by the same root. But lets not mix topics. Will create new ticket in case it persists after this is solved.

(thx for taking care and sorry for delayed answer. Did not get any notification which I expected)

If you create a new user (System Preferences > Users & Groups), log in as that user, run Xcode there, and use it to create and run a new test app, do you still see the problem?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

If you create a new user (System Preferences > Users & Groups), log in as that user, run Xcode there, and use it to create and run a new test app, do you still see the problem?

No. Does not show the problem.

Interesting. So something stored in your main user account is triggering this.

Just to confirm, both your main user account and your temporary test account were admin accounts, right?

Do you have any .lldbinit files in play? These can be loaded from a variety of locations, as discussed in the Configuration Files section of the lldb man page.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Just to confirm, both your main user account and your temporary test account were admin accounts, right?

Yes, correct.

Do you have any .lldbinit files in play?

No. At least nothing we manually / intentionally configured. Also keep in mind: this happens reproducable for the complete team in Xcode 13.x and not in Xcode 12.x.

Also keep in mind: this happens reproducable for the complete team

Right. And, at least on your machine, it happens with a new test project created using your standard account but not with a new test project created using a new test account. That suggests it’s some configuration change that everyone on your team has applied. Weird.

This is still correlated with po not working, right? If so, that’s kinda annoying, and probably worth opening a DTS tech support incident so that DTS’s tools expert can allocate time to look at this in depth.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

This is still correlated with po not working, right?

po not working happens only for our project, and only in parts of it (reproducable).

"Parts of it" means in some files po does not work 100%, in others it works 100%.

The same project and files do not show the error and po works using Xcode 12.

For new project, the LLDB error is there (but not for new project created on newly created user)

error: invalid target, create a target using the 'target create' command

but po works for new projects.

probably worth opening a DTS tech support incident so that DTS’s tools expert can allocate time to look at this in depth

OK, will do. Thanks!

+1

I have the same issues.

  1. "error: invalid target, create a target using the 'target create' command" in Xcode 13.x but not in Xcode <13.

  2. po not working when stopping on breakpoint in "random" source files. (100% reproducibly on affected files, but "random" as I can not see why / which files are affected and which are not)