iOS Observatory not discovered after 30 seconds. Error launching application on iPhone - ios

I'm unable to debug a freshly created app on physical iOS devices when pubspec dependencies reach a certain size, because it causes the "waiting for observatory port" step to timeout after 30 seconds.
Devices tested:
iPhone 12,
iPhone 12 Pro
iOS versions tested:
14.7.1,
14.5
The app runs properly on emulator but not on ios real device.
How do I fix this issue?

This Error message occur when your iPhone is busy processing something. For example as below.
If you run Flutter doctor you will see message as below.
Error: iPhone X is busy: Fetching debug symbols for iPhone X. Xcode will continue when iPhone X is finished. (code -10)
To confirm I opened xCode -> windows -> Devices and Simulator and it was showing the progress. Let the progress complete and then confirm by running Flutter doctor to make sure there is no error message.

Had the same problem after updating Xcode and running for the first time. As mentioned on the this github issue (https://github.com/flutter/flutter/issues/72161#issuecomment-994653225) I simply:
Opened ios/Runner.xcworkspace with the iPhone connected
Waited until "Fetching debug symbols" process finished
Closed Xcode
Run again from IDE and it worked!

I have encountered the same issue and following this process has fixed the problem for me on 14.7.1 and 14.8:
Uninstall the app
Restart the phone
Open the app using Xcode
Run 'flutter clean' for the project
Now it should work if you run it again.
If it still doesn't work you could try increasing the observatory timeout (the default appears to be 30 seconds):
localUri = await observatoryDiscovery.uri.timeout(const Duration(seconds: 30));
I'm not 100% sure why this problem appears inconsistently, but there is a lot of related discussion at the following link:
https://github.com/flutter/flutter/issues/72161

For coders who are as lazy as me, you could take these steps:
Open xcode for the project:
Run the project from xcode:
while(prompt_below_finished == false) wait for some time || make a coffee;
Runs successfully. As for me, next time I ran with android studio , it run smoothly

run your project through Xcode, not from Xcode or Android Studio. it will show different error message.
when I run the Flutter project using Xcode, the error message was
"The sandbox is not in sync with the Podfile.lock..."
to solve this, I run pod install on the ios folder. run these 2 commands below on your terminal
cd ios
pod install

I have tried all the solutions here and for me the simplest works:
move you Android Studio in the trash, download it and reinstall. for me the problem was with Android Studio 2021.1.1 Patch but I got there with several updates. a clean install solved the problem.

In My iPad case, It showed a white screen after compiling in the installing step for 5-10 minutes & it worked at the end without doing anything

Try updating your Xcode and MacOS to the latest versions.

Related

React Native Expo Managed App doesn't launch/start on iOS simulator

I've been having hard times with my old Windows laptop while developing React Native apps so I moved to MacOS laptop. I installed Android Studio and Xcode (including Xcode command line tools). Then I initialized a blank expo managed project. I started both on Android Emulator and iOS simulator. Android one worked out with an ádb´ error (or maybe warning). But on the other hand, iOS simulator did nothing. There's no Expo Go app installed on iOS device, so it can not launch my app using it. I don't get any error or warning related to this problem, so I can't trace the problem.
I have tried deleting global expo folder located at ´~/.expo/´, I also tried to give 777 (all permissions) on that folder to my current user.
I tried uninstalling and reinstalling expo package globally.
I made sure I have selected Xcode command line tools on ´Xcode -> Preferences -> Locations -> Xcode 13.2.1 (13C100)´
I tried to launch different iOS devices like (iPhone 6, 8, 13, iPod etc.)
I tried clearing cache and starting expo with ´sudo npm start --clear-cache´
I have been trying to solve this for at least 2 hours tried everything possibly related to my problem but none of them did work. There's one thing I don't understand though. Even though I used different iOS device simulators the Expo Metro Bundler showed this ´› Opening exp://10.42.33.15:19000 on iPhone 8´ output. I have tried iPhone 13, iPhone 6, iPod etc. but this was the same output for different devices. Here's some screenshot related to probem:
https://www.youtube.com/watch?v=dvuZn6gX_Q4
This tutorial video on YouTube helped me solve my problems. I think I was missing a few things:
I haven't granted required privacy permissions on my Mac for Xcode, Android Studio and VS Code. Open System Preferences > Security & Privacy > Go Privacy Tab > Give Full Disk Access to Xcode, VS Code, Android Studio, Terminal and Watchman (Watchman is not required, but I have also installed it for solving a problem before)
You should to launch both your Android and iOS simulators before starting your expo application. Simply go to Android Studio and launch your device. To launch iOS device use bash and type open -a simulator.
If you don't have Expo Go app installed on your iOS simulator then you should first install it before starting your expo app. To install it use expo client:install:ios command.
Start your app by using expo start command. Type i and a or click on Run on iOS simulator and Run on Android device/emulator buttons to launch your app on devices.
NOTE: If you app gets stuck at New update available, downloading... stage then you can start your expo app with cleaned cache using expo start -c command. It was helpful for me.
NOTE 2: You may need to use sudo command on some of the commands I've mentioned, I'm not sure which ones are required or not.
I run into the same issue every time when I tried to set it up on a new laptop.
Its fixed after the installation of xCode cli.
Take a look at this - https://docs.expo.dev/workflow/ios-simulator/
I fixed similar issue by hard restarting simulator
Top menu -> Device -> Erase All Content And Settings...

Can't run flutter app on physical Apple devices

I have a perfectly working Xcode (at least for Swift iOS projects), today I tried to install flutter.
I followed the steps from here: FlutterDev (every step, so the solution is not here)
I can build and run Flutter projects in terminal on Simulator on iPhones and Android Virtual Devices as well.
Flutter doctor found everything OK.
But I can't run it on any physical Apple device. Tested on 2 MacBook Pros -> deploying to 3 different iPhones.
I got SIGABRT error right after the app tried to launch if I run the from Xcode, and the terminal stuck in installing and launching... if I try to run the app from there.
Terminal
Xcode
Maybe you should just try these steps:
1) flutter clean
2) flutter build ios --release
Then later do this in Xcode MenuBar: Product -> Clean and then build in Xcode
It is a bug from Flutter. Instead switch the channel:
flutter channel dev
flutter upgrade
flutter run
But remember: The dev channel is far ahead of the stable one, it is little less safe. I would recommend you to use it just for running the app on your device. For coding etc. switch back to the stable channel:
flutter channel stable
flutter upgrade
The bug will be fixed in v1.15.3.
After I've spent my day troubleshooting the only solution that worked for me is to download xcode beta, the newest 13.4 iOS beta and then everything worked immediately. I opened the existing projects, hit run and opened on my phone without any extra steps.

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;

