Docker-OSX icon indicating copy to clipboard operation
Docker-OSX copied to clipboard

Recognising iPhone device connected to USB

Open osmooth opened this issue 5 years ago • 44 comments
trafficstars

USB devices are not recognised, a major part of my work requires iPhone connected to device and use it for side loading apps. So I've opened this issue. We are running Qemu inside docker for me "-privileged -v /dev/bus/usb:/dev/bus/usb" didn't work...

osmooth avatar Jun 12 '20 09:06 osmooth

Yes I am aware of this issue.

If you have a developer cert you can SCP/rsync/sftp the signed ipa back to an nginx server or something and install over the air using manifest.plist.

You can pass the usb iPhone thru but what I’ve noticed is it seems to reject the iPhone until the passcode is entered. Correct me if I’m wrong but there’s a small race to enter the trust this device pin.

You may be on the right track, check out this comment https://sick.codes/how-to-install-macos-virtual-machine-on-linux-arch-manjaro-catalina-mojave-or-high-sierra-xcode-working/#comment-41151

That is all until I add it natively which I aim to do as soon as I finish other work on my plate.

EDIT: see below!


# Linux PC
yay usbfluxd
systemctl restart usbmuxd
avahi-daemon
usbfluxd -f -n
socat tcp-listen:5000,fork unix-connect:/var/run/usbmuxd

# MAC
# get homebrew
brew install make autoheader automake autoconf libtool pkg-config gcc libimobiledevice
# clone & make corellium/usbfluxd
usbfluxd -f -r 192.168.1.X:5000

sickcodes avatar Jun 12 '20 10:06 sickcodes

Tbh I think this should be worked on as a priority. Let’s face it, most people that want to use macOS want to use it simply for Xcode and to sideload.

peterandrewd avatar Jun 14 '20 18:06 peterandrewd

would be a great set of instructions....except there is no OSX-KVM folder in home/user...

peterandrewd avatar Jun 14 '20 19:06 peterandrewd

Misclicked, will work on this one! It’s doable with the new arguments. Taking a break until mid-week.

sickcodes avatar Jun 14 '20 21:06 sickcodes

Well well after a lot of tinkering I figured out a way to mount USB devices in QEMU (not virt(shit) manager) WITHOUT having to create a new container each time and it’s not just for 1 time use only. You can disconnect it, replug it and still access it. I tested it with 2 different USB drives.

As you can see in the screenshots, the USB drives show up. Still can’t get iPhone mounted though but at least USB drives mount easily now.

image

image

peterandrewd avatar Jun 16 '20 20:06 peterandrewd

That’s also where I got stuck @peterandrewd I can mount it but it doesn’t seem to pass through. However, I can pass it through on VirtualBox windows and sideload apps in Windows. Have you tried the method I described at the start?

You don’t need to connect the USB you can sign it and then install OTA

https://dantheman827.github.io/ios-app-signer/

Sign with that

Then put your IPA on any SSL domain and do an OTA install manifest.plist

https://gist.github.com/hramos/774468

<a href="itms-services://?action=download-manifest&url=https://your.domain.com/your-app/manifest.plist">Awesome App</a>

If you don’t have an SSL domain use this https://github.com/bumaociyuan/ios-ipa-server

sickcodes avatar Jun 16 '20 21:06 sickcodes

That’s also where I got stuck @peterandrewd

I can mount it but it doesn’t seem to pass through. However, I can pass it through on VirtualBox windows and sideload apps in Windows.

Have you tried the method I described at the start?

You don’t need to connect the USB you can sign it and then install OTA

https://dantheman827.github.io/ios-app-signer/

Sign with that

Then put your IPA on any SSL domain and do an OTA install manifest.plist

https://gist.github.com/hramos/774468

<a href="itms-services://?action=download-manifest&url=https://your.domain.com/your-app/manifest.plist">Awesome App</a>

If you don’t have an SSL domain use this https://github.com/bumaociyuan/ios-ipa-server

Ok so I can create a Windows VM and sideload apps that way? How do you sideload using Windows without Xcode? Or are you saying you have a MacOS VM in Windows?

I had tried the OTA method but it seemed too complicated and didn’t work. I got stuck. I’ll try again though but I would appreciate to be guided through it step by step if I get stuck.

peterandrewd avatar Jun 16 '20 21:06 peterandrewd

Ahhh my iPhone doesn't let me enable full trust certificates in settings. There is no option for it.

--EDIT-- nvm I THINK I got it working. Just have a question. I used the ios ipa server git instructions, and was able to sign and then sideload apps without creating a manifest file as outlined in your first step. So what's the manifest file for if I can sideload using the ios ipa server method? And did I miss something?

