我正在开发一个shell脚本,它直接构建并安装我们的xcodeproj到第一个找到并连接的iDevice。这是脚本
#!/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
除了在我的iPhone上安装外,一切正常。我得到了正确的设备名称,看起来好像找到了设备,但我在iPhone上看不到应用程序。奇怪的是,如果我从xCode安装它,一切都运行良好。
有谁知道如何解决这个问题?
答案 0 :(得分:0)
我使用以下命令在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
如果您想在另一台模拟器中运行,请尝试使用以下命令查看可用的模拟器:
xcrun instruments -s