Skip to content

Latest commit

 

History

History
287 lines (249 loc) · 11.3 KB

DEPLOYMENT.md

File metadata and controls

287 lines (249 loc) · 11.3 KB

Deployment

Tested working configuration

  • Built using: XCode 14.3.1 on MacOS Ventura 13.5

1. Prepare PC (build machine)

  1. Install XCode

  2. Add your developer Apple ID to XCode

    1. XCode -> XCode menu -> Preferences -> Accounts Tab
    2. Click + under Apple IDs list
    3. Choose Apple ID
    4. Login to your account
  3. Download a "Apple Development certificate" for your user

    1. Continue from previous step, right after logging into your Developer account in Xcode
    2. Select Manage Certificates
    3. Click + in the lower left corner
    4. Select Apple Development
  4. Install Homebrew

  5. Install Python 2.7 from MacPorts

    1. Install MacPorts
    2. In terminal: ports install python27

2. Prepare server STF

  1. Add in NGINX config (in STF server deployment) block configuration for new provider:
  • Client IP should be changed from [^/] to some more specific range such as: (?<client_ip>192.168.255.[0-9]+) to restrict it to a reasonable IP range
  • If left alone this example config will let clients arbitrarily tunnel to any IP on ports 8000-8009
# MacOS
location ~ "^/frames/(?<client_ip>[^/]+)/(?<client_port>800[0-9])/x$" {
  proxy_pass http://$client_ip:$client_port/echo/;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection $connection_upgrade;
  proxy_set_header X-Forwarded-For $remote_addr;
  proxy_set_header X-Real-IP $remote_addr;
}

3. Prepare mobile devices for work with provider

  1. Register(provision) your IOS device to your developer account as a developer device.

    1. Use the API -or-

      1. Follow https://developer.apple.com/documentation/appstoreconnectapi/creating_api_keys_for_app_store_connect_api to create an app store connect API key. Give it Developer access.
      2. Gain a session using JSON Web Tokens
      3. Create a provisioning profile if none exist using profiles: https://developer.apple.com/documentation/appstoreconnectapi/profiles See also https://github.com/cidertool/asc-go/blob/f08b8151f7fd92ff54924480338dafbf8a383255/asc/provisioning_profiles.go
      4. Post to the devices endpoint to register a device: https://developer.apple.com/documentation/appstoreconnectapi/devices See also https://github.com/cidertool/asc-go/blob/f08b8151f7fd92ff54924480338dafbf8a383255/asc/provisioning_devices.go
    2. Follow these instructions: https://www.telerik.com/blogs/how-to-add-ios-devices-to-your-developer-profile I couldn't find updated instructions on Apple's website. If you find them please let me know so I can link to them.

  2. Plug in your IOS device to PC

  3. Accept pairing on IOS device screen

  4. Access device on PC:

    1. Open Finder
    2. Click to device
    3. Accept pairing to device
  5. Have Xcode setup the "developer image" on your IOS device:

    1. Open Xcode
    2. Go to Windows... Devices and Simulators
    3. Wait while Developer Image is installed to your phone
  6. Download actual profiles for device by Xcode or TestFlight: https://docs.fastlane.tools/actions/sigh/

4. Prepare dependencies on build machine

  1. Run ./init.sh
  2. View error:
mobiledevice        => version 2.0.0
libplist - Installing HEAD
Running `brew update --auto-update`...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
 
You have 32 outdated formulae installed.
You can upgrade them with brew upgrade
or list them with brew outdated.
 
Cloning into '/Users/emb/Library/Caches/Homebrew/libplist--git'...
Already on 'master'
/usr/local/lib/pkgconfig/libplist.pc was missing; creating symlink to /usr/local/Cellar/libplist/HEAD-c3af449/lib/pkgconfig//libplist-2.0.pc
ln: /usr/local/lib/pkgconfig/libplist.pc: File exists
libusbmuxd - Installing HEAD
Already on 'master'
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels.
Could not fix pkgconfig for libusbmuxd; could not locate installed pc file in Cellar
  1. Need manual install needed libs, run: brew install --HEAD libusbmuxd
  2. And view new error:
==> Cloning https://github.com/libimobiledevice/libusbmuxd.git
Cloning into '/Users/emb/Library/Caches/Homebrew/libusbmuxd--git'...
==> Checking out branch master
Already on 'master'
Your branch is up to date with 'origin/master'.
==> ./autogen.sh
Last 15 lines from /Users/emb/Library/Logs/Homebrew/libusbmuxd/01.autogen.sh:
checking whether to build static libraries... yes
checking for pkg-config... /usr/local/Homebrew/Library/Homebrew/shims/mac/super/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for libplist-2.0 >= 2.2.0... yes
checking for libimobiledevice-glue-1.0 >= 1.0.0... no
configure: error: Package requirements (libimobiledevice-glue-1.0 >= 1.0.0) were not met:
 
No package 'libimobiledevice-glue-1.0' found
 
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
 
Alternatively, you may set the environment variables limd_glue_CFLAGS
and limd_glue_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
 
Do not report this issue to Homebrew/brew or Homebrew/core!
 
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels.

