Skip to content

Appium - iOS - Building using debug-mode is not supported #120789

Closed

Description

@marceloadsj

Hello everyone. 1st of all, thx for your great work on this project! :)

Trying to use iOS and Appium

Following a research of using iOS, Appium and specific APIs like getRenderObjectDiagnostics I faced some issues that blocked me.

Appium cannot use debug-mode iOS builds

On this ticket: #73935
We see that Appium cannot start an iOS application that was build using debug mode.

Do we have a way to launch a debug-mode iOS build via flutter cli or something of those sorts?

image

A possible solution is to use profile-mode

While researching on Appium Flutter Driver, I found: appium/appium-flutter-driver#115
Which describes that the solution right now is to build the iOS app in profile mode in order to use Appium.

By using profile-mode iOS builds, some APIs are unavailable

But by doing that, we lose the possibility to use the API I mentioned: #70772


I opened this issue following @Hixie comment here: #70772 (comment)

PS: Please, if a solution is 100% achievable from userland, let me know and feel free to close off this issue!

Activity

  1. darshankawar commented on Feb 16, 2023

    @darshankawar
    Member

    @marceloadsj
    Please check this link and this to see if it helps in your case.

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Feb 16, 2023
  3. marceloadsj commented on Feb 16, 2023

    @marceloadsj
    Author

    Hello @darshankawar thanks for your reply.

    Well, I did good info on those links related to "other options" of integration testing on Flutter apps.

    But regarding the core issue, I couldn't find anything.

    Just to be in sync, the root problem is **an iOS Flutter app built in debug-mode cannot run externally, without being from Flutter cli".

    From there I had 2 options

    1. check exactly why the app can't run, and see if, on Appium, I can make the debug-mode app to run via flutter cli. This would became an Appium concern, thus this issue could be closed

    2. or, forget about debug-mode and use profile-mode. But this creates a new problem: some APIs are not available in this mode. So, here the question is: is there a way to keep them in place? (APIs like getRenderObjectDiagnostics)

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Feb 16, 2023
  5. darshankawar commented on Feb 17, 2023

    @darshankawar
    Member

    Thanks for the feedback.

    2. forget about debug-mode and use profile-mode. But this creates a new problem: some APIs are not available in this mode. So, here the question is: is there a way to keep them in place? (APIs like getRenderObjectDiagnostics)

    #70772 would be the right link to follow-up on for this scenario.

    1. check exactly why the app can't run, and see if, on Appium, I can make the debug-mode app to run via flutter cli. This would became an Appium concern, thus this issue could be closed

    I am not sure how Flutter would fix anything for this scenario, since it seems to be requirement from iOS level itself as it can't be open in debug mode for iOS 14+, so I think the change should probably made at Appium level to support it.

    Based on above, I will go ahead and close it as I don't think this would be actionable from Flutter side. If you disagree, write in comments and I'll reopen it.

  6. added
    r: duplicateIssue is closed as a duplicate of an existing issue
    and removed
    in triagePresently being triaged by the triage team
    on Feb 17, 2023
  7. marceloadsj commented on Feb 17, 2023

    @marceloadsj
    Author

    @darshankawar regarding:

    since it seems to be requirement from iOS level itself as it can't be open in debug mode for iOS 14+

    Do you have, please, any document from iOS, from Flutter or any "code", that explains what exactly is that requirement?

  8. marceloadsj commented on Mar 1, 2023

    @marceloadsj
    Author

    Any input from @Hixie side here, please?

    I'm tagging you as you asked for us to open an issue to discuss this behaviour.
    #70772

    Thanks!

  9. Hixie commented on Mar 1, 2023

    @Hixie
    Contributor

    Yeah this might actually be a bug that has to be filed with Appium rather than Flutter, but let's reopen this while we figure out exactly where the fix would have to happen.

  10. reopened this on Mar 1, 2023
  11. added
    a: tests"flutter test", flutter_test, or one of our tests
    platform-iosiOS applications specifically
    P2Important issues not at the top of the work list
    and removed
    r: duplicateIssue is closed as a duplicate of an existing issue
    on Mar 1, 2023
  12. jmagman commented on Mar 1, 2023

    @jmagman
    Member

    The limitation is that on iOS 14+ any JIT app (Flutter iOS debug mode) needs to be launched by a debugger either from lldb or Xcode. See:
    #60657
    #62518
    flutter-team-archive/engine#20980

    When you flutter run or run from a Flutter IDE plugin, the app is built under the covers with xcodebuild, then the .app bundle is being installed and launched via an lldb debugserver session by a tool called ios-deploy which is shipped in the flutter SDK at bin/cache/artifacts/ios-deploy/ios-deploy. Appium, or any tooling, could do the same and use ios-deploy to launch the app with the debugger. See https://github.com/ios-control/ios-deploy#examples or run bin/cache/artifacts/ios-deploy/ios-deploy -h to see the available commands and flags (--justlaunch, etc).

    /// Installs and then runs the specified app bundle.
    ///
    /// Uses ios-deploy and returns the exit code.
    Future<int> launchApp({
    required String deviceId,
    required String bundlePath,
    required List<String> launchArguments,
    required IOSDeviceConnectionInterface interfaceType,
    required bool uninstallFirst,
    Directory? appDeltaDirectory,
    }) async {
    appDeltaDirectory?.createSync(recursive: true);
    final List<String> launchCommand = <String>[
    _binaryPath,
    '--id',
    deviceId,
    '--bundle',
    bundlePath,
    if (appDeltaDirectory != null) ...<String>[
    '--app_deltas',
    appDeltaDirectory.path,
    ],
    if (interfaceType != IOSDeviceConnectionInterface.network)
    '--no-wifi',
    if (uninstallFirst)
    '--uninstall',
    '--justlaunch',
    if (launchArguments.isNotEmpty) ...<String>[
    '--args',
    launchArguments.join(' '),
    ],
    ];

    /// Returns [IOSDeployDebugger] wrapping attached debugger logic.
    ///
    /// This method does not install the app. Call [IOSDeployDebugger.launchAndAttach()]
    /// to install and attach the debugger to the specified app bundle.
    IOSDeployDebugger prepareDebuggerForLaunch({
    required String deviceId,
    required String bundlePath,
    required List<String> launchArguments,
    required IOSDeviceConnectionInterface interfaceType,
    Directory? appDeltaDirectory,
    required bool uninstallFirst,
    }) {
    appDeltaDirectory?.createSync(recursive: true);
    // Interactive debug session to support sending the lldb detach command.
    final List<String> launchCommand = <String>[
    'script',
    '-t',
    '0',
    '/dev/null',
    _binaryPath,
    '--id',
    deviceId,
    '--bundle',
    bundlePath,
    if (appDeltaDirectory != null) ...<String>[
    '--app_deltas',
    appDeltaDirectory.path,
    ],
    if (uninstallFirst)
    '--uninstall',
    '--debug',
    if (interfaceType != IOSDeviceConnectionInterface.network)
    '--no-wifi',
    if (launchArguments.isNotEmpty) ...<String>[
    '--args',
    launchArguments.join(' '),
    ],
    ];
    return IOSDeployDebugger(
    launchCommand: launchCommand,
    logger: _logger,
    processUtils: _processUtils,
    iosDeployEnv: iosDeployEnv,
    );
    }

    This is the workaround Flutter tooling uses for the iOS 14+ limitation of running a JIT app on iOS, so Appium should be able to do the same.

    Does that answer your question?

  13. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 1, 2023
  14. marceloadsj commented on Mar 14, 2023

    @marceloadsj
    Author

    Thanks a lot everyone for your detailed explanation, I really appreciate it! <3

    I believe Appium (and any other userland tooling) can use the info provided by @jmagman to be able to launch Flutter apps in debug mode.

    I will close this issue and continue the discussion on Appium side. Thanks again! :)

  15. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 14, 2023
  16. github-actions commented on Mar 28, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  17. locked as resolved and limited conversation to collaborators on Mar 28, 2023
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

    P2Important issues not at the top of the work lista: tests"flutter test", flutter_test, or one of our testsplatform-iosiOS applications specificallyr: solvedIssue is closed as solved

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions