Xcode command line install to device - ios

I am trying to install an app from XCode onto my device from the command line. I have tried several of the "xcodebuild" command line options which do build, clean, install, etc fine. I have also searched for various solutions.
I was able to execute this command but it just builds to a folder.
xcodebuild install -scheme "My App" -destination 'platform=iOS,id=mydeviceid'
I am able to take that folder from my hard drive and sync to the physical device using iTunes so all the build steps are being completed successfully. However, it does not "run" on the device like when Build and Run are executed in XCode.
There are some 3rd party solutions but I can't believe there isn't some native xcodebuild switch to do that. Does anyone have suggestions?
Thank you

There is no native xcodebuild switch to install to a device.
You need to fallback to third-party options:
$ brew install ideviceinstaller
ios-deploy
You can try to use Apple Configurator 2 (available in the App Store) and install the cfgutil command line tool.
.
Ignore the fact that ^ says "Uninstall Automation Tools...", if you haven't installed already, it will say "Install Automation Tools...".

Related

Flutter Doctor : Xcode installation is incomplete

I have an app created with Flutter want to build it in IOS.
When i want to run simulator or build the I get error ,When I run Flutter doctor I get this error L
Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
I was facing the same issue. I did not installed Xcode from Apple Store. If your scenario is same, you can try below steps,
Open Xcode
Go to Preferences -> Location tab
You will find "Command Line Tools" option. If it is blank, select the Xcode version from list (see image below). It will ask for password or Touchid to update it.
Run flutter doctor again. It should resolve the issue
You probably miss the xcode command line tools, you may want to reinstall XCode, or select the xcode command line tools with the command xcode-select
Here's a full fix that should solve your problem: https://github.com/flutter/flutter/issues/6308#issuecomment-257812324
So, I was facing this same issue, and tried to and copy paste the command already given. Namely
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
But why did it not work? Silly mistake of mine: I have two Xcode versions in my Applications folder. One is called Xcode_12_3_0 and the other Xcode_12_5_1. Make sure that, when you run the command, you also make sure you enter your app's real name. For instance:
sudo xcode-select -s /Applications/Xcode_12_5_1.app/Contents/Developer
An answer for us, absent-minded people.
If you already have Xcode and this happens. Just run this command
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
And
sudo xcodebuild -runFirstLaunch
It will automatically show

webdriveragentrunner iphoneos12.2-arm64.xctestrun doesn't exist

I want to automate ios app using appium.
The thing is that I am getting this error when I use appium inspector in order to open my installed application for the first time:
xcodebuild failure: "xcodebuild failed with code 65"
I followed different solutions I found online (like enable automatically manage signings in webdriveragent project, code signing identity...) but I am still getting this error.
Seems that this path does't exist in my computer.
Is there a way to fix this issue?
Thanks
You need to walk through Appium XCUITest Driver Real Device Setup article and perhaps Real device security settings chapter of the appium-xcuitest-driver documentation.
Most probably you have wrong XCode configuration with regards to signing mobile application packages
The easiest option would be considering using Appium Studio which has a simple wizard allowing creation of iOS provisioning profile in few clicks.
In my case I had to use one command from Full manual configuration
Steps that I made:
install appium:
npm install -g appium
Successfully build webDriverAgentRunner from xcode.
cd /usr/local/lib/node_modules/appium/node_modules/appium-webdriveragent
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<id_of_your_device>' test
Don't kill the console
Open appium desktop and try to connect

Is it possible to install a ".app" build file to an iPad from within Xcode, without loading the actual project file?

Without actually loading my .xcodeproj into Xcode, is it possible, from the Xcode app, to start an app install to my iPad using the .app file only, which was generated in an earlier build?
This is my last line of inquiry... I'm just looking at potential options because I don't have a paid developer account (yet) and might try to use Teamviewer to log into the remote client Mac to install via Xcode, but do not wish to reveal my project file/code on the remote machine. Installing from within Xcode purely using the .app file would solve my problem, if possible.
I managed to work out a way to do it using this, this, and this. You will need the XCode command line tools, which come as part of the App Store XCode install, or you can get the command line tools only from here.
First up, download and install npm. Then install ios-deploy from the terminal,
sudo npm install -g ios-deploy --unsafe-perm --allow-root
If you need to build from the command line, make sure you have a working XCode project which builds as you want, open a terminal and go to the directory with your .xcodeproj inside, then type:
xcodebuild -list -project <NAME>.xcodeproj/
xcodebuild -scheme <SCHEME NAME> build
Then, or if you've already built in XCode and just want to deploy your .app file to the iOS device, type:
ios-deploy debug --bundle <APP PATH>
You can change debug to release, or either way it will use whatever you set your XCode build configuration to be I think. The <APP PATH> location depends on your XCode install, but the most recent location (I think) is
~/Library/Developer/Xcode/DerivedData/{app name}/Build/Products/Deployment/
This will install your .app onto the iOS device from the command line, and you don't need to load XCode up, or expose your source files. Just requires the .app file. For me, this is a potentially useful way to install an app remotely on a client's device without the need for a paid developer account.

how to debug with real device using xcode tools in terminal

I've already have Xcode tools installed on my mac and now I can build my iOS game project like this:
xcodebuild -scheme "Game Scheme"
and the next thing I want is to install and run the generated app (using the command above) on a real device (connect to mac).
I'm wondering if there is a command such as (I read the document about xcrun but still can not figure out how to get this done):
xcrun "my game.app" -l
to install the game on my device, run it, and print all the logs in my terminal just like Xcode did in the console.
Any advice will be appreciated, thanks :)
Doing so is a complicated process that requires reverse-engineering the MobileDevice framework interface or the underlying protocols.
Fortunately, various parties have done the work for you.
https://github.com/phonegap/ios-deploy
http://www.libimobiledevice.org/

How to install iOS application from src, .app, or .ipa via command line to hardware device

For test automation (GUI test, not XCUnitTest) purposes, I need to install an iOS app onto a physical hardware device.
I'm looking for:
a replacement to Fruitstrap (it has been abandoned)
or a way to perform XCode's "Build & Run" action on a target device
I've tried:
using xcodebuild and pointing the -destination argument at the target device and providing build actions of clean and install
It finds the target device and begins cleaning and then installing.
At the end of all the files being compiled and the app being signed, I get a success message
** INSTALL SUCCEEDED **
But, alas, no app is installed on my phone.
This is my full xcodebuild command:
xcodebuild
-destination platform=iOS,id=######## \
clean install
Here's the gist of the output
Creative suggestions welcome.
I'm considering writing an applescript if needed, but wish there was a better way.
Fruitstrap is, for the time being, working and installing the app correctly.
/path/to/fruitstrap \
install -id ##udid### \
--bundle "/Users/#######/path/to/application.ipa"
Other, more maintained solutions are still welcome.
Limitations:
Need to have a prebuilt .ipa file
Target device must be signed with a provisioning profile that includes the target device's udid

Resources