Skip to content

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

@KazuCocoa

Description

@KazuCocoa
Member

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

Activity

mykola-mokhnach

mykola-mokhnach commented on Jul 10, 2022

@mykola-mokhnach
Collaborator

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

Dan-Maor

Dan-Maor commented on Jul 11, 2022

@Dan-Maor
Contributor

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

mykola-mokhnach

mykola-mokhnach commented on Jul 11, 2022

@mykola-mokhnach
Collaborator

thanks for the investigation @Dan-Maor
This makes sense, however I'm not quite sure it is not going to create another issues related to project building or configuration, which would require to rewrite xcuitest driver wrappers for it.
I've started working on another solution, which removes private classes from the dependencies list. However, this change requires to refactor a lot of dependant code (really, a lot) and will require some weeks to land before I can even make it to compile successfully. Although it is safer from the perspective that all the other building infra should remain as is.

All the related changes could be found at https://github.com/appium/WebDriverAgent/tree/xcode_upd

KazuCocoa

KazuCocoa commented on Jul 12, 2022

@KazuCocoa
MemberAuthor

thank you for the detailed investigation @Dan-Maor

Would you mind asking a question..? How did you find allowed clients you addressed as below?

As of Xcode 14 beta 3 XCTAutomationSupport is defined to only allow the following clients:...

I initially guessed to remove dynamic links, but haven't tried well yet.

Dan-Maor

Dan-Maor commented on Jul 12, 2022

@Dan-Maor
Contributor

@KazuCocoa I retrieved the list from Hopper by going through the load commands and listing the strings of the LC_SUB_CLIENT load commands.

They can also be retrieved in the same manner by using otool -l on the XCTAutomationSupport framework.

KazuCocoa

KazuCocoa commented on Jul 12, 2022

@KazuCocoa
MemberAuthor

thank you! I've learned the tool and the way...

mykola-mokhnach

mykola-mokhnach commented on Jul 14, 2022

@mykola-mokhnach
Collaborator

Closed as fixed

32 remaining items

KazuCocoa

KazuCocoa commented on Feb 25, 2023

@KazuCocoa
MemberAuthor

Maybe it shows more information such as the code sign did not work etc, but your environment was for a simulator, and Appium 2 and newer XCUITest driver, then potentially some other issues might be there. Could you share the full log as GIST?

Haochenyu2021

Haochenyu2021 commented on Feb 26, 2023

@Haochenyu2021

Maybe it shows more information such as the code sign did not work etc, but your environment was for a simulator, and Appium 2 and newer XCUITest driver, then potentially some other issues might be there. Could you share the full log as GIST?

Hi @KazuCocoa Here is the log....
appium-server-logs.txt

KazuCocoa

KazuCocoa commented on Feb 26, 2023

@KazuCocoa
MemberAuthor

Thanks, but I meant the vanilla xcodebuild instead of the Appium log at this time (sorry)

Haochenyu2021

Haochenyu2021 commented on Feb 26, 2023

@Haochenyu2021

Thanks, but I meant the vanilla xcodebuild instead of the Appium log at this time (sorry)

Thanks @KazuCocoa - I use xcrun simctl spawn log stream | grep Appium to check the xcodebuild for the simulator, got no such file or directory for this UDID.
I guess there's no log created from xcode because from appium we could see: [xcodebuild error message:] is null here

KazuCocoa

KazuCocoa commented on Feb 26, 2023

@KazuCocoa
MemberAuthor

I meant xcodebuild with the below command directly.

