How to use iOS debug app on iPhone while disconnected? - ios

I made a flutter app and tried to build on iPhone. It works while debugging is connected. But if I try to exit and relaunch the app or disconnect cable, it would not launch again and keeps crashing.
How can I use the app while Xcode debugging is disconnected?

Run flutter run --release in the terminal and that'll allow you to run a production version app on your iOS device without debugging connected.

If you only Start Debugging after this you can disconnect cable and will work. If you after Restart Debugging after this if you disconnect cable app will be crashing. I think you restart debugging.

From Xcode, you can change the Build Configuration of the Run Schema easily. To do this, click on Runner -> Edit Scheme, then go in the Run tab, choose "Release" in the Build Configuration drop down menu. To install the application, run the configuration again.
See Step 4 in this page for screenshots.

Assuming you can already able to debug with cable.
flutter build ios
connect cable
flutter install , if more than 1 device option is available, terminal will prompt you to choose the device for installation.
now you can disconnect cable

Related

Flutter iOS App not launching after removing USB

So i'm testing a flutter app that builds and installs successfully on an iOS simulator as well as a physical devices. However, when building and installing the app with xcode via the USB, it successfully installs and launches but when the USB is disconnected from my mac and i try to run the already installed device on the iPhone, it shows only the launch / splash screen and fades and closes.
Is there something i'm doing wrong that causes this to happen? As the app works fine when connected with the USB and it's being run.
If the build is in debug mode - it won't open.
if you want to open application after disconnecting, try profile / release mode
flutter run --profile
or
flutter run --release
In iOS, debug build doesn't work without USB. To use the app without USB trying making a release build using flutter run --release

How to launch my Flutter app without the host computer?

I wanted to know how to launch my Flutter app without the host computer on my iOS 14+ devices. Because I disconnected to my host computer and it gave me some error, so that I don't have to go back to my Mac everytime and rebuild that app.
You can just run this command in your IDE (I did it with VSCode)
flutter run --release
It worked for me!

Flutter app stuck on Installing and Launching step for physical iPhone

Annoying problem here for my Flutter app: iOS13.3, Xcode11.3 on a physical iPhoneX. The iOS-Simulators all work. The problem is only happening on a physical device. The Flutter App freezes at startup (i.e. at Installing and Launching... step) ! Any ideas ??
My flutter doctor -v does not bring any problems. Also tried flutter clean and flutter upgrade. But nothing seems to fix the problem...
If I run the App from Xcode (Runner.xcworkspace) then everything works as well. Only from VSCode and Flutter, I can no longer launch my physical iPhoneX.
Also, when uploaded to TestFlight, the App freezes at App Start ! (grey screen freeze). Therefore Apple App Store rejects all Flutter Apps for now ! Very annoying.
I am not sure if the Installing and Launching... freeze is related to the TestFlight and App Store Problem !! Might as well be...
This fixed the issue for me:
Run the app from Xcode.
Disable WiFi on iPhone.
Run from Android Studio.
Turn on WiFi on iPhone once the launch process has completed.
This is a workaround solution
I was having this issue. I uninstalled the app from my device, opened the project in xcode, ran some build cleaning thing that appeared in the yellow triangle warning area, then built the app via xcode. Then uninstalled the app from device again. Then ran via android studio and it worked.
Basically, it is because of might some files
For me, this worked
Follows these steps: Go to Flutter > bin > cache
and delete the Artifact folder
Try executing the command: killall -9 dart and retry.
As in my case, I use one of following solutions to fix the issue:
#1. close WiFi on mac, then run from Android Studio; OR
#2. close WiFi on both mac and iphone, then run from Android Studio; OR
#3. enable hotspot on iphone and connect it from mac, then run from Android Studio;

Physical device (iPad) not detected in vs code for flutter but detected and working proper for debugging in Xcode

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.

App closes automatically when not ran from Xcode

I am developing an app using react native.
When I test it on iOS device connected by USB (when I run from Xcode Integrated development environment). It works as expected. But if I unplug USB cable, the app is still on the phone, can be opened but only displays "NameofTheApp - Powered by React native" and shuts automatically after 10 seconds.
I have following questions
Is it normal as it is only on development mode
Is it a bug which i have to fix before releasing app?
This happened because when you run from the XCode, it has two modes.
1. Debug
2. Release
The crash happened because you were running in release while running xcode.
While running in Xcode, edit schema and set the mode as debug as follows:
Choose Product -> Scheme -> Edit Scheme. Change the Build Configuration under the Info tab to debug.
For me I had the 'debug executable' checkmark checked.
This is at Product -> Scheme -> Edit Scheme,
Select Run section on left side, info tab and verify that debug executable is Unchecked
You are trying to run the debug version which is unusable after USB debugging because it got disconnected from the server. You need to run it in production mode. Here is how to do

Resources