npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

appium-ios-device

v2.7.24

Published

Appium API for dealing with iOS devices

Downloads

1,101,374

Readme

appium-ios-device

NPM version Downloads

Release

Appium API for dealing with iOS devices. This is mainly a rewrite of libimobiledevice in Node.js. The APIs allow Appium to talk directly to the phone over usbmuxd.

More information can be found at the links below:

Note This module is used and tested by appium-xcuitest-driver, which expects macOS as the host paltform with Xcode. Some features may only work partially on other platforms.

Usage

This module should be used over the utilities and services modules or exported classes in documents due to the complexity of iOS communication. When a new services is implemented, it should be added and made available over the services module.

Methods

  • utilities.getConnectedDevices
  • utilities.getOSVersion
  • utilities.getDeviceTime
  • utilities.getDeviceName
  • utilities.getDeviceInfo
  • utilities.startLockdownSession
  • utilities.connectPort
  • utilities.connectPortSSL
  • utilities.fetchImageFromGithubRepo
  • services.startSyslogService
  • services.startWebInspectorService
  • services.startInstallationProxyService
  • services.startSimulateLocationService
  • services.startAfcService
  • services.startNotificationProxyService
  • services.startHouseArrestService
  • services.startInstrumentService
  • services.startTestmanagerdService
  • services.startMCInstallService
  • services.startImageMounterService

Classes

  • Xctest
    • Allows invoking pre-installed xctest app from iOS devices. No Xcode installation is required. This class simulates the procedure which Xcode uses to invoke xctests.
    • new Xctest(udid, xctestBundleId, targetBundleId, opts)
      • udid - string Device udid.
      • xctestBundleId - string - Bundle Id of xctest app on device. The app must be installed on device.
      • targetBundleId - string - Test target bundle id. null by default.
      • opts - optional addition options to specific XCTestConfiguration and app launch env.
        • conf - properties to override in XCTestConfiguration.
          • productModuleName - string | null
          • targetApplicationArguments - string[] | null
          • testsToRun - string[] | null
          • testsToSkip - string[] | null
        • env - object - key-value pairs to append in xctest app environment
    • xctest.start()
      • Start xctest process. If this method has been called before and the stop() method has not been called, calling this again would return directly.
      • Throws: If xctest bundle id invalid or not installed.
    • xctest.stop()
      • Stop xctest process.

Mount Developer Image

When using a higher version of iOS devices with a lower version of Xcode or other non-macOS operating systems, most of the functions in services or Xctest may not be available because the developer image is not mounted. Sometimes it can be solved automatically by opening Xcode and waiting for a while. But more often you need to manually download and mount the developer image as follows:

  1. Download .dmg file with new Xcode(sometimes beta version is needed) from Apple Developer Downloads Page.
  2. Unarchive new Xcode from .dmg file without replacing old one.
  3. Find the folder named after the target iOS version in (New Xcode.app)/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport. A DeveloperDiskImage.dmg and a DeveloperDiskImage.dmg.signature should be inside that folder.
  4. Copy the folder you found from last step and paste to (Old Xcode.app)/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport.
  5. The operations in the above two steps are also applicable to platforms other than the iPhone. e.g. the folder for tvOS is (Xcode.app)/Contents/Developer/Platforms/AppleTVOS.platform/DeviceSupport.
  6. Restart your old Xcode and reconnect your devices, wait for a while until the "preparing device for development" prompt disappears.
  7. You can also mount this image using ideviceimagemounter binary file compiled by libimobiledevice project on your operating system.

These operations are very cumbersome. Fortunately there are many repositories of these developer images in the open source community. The folders mentioned in the above process are zipped and uploaded into open source repositories according to different versions. You can also make your own mirror repository on GitHub in a similar way. With services.startImageMounterService and utilities.fetchImageFromGithubRepo, you can automate the whole process cross-platform.

As an example, assuming we are using a repo from https://github/example/iOSDeviceSupport. All the .zip files are inside DeviceSupportFiles/iOS folder of root. We can check the mount status, download and mount the image using following code:

import { services, utilities } from 'appium-ios-device';
import _ from 'lodash';
const { startImageMounterService } = services;
...
async function checkAndMountDeveloperImage(udid) {
  const imageMountService = await startImageMounterService(udid);
  try {
    const mountStatus = await imageMountService.isDeveloperImageMounted();
    if (!mountStatus) {
      const { fetchImageFromGithubRepo } = utilities;
      const repoOpts = {
        githubRepo: 'example/iOSDeviceSupport',
        subFolderList: ['DeviceSupportFiles', 'iOS']
      }
      const downloadedImagePath = await fetchImageFromGithubRepo(udid, repoOpts);
      if (!_.isEmpty(downloadedImagePath)) {
        const {developerImage, developerImageSignature} = downloadedImagePath;
        await imageMountService.mount(developerImage, developerImageSignature);
      }
    }
  } catch(e) {
    // Failed to mount, do something...
  } finally {
    imageMountService.close();
  }
}

Test

npm test