peterandrewd avatar Jun 16 '20 22:06 peterandrewd

Oh nice, how’d you side load it? Drag into iTunes?

sickcodes avatar Jun 16 '20 22:06 sickcodes

So the Chinese repo skipped everything?? If so that awesome 😂

sickcodes avatar Jun 16 '20 22:06 sickcodes

Oh nice, how’d you side load it? Drag into iTunes?

No. I didn’t use anything but iOS app signer. I just logged into the server ip:port it created on my phones browser and selected the apps to install...? I guess you can try it yourself and verify that it works and that I’m not making any mistake.

peterandrewd avatar Jun 16 '20 22:06 peterandrewd

Was I right? lol

peterandrewd avatar Jun 17 '20 02:06 peterandrewd

Was I right? lol

Once again

peterandrewd avatar Jun 17 '20 11:06 peterandrewd

😂 I really liked that repo. It looks like a 1 click signer! I should take some of their code and implement it in this one for a full CI/CD solution.

sickcodes avatar Jun 18 '20 10:06 sickcodes

Sounds good to me. Or update the repo. Cos it doesn’t like look it’s still maintained

peterandrewd avatar Jun 18 '20 11:06 peterandrewd

Good idea

sickcodes avatar Jun 18 '20 12:06 sickcodes

Im full of good ideas

peterandrewd avatar Jun 18 '20 12:06 peterandrewd

Docker rhymes with Coc*er

peterandrewd avatar Jun 22 '20 18:06 peterandrewd

Seems like on solution is to do it like this https://www.reddit.com/r/hackintosh/comments/f31wx0/macos_on_kvm_and_xcode_and_iphone_usb_passthrough/

