question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Xcode 14 beta 3: Failed to build WDA as XCTAutomationSupport.framework/XCTAutomationSupport linking failure

See original GitHub issue

[update] Please use newer xcuitest driver with appium 2.

https://github.com/appium/appium/blob/master/packages/appium/docs/en/guides/migrating-1-to-2.md

npm install --location=global appium@next
appium driver install xcuitest  # or "appium driver update xcuitest"
appium server --base-path=/wd/hub

Still the error occurred:

rm ~/.appium # or remove $APPIUM_HOME
appium driver install xcuitest
appium server --base-path=/wd/hub

The problem

This happens only XCTAutomationSupport.framework/XCTAutomationSupport included in Xcode 14 beta 3. XCTAutomationSupport in Xcode 14 beta 2 did not have. So as a workaround, you can use Xcode 14 beta 3 by replacing XCTAutomationSupport in Xcode 14 beta 3 with Xcode beta 2 for now.

(This does not mean Appium/WDA does not work on iOS 16 beta 3.)

mac2/WDA does not have this issue since it does not have a binary link to XCTAutomationSupport.

Environment

Details

Xcode build caused below errors:

  • simulator (on an intel mac)
error build: Cannot link directly with dylib/framework, your binary is not an allowed client of /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/XCTAutomationSupport.framework/XCTAutomationSupport for architecture x86_64
  • real device
error build: Cannot link directly with dylib/framework, your binary is not an allowed client of /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/XCTAutomationSupport.framework/XCTAutomationSupport for architecture arm64

Xcode build example…:

xcodebuild build-for-testing -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=00008030-000C51E13C29802E IPHONEOS_DEPLOYMENT_TARGET=15.4 GCC_TREAT_WARNINGS_AS_ERRORS=0 COMPILER_INDEX_STORE_ENABLE=NO

then:

ld: cannot link directly with dylib/framework, your binary is not an allowed client of /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/XCTAutomationSupport.framework/XCTAutomationSupport for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

So far, the workaround is to replace XCTAutomationSupport.framework/XCTAutomationSupport in beta 3 with the framework binary in beta 2.

Link to Appium logs

Code To Reproduce Issue [ Good To Have ]

Build Appium/WDA with Xcode 14 beta 3.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:4
  • Comments:19 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
Dan-Maorcommented, Jul 11, 2022

Here are my findings upon an initial investigation:

  • Apple are indeed make things a little more strict, looks like XCTest’s private frameworks were compiled with allowable_client flags specifying which clients are allowed to link to the XCTAutomationSupport framework (new LC_SUB_CLIENT load commands were added).

For dynamically linked shared libraries that are subframework of an umbrella framework they can allow clients other than the umbrella framework or other subframeworks in the same umbrella framework. To do this the subframework is built with “-allowable_client client_name” and an LC_SUB_CLIENT load command is created for each -allowable_client flag. The client_name is usually a framework name. It can also be a name used for bundles clients where the bundle is built with “-client_name client_name”.

  • As of Xcode 14 beta 3 XCTAutomationSupport is defined to only allow the following clients: AutomationInfrastructureIntegrationTests, IDEApplicationTests, IDETestingFoundationTests, IDEXcodeUITesting, XCTAutomationSupportTests, XCTDaemon, XCTDaemonControl, XCTDaemonControlTests, XCTDaemonTests, XCTHarness, XCTest-AppHostedTests, XCTest-PerformanceTests, XCTest-ToolHostedTests, XCTest-UITests-iOS, XCTest-UITests-macOS, XCTest-UITests-tvOS, XCTestCore, XCUIAutomation, XCUIRecorderService, testmanagerd, xctest.
  • We can tell the linker to use one of the whitelisted client names by adding -client_name xctest to the other linkers flags section of WebDriverAgentLib, however then the compiler will complain that the flag can only be used when building a bundle, not a dynamic library. Changing WebDriverAgentLib’s Mach-O type to Bundle will result in an inability for the main test bundle to link against it, stating that only dynamic libraries can be linked against.
  • As of now, the only solution I can think of in order to build with Xcode 14 beta 3 is to change the project structure by removing the WebDriverAgentLib target entirely and add all linked libraries references, header files and source files directly to the WebDriverAgent runner targets. After combining this method with the added flag (the main test bundle is already defined as a Mach-O bundle type) and adding the frameworks search path from WebDriverAgentLib (so that the XCTest frameworks can be located during link time) I managed to get WebDriverAgent runner to run on a simulator and on my iPhone running the iOS 16.0 beta 3.

Information regarding load commands taken from here: https://opensource.apple.com/source/cctools/cctools-921/include/mach-o/loader.h

3reactions
mykola-mokhnachcommented, Jul 10, 2022

We’d have to change WDA code to avoid dependencies on private frameworks. It looks like Apple is becoming more and more paranoid: https://developer.apple.com/forums/thread/124782

Read more comments on GitHub >

github_iconTop Results From Across the Web

ld: cannot link directly with dyli… | Apple Developer Forums
Mac mini with M1 chip (OS 13 beta); Xcode 14 Official; iPhone SE 2020 (iOS 16 Official). This is my error when building...
Read more >
WebDriverAgent - XCode build error - Support - Appium Discuss
Issue: Xcode 14 beta 3: Failed to build WDA as XCTAutomationSupport.framework/XCTAutomationSupport linking failure.
Read more >
error build: Cannot link directly with dylib/framework ...
I'm using. Xamarin.iOS; Visual Studio for Mac 17.4 with enabled manual provisioning; Xcode 14.1; macOS Monterey 12.6.1.
Read more >
Failed to build WebDriverAgent to deployed on iOS 16
This my error on terminal ... Xcode 14 beta 3: Failed to build WDA as XCTAutomationSupport.framework/XCTAutomationSupport linking failure.
Read more >
appium/appium - Gitter
Original error: Unable to launch WebDriverAgent because of xcodebuild failure: "xcodebuild failed with code 65". Make sure you follow the tutorial at https:// ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found