Using xcodebuild to install app on iPhone

I'm working on a shell script that builds and installs our xcodeproj directly to the first iDevice found and connected. This is the script

#!/bin/bash

cd ../../cordova/platforms/ios

deviceName=$(ideviceinfo | grep -i DeviceName)
deviceName=${deviceName//DeviceName: /} #This is the device name you set in Settings->General->Info->Name on your iDevice
deviceUdid=$(system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p' -e '/iPhone/,/Serial/p' | grep "Serial Number:" | awk -F ": " '{print $2}')

if [ -n "deviceUdid" ]; then
    echo 'Found device "'${deviceName}'" with UUID "'${deviceUdid}'", process...'
    xcodeProject=$(ls | grep -i *.xcodeproj)
    if [ -n "$xcodeProject" ]; then
        echo "Is xCode project dir, start building..."
        ################### Not working command ###################
        eval "xcodebuild -scheme AppScheme -destination 'platform=iOS,id=$deviceUdid' install" #This line is not really working
        ################### Not working command ################
    else
        echo "Directory is not an xCode project directory!"
    fi
else
    echo 'It looks like there is no iDevice connected!'
fi

      

Everything works except installation on my iPhone. I am getting the correct device name, it looks like it finds the device, but I cannot see the app on my iPhone. The weird thing is that everything works well if I install it from xCode.

Does anyone know how to fix this problem?

+3


source to share


1 answer


I am using the following commands to build and run my application in the Simulator:

xcodebuild -sdk iphonesimulator8.4 -arch i386 -workspace MyApp.xcworkspace -scheme MyApp install DSTROOT=~/MyApp

xcrun instruments -w "iPhone 5s (8.4 Simulator)"
xcrun simctl install booted ~/MyApp/Applications/MyApp.app

      



if you want to run in another simulator try to see the simulators available with:

xcrun instruments -s

      

0


source







All Articles