[debug] �[35m[WebDriverAgent]�[39m Beginning test with command 'xcodebuild build-for-testing test-without-building -project /Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -derivedDataPath /Users/emily/Library/Developer/Xcode/DerivedData/WebDriverAgent-aghlrsejdreqngftgvcqwnjgrbou -destination id=DFBB176D-22E6-42B3-B6BD-5B2C84F6ECB7 IPHONEOS_DEPLOYMENT_TARGET=15.0 GCC_TREAT_WARNINGS_AS_ERRORS=0 COMPILER_INDEX_STORE_ENABLE=NO' in directory '/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-webdriveragent'

I noticed you used Appium 1.22.3 embedded in Appium Desktop 1.22.3, which is not Appium 2 and newer Appium XCUITest driver. Our Appium inspector means https://github.com/appium/appium-inspector

Haochenyu2021

Haochenyu2021 commented on Feb 26, 2023

@Haochenyu2021

I meant xcodebuild with the below command directly.

[debug] �[35m[WebDriverAgent]�[39m Beginning test with command 'xcodebuild build-for-testing test-without-building -project /Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -derivedDataPath /Users/emily/Library/Developer/Xcode/DerivedData/WebDriverAgent-aghlrsejdreqngftgvcqwnjgrbou -destination id=DFBB176D-22E6-42B3-B6BD-5B2C84F6ECB7 IPHONEOS_DEPLOYMENT_TARGET=15.0 GCC_TREAT_WARNINGS_AS_ERRORS=0 COMPILER_INDEX_STORE_ENABLE=NO' in directory '/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-webdriveragent'

I noticed you used Appium 1.22.3 embedded in Appium Desktop 1.22.3, which is not Appium 2 and newer Appium XCUITest driver. Our Appium inspector means https://github.com/appium/appium-inspector

hi @KazuCocoa sorry for the version number - The correct ones should be:
Appium Server GUI 1.22.3 & Appium Inspector 2023.2.1

KazuCocoa

KazuCocoa commented on Feb 27, 2023

@KazuCocoa
MemberAuthor

Then, could you try out Appium 2.0 with latest appium-xcuitest-driver?

Haochenyu2021

Haochenyu2021 commented on Feb 27, 2023

@Haochenyu2021

Then, could you try out Appium 2.0 with latest appium-xcuitest-driver?

Hi @KazuCocoa - I'm using the latest appium-xcuitest-driver, which is 4.18.1

KazuCocoa

KazuCocoa commented on Feb 27, 2023

@KazuCocoa
MemberAuthor

Then, could you share the version's xcodebuild command result?

Haochenyu2021

Haochenyu2021 commented on Feb 27, 2023

@Haochenyu2021

Then, could you share the version's xcodebuild command result?

I found I got an error of WebDriverAgentRunner-Runner.app
System: The bundle identifier for WebDriverAgentRunner-Runner.app couldn't be read
image
But I have successfully built WebDriverAgentLib, WebDriverAgentRunner, and IntegrationApp onto simulator from xcode

And another thing is my Appium folder is under usr\local\lib\node_modules
But appium drivers are under user\username.appium\node_modules
Does this matter?

KazuCocoa

KazuCocoa commented on Feb 27, 2023

@KazuCocoa
MemberAuthor

The drivers' path was expected. https://appium.github.io/appium/docs/en/2.0/guides/migrating-1-to-2/

Did you try out xcodebuild command the same as Appium 2 issued like below? (The below's one was what you shared before. In appium 2 appium log also may have the same xcodebuild build-for-testing test-without-building ... command result. I meant the entire build result.

xcodebuild build-for-testing test-without-building -project /Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -derivedDataPath /Users/emily/Library/Developer/Xcode/DerivedData/WebDriverAgent-aghlrsejdreqngftgvcqwnjgrbou -destination id=DFBB176D-22E6-42B3-B6BD-5B2C84F6ECB7 IPHONEOS_DEPLOYMENT_TARGET=15.0 GCC_TREAT_WARNINGS_AS_ERRORS=0 COMPILER_INDEX_STORE_ENABLE=NO' in directory '/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-webdriveragent

dduphorn

dduphorn commented on May 4, 2023

@dduphorn

I got the message 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

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

Then I got the error /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/XCTAutomationSupport.framework/XCTAutomationSupport for architecture arm64

I removed the XCTAutomationSupport Linked Binary and now I"m getting the error

Undefined symbol: OBJC_CLASS$_XCAccessibilityElement
Undefined symbol: OBJC_CLASS$_XCDeviceEvent
Undefined symbol: OBJC_CLASS$_XCElementSnapshot
Linker command failed with exit code 1 (use -v to see invocation)

My linked Binary does include XCTest.frameworks.

Any idea what I'm missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    XCUITestregarding xcuitest driver

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jagdish24@jlipps@JeremyCaltranz@KazuCocoa@bwomsm1

        Issue actions

          Xcode 14 beta 3: Failed to build WDA as XCTAutomationSupport.framework/XCTAutomationSupport linking failure · Issue #17174 · appium/appium