cgold
cgold

Reputation: 4245

iOS app is missing DYLD if not run from xcode

If I run my app from Xcode 12.3, I can launch it on my Iphone 11. But running the app on the phone fails. The device log gives the following error in a package (Mocker) that I am using:

Termination Description: DYLD, dyld: Using shared cache: 
EEFDD874-2301-31BF-B255-11CE61E827BD | dependent dylib 
'@rpath/XCTAutomationSupport.framework/XCTAutomationSupport'
 not found for 
'/private/var/containers/Bundle/Application/
E5F4D064-2097-4978-AFB5-954DC355F686/Things.app/Frameworks/
Mocker.framework/Frameworks/XCTest.framework/XCTest', tried but didn't find: 
'/usr/lib/swift/XCTAutomationSupport.framework/XCTAutomationSupport' 
'/private/var/containers/Bundle/Application/
E5F4D064-2097-4978-AFB5-954DC355F686/Things.app/Frameworks/
XCTAutomationSupport.framework/
XCTAutomationSupport' 
'/private/var/containers/Bundle/Application/E5F4D064-2097-4978-AFB5-
954DC355F686/Things.app/Frameworks/Mocker.framework/Frameworks/
XCTAutomationSupport.
framework/XCTAutomationSupport' '@rpath/XCTAutomationSupport.framework/
XCTAutomationSupport' 
'/System/Library/Frameworks/XCTAutomationSupport.framework/
XCTAutomationSupport'

Clearly, this is a problem where some package can be found or not found depending on specification. How would I move forward? If possible, I'd appreciate an understanding of how this can even happen - what makes it possible that libraries become unavailable when running from the phone instead of being launched from Xcode (on the same phone)?

Upvotes: 2

Views: 1797

Answers (1)

Pranav Kasetti
Pranav Kasetti

Reputation: 9925

The reason this fails at runtime rather than compile-time is that Mocker is trying to find the XCTest dynamic library - these are only loaded at runtime.

The framework is missing in the Application Bundle - can be seen from the error log:

not found for 
'/private/var/containers/Bundle/Application/
E5F4D064-2097-4978-AFB5-954DC355F686/Things.app/Frameworks/
Mocker.framework/Frameworks/XCTest.framework/XCTest

Add the dylib to the Linked Frameworks and Libraries of the application target, follow the steps here and there are lots of other SO questions related to embedding XCTest.framework into an application target.

This isn't a problem for testing targets, since they have already been added on both the simulator and device runtimes.

Upvotes: 1

Related Questions