Installation environment:

  • MacOS Mojave 10.14
  • Xcode10.1

Install libimobiledevice

I found a tutorial on the Internet

Remove all iOS devices and enter the following code on the terminal

brew uninstall ideviceinstaller
brew uninstall libimobiledevice
brew install --HEAD libimobiledevice
brew link --overwrite libimobiledevice
brew install --HEAD  ideviceinstaller
brew link --overwrite ideviceinstaller
sudo rm -rf /var/db/lockdown/*
Copy the code

Connect to an iOS device, trust it, and enter the following code

sudo chmod -R 777 /var/db/lockdown/
Copy the code

Checking mobile phone information

ideviceinfo -d
Copy the code

Check the Bundleids of all apps installed on your phone

ideviceinstaller -l
Copy the code

Actual Installation process

Have a problem

Error running brew Install –HEAD libiMobileDevice

Last 15 lines from /Users/joy/Library/Logs/Homebrew/libimobiledevice/01.autogen.sh: checking dynamic linker characteristics... Checking How to Hardcode Library Paths into Programs... immediate checking for pkg-config... Checking checking pkg-config is at least version 0.9.0... checking pkg-config is at least version 0.9.0... Yes checking for libusbmuxd >= 1.1.0... No configure: error: Package requirements (libusbmuxd >= 1.1.0) were not met: Requested 'libusbmuxd >= 1.1.0' but version of libusbmuxd is 1.0.10 Consider Adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables libusbmuxd_CFLAGS and libusbmuxd_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.Copy the code

It looks like the version of Libusbmuxd is wrong. After checking many schemes on the Internet, I found that only version 1.1.0 can be compiled and installed.

Compile the installation

There are many libraries to build and install, but since BREW Install –HEAD LibiMobileDevice automatically installs the libraries for me when I start, I don’t need to build and install them.

Compile and install libusbMuxD-1.1.0
git clone https://github.com/libimobiledevice/libusbmuxd.git
cd libusbmuxd
./autogen.sh
make
sudo make install
Copy the code
Compile and install LibiMobileDevice
git clone https://github.com/libimobiledevice/libimobiledevice.git
cd libimobiledevice
./autogen.sh
make
sudo make install
Copy the code

/autogen.sh /autogen.sh

Checking for OpenSSL >= 0.9.8... no configure: error: OpenSSL support explicitly requested but OpenSSL could not be foundCopy the code

I confirm that the openSSL version I installed is 1.0 or above, but I still report the openSSL version error. I found on the Internet that the dependent libraries could use OpenSSL or GnuTLS, so I decided to try another one.

brew install GnuTLS
Copy the code

After installing the dependency libraries, type the following code to recompile the installation

./autogen.sh --disable-openssl
Copy the code

I have a new problem:

configure: error: libgcrypt is required to build libimobiledevice with GnuTLS
Copy the code

The libgcrypt library needs to be installed

brew install libgcrypt
Copy the code

After installing, recompile installation, OK, No problem~

Compile and install the ideveceInstaller

I tried to install with HomeBrew, but found that when HomeBrew installed the IdeveceInstaller, it relied on LibiMobileDevice and automatically downloaded a stable version of libiMobileDevice, so it was better to just compile and install.

git clone https://github.com/libimobiledevice/ideviceinstaller.git
cd ideviceinstaller
./autogen.sh
make
sudo make install
Copy the code

Automated testing

Install WebDriverAgent

Install WebDriverAgent on the real machine

How to install WebDriverAgent on iOS

Download the code from GitHub

git clone https://github.com/facebook/WebDriverAgent
Copy the code

Run the initialization script

./Scripts/bootstrap.sh
Copy the code

The script downloads all dependencies using Carthage and packages the response JS files using NPM

After the execution is complete, double-click the webDriverAgent. xcodeProj file.

After setting up the Team, Profile and Signing Certificate, select Product -> Test.

If all goes well, a WebDriverAgent without ICONS appears on the phone, starts up, and immediately returns to the desktop. This is normal and don’t be surprised.

The IP address of the device is displayed on the console interface.

Synthesize a URL from the IP and port given above, plus /status. For example, http://10.0.0.1:8100/status, and then open the browser. If a string of JSON output appears, the WDA installation is successful.

And inspector http://localhost:8100/inspector, inspector is used to check the UI layer, convenient to write the test script

Use terminals instead of Xcode

In general, for continuous integration, it is better to be able to automate everything

# Unlock keychain so that normal signing applications can be performed.  PASSWORD="replace-with-your-password" security unlock-keychain -p $PASSWORD ~/Library/Keychains/login.keychain # Obtain the device UDID UDID = $(idevice_id - l | head - n1) # running test xcodebuild - project WebDriverAgent. Xcodeproj - scheme WebDriverAgentRunner -destination "id=$UDID" testCopy the code

Install Python3 wda

pip install --pre facebook-wda
Copy the code

This is where you can start writing Python scripts

The import time import wda c = wda. Client (url = 'http://169.254.16.231:8100') index = 0 def main () : Cession ('com.jifen.qukan') as s: If s(type='Button', name=u' video ').exists: if (type='Button', name=u' video ') Def pushSubVC(s): def pushSubVC(s): def pushSubVC(s): def pushSubVC(s): def pushSubVC(s): def pushSubVC(s): def pushSubVC(s): global index es = s(label='home content ext').find_elements() i = 1 for e in es: print(i) i+=1 d = es[index] rect = d.bounds x = rect.x y = rect.y index=index+1 s.click(x,y-20) time.sleep(63) if s(label='home content back white').exists: d = s(label='home content back white') d.tap() if s(type='ScrollView').exists: D = s (type = 'ScrollView) d.s croll (direction =' down ', short = 0.4) if __name__ = = "__main__ ': the main ()Copy the code

Refer to the article

Install libimobiledevice

Get the BundleID of the app installed on the phone

Potholes encountered while installing and using ideviceInstaller

Libimobiledevice installation (Mac)

Compile and install LibiMobileDevice

Automated testing

Write iOS automated tests in Python

The iOS WebDriverAgent environment is set up

IOS +Python+Appium real machine automation test combat

Python + Appium+ IOS automated testing

Build appium+ios+ Python automated test environment on MAC