Sad thing I have only one USB Controller and it is not an option for me :(

reinismu avatar Aug 11 '20 20:08 reinismu

Any news on how to get XCode <-> IPhone USB debugging working? Thanks!

VitaminCpp avatar Sep 11 '20 12:09 VitaminCpp

I'm pretty sure it can do done.

However, I just add my UDID to my developer account, use https://dantheman827.github.io/ios-app-signer/ and then make a manifest plist and I'm good to go.

This looks like it's the correct answer https://www.reddit.com/r/hackintosh/comments/f31wx0/macos_on_kvm_and_xcode_and_iphone_usb_passthrough/

sickcodes avatar Sep 11 '20 13:09 sickcodes

It can be done, checkra1n can do it https://downthecrop.xyz/blog/checkra1n-on-pc-linux-via-qemu-macos-virtualization/

sickcodes avatar Sep 11 '20 14:09 sickcodes

UDID to my

Yeah, but this way you only can deploy to your IPhone but not debug your app. Am i correct?

VitaminCpp avatar Sep 11 '20 14:09 VitaminCpp

It can be done, checkra1n can do it https://downthecrop.xyz/blog/checkra1n-on-pc-linux-via-qemu-macos-virtualization/

This sounds interesting! Thanks for that hint. I'll have a look onto it. ;-)

VitaminCpp avatar Sep 11 '20 14:09 VitaminCpp

Seems like on solution is to do it like this https://www.reddit.com/r/hackintosh/comments/f31wx0/macos_on_kvm_and_xcode_and_iphone_usb_passthrough/

Sad thing I have only one USB Controller and it is not an option for me :(

Tried this. Used this script: https://raw.githubusercontent.com/andre-richter/vfio-pci-bind/master/vfio-pci-bind.sh and intel_iommu=yes, but getting this error when starting the container 😢:

usb_desc_get_descriptor: 1 unknown type 33 (len 10)
qemu-system-x86_64: -device vfio-pci,host=00:14.0: VFIO_MAP_DMA failed: Cannot allocate memory
qemu-system-x86_64: -device vfio-pci,host=00:14.0: vfio 0000:00:14.0: failed to setup container for group 5: memory listener initialization failed: Region pc.ram: vfio_dma_map(0x558158033810, 0x0, 0xa0000, 0x7f3eb2600000) = -12 (Cannot allocate memory)

mikob avatar Feb 21 '21 22:02 mikob

Seems like on solution is to do it like this https://www.reddit.com/r/hackintosh/comments/f31wx0/macos_on_kvm_and_xcode_and_iphone_usb_passthrough/ Sad thing I have only one USB Controller and it is not an option for me :(

Tried this. Used this script: https://raw.githubusercontent.com/andre-richter/vfio-pci-bind/master/vfio-pci-bind.sh and intel_iommu=yes, but getting this error when starting the container cry:

usb_desc_get_descriptor: 1 unknown type 33 (len 10)
qemu-system-x86_64: -device vfio-pci,host=00:14.0: VFIO_MAP_DMA failed: Cannot allocate memory
qemu-system-x86_64: -device vfio-pci,host=00:14.0: vfio 0000:00:14.0: failed to setup container for group 5: memory listener initialization failed: Region pc.ram: vfio_dma_map(0x558158033810, 0x0, 0xa0000, 0x7f3eb2600000) = -12 (Cannot allocate memory)

I think I had the same issue and I solved it with setting soft/hard memlock to -1

example:

version: '3.4'

services:
  osx:
    container_name: docker-osx
    image: sickcodes/docker-osx
    privileged: true
    network_mode: "host"
    environment:
      - DISPLAY=${DISPLAY:-:0.0}
      - RAM=8
      # - EXTRA=-device usb-host,hostbus=0x001,hostaddr=0xB # Pass left usb
      # - EXTRA=-device usb-host,vendorid=0x05ac,productid=0x12a8,guest-reset=false # Pass iPhone
      # - EXTRA=-device usb-ehci,id=ehci -device usb-host,bus=ehci.0,vendorid=0x05ac,productid=0x12a8,guest-reset=false
      # - EXTRA=-device ich9-usb-ehci1,id=ehci -device usb-host,bus=ehci.0,vendorid=0x05ac,productid=0x12a8,guest-reset=false
      # - EXTRA=-usb -device usb-host,hostbus=0x1,hostport=0x1,guest-reset=false
      # - EXTRA=-device ich9-usb-ehci1,id=usb,bus=pcie.0,addr=0x7.0x7
      # - EXTRA=-device usb-ehci,id=ehci -device usb-host,bus=ehci.0,hostbus=0x1,hostport=0x1,guest-reset=false
      # - EXTRA=-device vfio-pci,host=0c:00.3 
    # network_mode: "host"
    ports:
      # <Port exposed> : < MySQL Port running inside container>
      - '10022:10022'
    expose:
      # Opens port 3306 on the container
      - '10022'
    ulimits:
      memlock:
        soft: -1
        hard: -1
      
    cap_add:
      - ALL
    volumes:
      - /tmp/.X11-unix:/tmp/.X11-unix
      - docker-osx_data2:/home
    # entrypoint:
    #   - ./boot-macOS-Catalina.sh

volumes:
  docker-osx_data2:
    name: docker-osx_data

It could be you need to set it on your main machine as well. Can't remember, but if everything with IOMMU groups are correct then that is next thing to look at

reinismu avatar Feb 21 '21 22:02 reinismu

Great notes @mikob & @reinismu, I'll try adding the iPhone passthrough from your links & code. Aiming for seamlessly using an environment variable. Just fixing up iMessage as we speak!

sickcodes avatar Feb 23 '21 07:02 sickcodes

  # - EXTRA=-device usb-host,hostbus=0x001,hostaddr=0xB # Pass left usb
  # - EXTRA=-device usb-host,vendorid=0x05ac,productid=0x12a8,guest-reset=false # Pass iPhone
  # - EXTRA=-device usb-ehci,id=ehci -device usb-host,bus=ehci.0,vendorid=0x05ac,productid=0x12a8,guest-reset=false
  # - EXTRA=-device ich9-usb-ehci1,id=ehci -device usb-host,bus=ehci.0,vendorid=0x05ac,productid=0x12a8,guest-reset=false
  # - EXTRA=-usb -device usb-host,hostbus=0x1,hostport=0x1,guest-reset=false
  # - EXTRA=-device ich9-usb-ehci1,id=usb,bus=pcie.0,addr=0x7.0x7
  # - EXTRA=-device usb-ehci,id=ehci -device usb-host,bus=ehci.0,hostbus=0x1,hostport=0x1,guest-reset=false
  # - EXTRA=-device vfio-pci,host=0c:00.3

@reinismu, @sickcodes btw, I can only get this working by binding my single usb controller to vfio (which means I lose connection to all my peripherals on the host, including bluetooth which goes through that usb controller) I use the last line you have there commented out -device vfio-pci,host=00:14.0

Do any of these other lines you have commented out work? Curious why they are there. Is it possible to pass a single USB port and not the whole pci controller? So I can retain usage of some peripherals on the host? I tried the README's passthrough method but that didn't work.

mikob avatar May 18 '21 02:05 mikob

@mikob That was just my testing stuff. I can get it to work only that way as well. (Binding usb to vfio)

reinismu avatar May 18 '21 14:05 reinismu

iPhone passthrough has been solved here: https://github.com/sickcodes/Docker-OSX/issues/133#issuecomment-836855901

I am yet to try it but it is confirmed working.

sickcodes avatar May 21 '21 09:05 sickcodes