This error initial by new dependenses: https://github.com/libimobiledevice/libimobiledevice-glue

  1. Resolve:

    1. brew create --set-name libimobiledevice-glue-1.0 "https://github.com/libimobiledevice/libimobiledevice-glue.git"
    2. Save file without changes
    3. Edit file: brew edit libimobiledevice-glue-1.0

    It text needed:

    class LibimobiledeviceGlue10 < Formula
      desc ""
      homepage ""
      url "https://github.com/libimobiledevice/libimobiledevice-glue.git"
      head "https://github.com/libimobiledevice/libimobiledevice-glue.git"
      version "1.0.0"
      sha256 ""
      license ""
    
      depends_on "autoconf" => :build
      depends_on "automake" => :build
      depends_on "libtool" => :build
      depends_on "pkg-config" => :build
      depends_on "libplist"
    
      def install
        system "./autogen.sh"
        system "./configure", "--disable-dependency-tracking", "--disable-silent-rules", "--prefix=#{prefix}"
        system "make", "install"
      end
    
      test do
        system "false"
      end
    end
    
    1. Install library: HOMEBREW_NO_INSTALL_FROM_API=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install --HEAD libimobiledevice-glue-1.0
    2. Manual fix symlinks:
    ./util/brewser.pl fixpc libimobiledevice-glue-1.0 1.0.0
    
    cd /usr/local/lib/pkgconfig/
    rm libimobiledevice-glue-1.0.pc libimobiledevice-glue-1.0-1.0.0.pc
    ln -s ../../Cellar/libimobiledevice-glue-1.0/HEAD-<HASH>/lib/pkgconfig/libimobiledevice-glue-1.0.pc libimobiledevice-glue-1.0.pc
    ln -s ../../Cellar/libimobiledevice-glue-1.0/HEAD-<HASH>/lib/pkgconfig/libimobiledevice-glue-1.0.pc libimobiledevice-glue-1.0-1.0.0.pc
    ls -al libimobiledevice-glue-1.0*
    1. Fix env: export PKG_CONFIG_PATH=$(find /usr/local/Cellar -name 'pkgconfig' -type d | grep lib/pkgconfig | tr '\n' ':' | sed s/.$//)
    2. Fix formulae: brew edit libusbmuxd
    3. Add in file new dependens:
    depends_on "libimobiledevice-glue-1.0"
    
    1. Save file
    2. Install libs:
    HOMEBREW_NO_INSTALL_FROM_API=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install --HEAD libusbmuxd
    HOMEBREW_NO_INSTALL_FROM_API=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install --HEAD libimobiledevice
    ./util/brewser.pl fixpc libusbmuxd 2.0
    ./util/brewser.pl fixpc libimobiledevice 1.0

5. Prepare sources

  1. Clone the various needed repos

    1. Run make clone
  2. Configure WebDriverAgent to use your identity for signing

    1. Open repos/WebDriverAgent/WebDriverAgent.xcodeproj in XCode
    2. Select the WebDriverAgentLib target
    3. Go to the Signing & Capabilities tab
    4. Select your team under Team
    5. Change Bundle Identifier to your
    6. Repeate this action for WebDriverAgentRunner, UnitTests, IntegrationTests_[1:3] and IntegrationApps
    7. Select in top target for builder: WebDriverAgentRunner
    8. Select in top physical device for builder
    9. Test build and run test: select in XCode menu Product and Test
    10. In log chech what start server and success
    11. Close XCode
  3. Create config:

    1. Copy the first {} block from config.json.example into config.json. Do not include any comment lines starting with //
    2. Edit config.json
      1. Update xcode_dev_team_id to be the OU of your developer account. If you add your account into Xcode first, you can then run make ou to display what the OU is. You can also find it by opening the keychain, selecting the Apple Development certificate for your account, and then looking at what the Organization Unit is.
      2. Update root_path to be where provider code should be installed, such as /Users/user/stf
      3. Update config_path to match that, such as /Users/user/stf/config.json
      4. Set use_vnc to false (https://githubhelp.com/devicefarmer/stf_ios_support/issues/37)
    3. Sample:
    {
      "xcode_dev_team_id": "XXXXXXXXX",
      "stf": {
        "ip": "192.168.1.10",
        "hostname": "stf.example.com"
      },
      "video": {
        "enabled": true,
        "use_vnc": false,
        "vnc_scale": 2,
        "vnc_password": "",
        "frame_rate": 10
      },
      "install": {
        "root_path": "/Users/user/stf",
        "config_path": "/Users/user/stf/config.json",
        "set_working_dir": false
      },
      "bin_paths": {
        "video_enabler": "bin/video_enabler"
      }
    }

6. Build and package application

  1. Fix env before build:
export PKG_CONFIG_PATH=$(find /usr/local/Cellar -name 'pkgconfig' -type d | grep lib/pkgconfig | tr '\n' ':' | sed s/.$//)
  1. Fix error repos wdaproxy:
cd repos/wdaproxy
go get github.com/DHowett/[email protected]
go install github.com/DHowett/[email protected]
go mod tidy
  1. Build: make

  2. Run then

    1. dist.tgz will be created

7. Deploy provider setup:

  1. Copy dist.tgz from build machine
  2. Run tar -xf dist.tgz
  3. Tweak config.json as desired

8. Starting provider

  1. Check plugging devices: idevice_id

  2. Pair its with your system

    1. Run idevicepair pair
    2. Accept pairing on IOS device screen
  3. Activate video by devices

    1. Activate screen devices
    2. Run QuickTime Player in GUI Mac
    3. File --> New video
    4. Choice device
    5. Check what video work
    6. Exit QuickTime Player
    7. Check what video activate on all physical devices:
    ./bin/ivf_pull list
  4. Run ./bin/ios_video_pull -devices -decimal to determine the PID ( product ID ) of your IOS device in decimal

  5. Run ./bin/devreset [decimal product ID] 1452 to reset the video streaming status of your IOS device

  6. Activate screen on all physical devices and run ./run ( and leave it running )

  7. Permissions dialog boxes appear for coordinator to listen on various ports; select accept for all of them

  8. Device shows up in STF with video and can be controlled.