Xcode 9.2 Simulator Debugging Broken; Could not attach to process id

Xcode 9.2 debugging on an iOS Simulator has completely broken for me.
I worked on this for hours and tried a ton of suggestions short of completely wiping my hard drive and starting out with a fresh operating system install. I ended up filing a bug with Apple. Posting here in case anyone has encountered this problem and has any suggestions.
Summary:
When try to build and run in debug mode with a debug executable. The simulator only opens the application to a white screen and then Xcode pops up an error:
Could not attach to pid: "<a process id>"
Ensure "<app>" is not already running, and "<user>" has permission to debug it.
Steps to Reproduce:
Make any project and try to run on any simulator.
Expected Results:
Debugger successfully attaches to debugger.
Actual Results:
Debugger is never able to attach to the iOS simulator process/app for debugging.
Debugger CAN attach and build and run successfully on a physical device.
Version/Build:
- Xcode Version 9.2 (9C40b)
- macOS Sierra 10.12.6
- Any iOS project
- Any iOS simulator
Other notes:
- Xcode 9.2 was working fine until this problem randomly started. The error initially said:
Failed to initiate service connection to simulator
DTServiceHubClient failed to bless service hub for
simulator iPhone 8 Plus <simulator identifier>
- After rebooting computer, the error shifted to "Could not attached to pid..."
I tried dozens of suggested solutions short of completely wiping my computer including:
Resetting device contents and settings on simulators
Create a new device (even different device and OS combinations)
Try different Xcode projects, even simple one-off single view applications
Looking at the etc/hosts file and verifying localhost can be pinged
Restarting computer multiple times
Deleting out derived data (multiple times)
Let it build and run without attaching debugger, then try to attach debugger by "attach to process id"
Completely uninstalling Xcode and all simulators, and reinstalling.
Removing any invalid certificates in keychain
It turns out our security software was blocking the debugger. Running sudo sysdiagnose helped me find a log entry showing that it was being blocked. The software is Cb Defense (Carbon Black Defense). Apparently the only workaround is for your security team to whitelist by a hash, and that hash could change in the future.
There is a bug in Xcode 9.0-9.2 that causes this issue to appear after running for a while. If you log out and back in it should resolve it for you.

App installation failed during run App in xcode 8

I upgrade my xcode after update in xcode_8 I have faced many issues like app not running in simulator as well as some time not run in device .It gives me an error App installation failed.An unknown error has occoured. Out of five three time run on device and 2 time not run and provisioning profile is correct because app run in device.
In simulator it gives an exception of slidemenu franework.
Code totally update with xcode_8 and swift 2.3.
Tried everything, described above, the only thing that fixed this was to restart my Mac, it then started working again.
Clean the derived data, then run again.

Resources