I have an issue. I started to code in Android Studio and I want to select iOS Simulator. However, I can select only option Open iOS Simulator which opens.. a watch!
How could I launch a phone as a simulator?
I tried going into Simulator itself, but couldn't find any ways how to do it.
Open iOS Simulator externally first. Now, open Xcode, Select your latest Xcode version in Xcode -> Preferences -> Locations -> Command Line Tools
Now, go to Terminal and run flutter doctor See if it shows any iOS device connected.
If yes, then you're done. Now you can see opened simulator can be seen in Flutter Device Selection and used to run your flutter application in iOS Simulator.
If No, then open terminal of project and run xcrun simctl list, from list of devices copy UID of wanted device and run xcrun simctl boot *SELECTED_UID*
After extensive research, I found a solution.
First, go to your xcode.
xcode -> Preferences -> Components and install selected iOS version.
After installation is finished, head to Android Studio go to Terminal tab and write xcrun simctl list - you will get list of devices. Select which one you want to use, copy UID (bunch of numbers) and use it with this command xcrun simctl boot *YOUR_DEVICE_ID*
Hope it helps for someone with same issue!
Related
I've recently started learning Swift and SwiftUI for iOS development and I completely understand how to run my apps for testing using XCode. You just click the play button with whatever simulator device is selected. However, I really don't like using XCode. I want to use VSCode for my development. Looking online I can find very complicated tutorials on how to build my project for release on the App store or "Ad-Hoc" from the terminal. But, I don't think this is what I need. I'm wondering if there is a way to build and run my app from the terminal on to a simulator or personal device (connected with USB)? I understand I can just have XCode open on the side and run it from there while developing from VSCode, but, my computer is kind of old and having both those apps open makes my fans go crazy.
You can follow this guide on how to build your project using xcodebuild.
Assuming you are in the directory with the .xcodeproj file, the command will look something like this:
xcodebuild -destination "platform=iOS Simulator,name=iPhone 14 Pro Max,OS=16.0" -scheme YourScheme SYMROOT="./build" build
Of course, you can choose any simulator you like. You can find a list of the simulators by doing xcrun simctl list.
The built app will be located in a folder called build/Debug-iphonesimulator, or build/Release-iphonesimulator, depending on your default configuration. The configuration can be set by the -configuration option.
Now you can launch the simulator. Here is a guide for that. Basically, you just specify the UUID of the simulator (again you can find this using xcrun simctl list), and then launch Simulator.app. Example:
xcrun simctl boot 8F9690AC-FCDE-4913-9BD2-E54B3CC9F6C1
open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/
To install the built app, you also need the UUID (see also this answer)
xcrun simctl install 8F9690AC-FCDE-4913-9BD2-E54B3CC9F6C1 build/Debug-iphonesimulator/YourApp.app
Finally, you launch your app by specifying the UUID of simulator, and the bundle ID of your app (source)
xcrun simctl launch 8F9690AC-FCDE-4913-9BD2-E54B3CC9F6C1 com.mydomain.YourAppBundleId
Here's my Environment
Xcode Version: 11.1 (11A1027)
Physical device: - iPad mini 2 (IOS 12.4.2)
VSCode Version: 1.39.2
Flutter version: 1.9.1+hotfix.6
When I use the iOS part of the Flutter project and run it physical device using XCode, it detects the device and works fine but I am somehow not able to see the device on the available devices section on VSCode.
However VSCode detects and works fine with the simulator.
I also ran flutter doctor to see connected devices, but again it does not show the connected physical devices but shows the simulator created device.
Use rm -rf <flutter_repo_directory>/bin/cache to force delete the files in cache and then flutter doctor -v to reinstall the missing sdk directories.
Deleting the cache in flutter/bin/cache directory and then reinstalling the dart sdk solved this issue.
Referred to this issue in Flutter repository(Issue No:41006).
I had the same issue. In my case, a recent iOS update had turned off Developer mode, for some reason... So I needed to enable it again (Settings - Privacy & Security - Developer Mode).
iPadOS / iOS Devices Setup for Hot Reload
Before trying to flutter Debug on physical device from Vscode it is Required to first :
Run a successful Xcode build on that iOS or iPadOS device
Follow this steps if you don't know how to Run Xcode Build -> your device should then be detected by flutter :
Open Xcode & do all the classic Set Up (Signing in with a Team & choosing a UNIQUE bundle Identifier)
Set Your iPhone Auto-Lock to Never (& Unlock it !) - Connect your iPhone or iPad to Mac with USB cable & Accept Prompt on the iPhone
Run Xcode Build on your iPhone this alert prompt will select Ok
On your iPhone a new menu will have appeared - Navigate to it & Click « Verify App » or « Accept »
Now Run Xcode Build Again - if does not run try running flutter clean & flutter build ios & try running again
—
After Successful Xcode Build - Stop Running the App
Keep Xcode Open
— iOS Setup is done
Close all Simulators or Emulators - Close VsCode
run flutter devices to make sure your Device is now detected
if it’s not try Turning it off & plugging it back again - remember to accept Trust Computer Prompt - keep it device unlocked too !
Open back your project in VsCode or Android Studio
Hot Reload⚡️Using VsCode :
Press F8 or Select ▷ « Start Debugging » in main.dart
That’s it ! You now have the power of Hot Reload⚡️ with VsCode on a physical device !
Hot Reload using Terminal Commands :
run flutter run -d yourDeviceID
Have fun ! Press r in Terminal for HotReload⚡️
If you need to find your iOS device ID :
Select Add Additional Simulators
Hot Reload⚡️on Android Studio :
Select your device & run
All I had to do was to disconnect the device from the laptop, make sure VS Code is open, then connect the device again while no VS Code, then it detected right away and chose the device automatically.
Sometimes it doesn't detect the device if it is not directly connected to the computer. I had a docking station in between and it didn't recognized the device. Especially after you have updated you macOS just before.
With "focus mode" activated on the device (like "do not disturb" 🌙) it won't show up.
Check whether you have fully installed xcode by running flutter doctor -v
Incase you find that some thing like
[!] Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
just run install Xcode and run
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
Incase you installed xcode already, just run the above commands, they will do the magic.
I'm trying to test one of my apps on ios 10. I have downloaded the Xcode 8 beta which ships with the ios 10.0 Simulator. However, as expected, Xcode 8 is throwing tons of errors on the libraries I'm using [like Alamofire] which is preventing me from building in Xcode 8, which I don't feel I need to worry about right now. I'm just looking for an easy way to run the last stable compiled version (which I can successfully build within Xcode 7 for ios 9.3). I am unable to trigger the ios 10.0 Simulator from my terminal via xcrun as I have used to achieve similar things in the past.
Any guidance would be much appreciated!
EDIT -- Solved
I figured out a way to achieve what I was looking for, for those interested.
In Xcode7 go to Preferences > Locations > and change Command Line Tools to Xcode 8.0
In Terminal, type xcrun simctl list to see the available Simulators (ios 10.0 simulators should be available now).
Copy the UDID of the Simulator you want.
Make sure the normal Simulator app is not running, then run open /Applications/Xcode-beta.app/Contents/Developer/Applications/Simulator.app --args -CurrentDeviceUDID <Copied UDID>
After the desired Simulator is booted, run xcrun simctl install booted <path to project .app file> (the path to the .app file can be found in Xcode on the left pane, under your main project, under the folder "Products" copy the file path from the [project-name].app file located there)
This should install the app onto the desired Simulator. I did encounter some errors the first few times I tried this. I got around them by simply quitting the Simulator.app and trying again (Worked for me on the fourth try).
I have a .app file shared from a developer which i would like to run in iOS 8 simulator. I have seen similar questions which has solutions for older versions of iOS which is no longer working for iOS 8. Can someone point out what needs to be done to run the .app file in an iOS 8 simulator without using xcode.
Boot the simulator you want to install it to in the iOS Simulator and then do the following:
xcrun simctl install booted /path/to/Your.app
xcrun simctl launch booted com.yourcompany.yourapp
The "booted" token was not supported on older versions of simctl in Xcode 6.0. If you get an error, please use the full device UDID instead of "booted". You can determine the UDID by running xcrun simctl list
If the application crashes after installing in the simulator using the command,
xcrun simctl install booted /path/to/Your.app
It's probably because the architecture issues, since we used the device build instead of simulator build.
The basic architecture difference between the iphone simulator and iphone device is
iPhone simulator uses the architecture i386 or x86_x64
whereas,
iPhone device uses the architecture arm64 or armv7 or armv7s
We can find each device architectures in this link. So to over come this problem we need to get the simulator build by changing the xcode build location settings.
SOLUTION :
To change the build location settings, Open your xcode and follow the below steps.
Go to xcode preferences.
Choose the locations tab.
In the 'Derived Data:' section click 'advanced', from the resulting screen choose 'legacy'.
Now build the application, after successful build go to 'Your-App-Folder/build/Debug-iphonesimulator' in finder, and copy the build available on the same folder with the extension .app
Copy that and run the above command answered by #jeremy.
xcrun simctl install booted /path/to/Your.app
After running this command, note that your simulator is installed with the build you specified. There you go, run the application in simulator by clicking the corresponding app and use it.
I deliberately write this solution to help the needy, those who are clueless about the architecture issues specified above.
Happy Coding :)
iOS Simulator also supports dragging and dropping for installing .app files
Open Simulator
you can do it through XCode under XCode > Open Developer Tool > Simulator
to open it "without using xcode", see these answers.
Find the .app file in Finder and drag it into your Simulator window
Wait for the app to install and launch it
For developers looking to provide a simulator build to theirs testers, these are the steps that I followed to create and test a build -
Add i386 in valid architectures section of build settings.
Open terminal and navigate to your project folder. Then execute the command -
xcodebuild -arch i386 -sdk iphonesimulator8.1
(This will build the application)
To install the application on simulator, run the command mentioned in the above answer i.e -
xcrun simctl install booted /path/to/Your.app
Now you should be able to run the app by clicking on the installed application in the simulator.
I have followed all the above commands and stuff but none worked. All I was doing is creating .app through archiving the app from Product->Archive and then converting that generated .ipa to .app by changing the extension to .zip.
But the app is crashing as and when it is being launched.
For those facing the same issue, go to
DerivedData/projectname/Build/Products/Debug-iphonesimulator/
folder. There you can find the .app file with app name. You need to use this .app file by dragging and dropping onto the simulator. Product->Archive->.app doesn't work.
I have built a demo iOS app on my Mac. My client wants to get the executable and run it on his iOS simulator on his Mac so as to give me feedbacks. I have an Apple developer account and I can deploy my app to my iPad / iPhone or distribute it via AppStore. But I don't know how to generate an iOS simulator executable for him. He only wants the iOS simulator executable. Does anyone have tried this before?
P.S. I can't really distribute it via AppStore since it is just a demo app. It is very likely rejected. Plus, I have to send it to him today so I don't think Apple can pass my app within a day.
P.P.S. I can't give him the source code unless he pays me. But it is not possible after a month.
Please help. Thanks in advance!
You need to send him the Application folder under the iPhone Simulator folder.
You can find it here:
~/Library/Application Support/iPhone Simulator/<Simulator-Version>/Applications/
Building upon this answer by #Midhun, for later versions of Xcode (Xcode 6, Xcode 7 and Xcode 8 in my research), the simulators now live here:
~/Library/Developer/CoreSimulator/Devices
I was actually trying to use an app built on Xcode 8 for iOS8 simulator and get it to run on an ios7 simulator from Xcode 6 on another Mac. I couldn't find out how to simply copy files around but I did manage to copy the Mine.app folder to the other Mac, then install it using
xcrun simctl install 6DC6323C-504C-423F-ACD6-652557B33D48 Mine.app
where you need to replace 6DC6323C-504C-423F-ACD6-652557B33D48 with your simulator device type ID (find using xcrun simctl list devices).
For running app, build on other mac machine to yours machine simulator. we require .app file for that project.
run below command in terminal
xcrun simctl install booted $LOCATION/FILENAME.app
replace $LOCATION with the path and the FILENAME should be the name.for more details check this link => https://www.webdigi.co.uk/blog/2016/how-to-transfer-your-app-to-an-ios-simulator-on-another-machine-using-app-file-and-xcrun/
iOS Run .app on another simulator
Build .app[About]
Xcode: Product -> Build
xcodebuild command[About]
//building workspace
xcodebuild -workspace "/path/to/workspace" -scheme "MyShemeName" -sdk iphonesimulator CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
Find .app
//1. Build location*. Usually it is derived data folder
//2. Xcode.
Project navigator -> project -> Products group
//3. Get it from iOS simulator
Activity Monitor -> <App Name>(not Xcode) -> Double click -> Open Files and Ports -> Find <App Name.app> path -> find and copy a file <App Name.app> by path -> save the file locally
[Build location]
Install .app
xcrun simctl install booted <app_path.app>
Or you can send just the one app you need from ~/Library/Application\ Support/iPhone\ Simulator/7.0/Applications/GUID-OF-YOUR-APP
i have used a similar tool called Simulator Bundler in a recent project with no issues,
https://github.com/landonf/simlaunch/downloads
Midhun MP answer is good but in case of solution don't work then in emergency sometimes making video and sending it to client would help. This tool provide light weight video creation.
http://www.screencast-o-matic.com/
You can resize it for your simulator.