Restore the connection to iPhone and run watchkitextension again - ios

I am using Xcode 6.3 and I keep getting the following message even if my phone and watch are both connected (and not locked):
Restore the connection to "mm24’s iPhone" and run
"com.projectname.watchkitextension" again, or if
"com.projectname.watchkitextension" is still running, you can attach
to it by selecting Debug > Attach to Process >
com.projectname.watchkitextension.
Even if I reset Xcode, Watch or phone I still get the above. The app seems to install on the devices but the connection with Xcode is not there.
Any suggestion on how to fix this?

I was running into this issue as well and it seems like I was able to solve it by removing the armv7 attribute of Valid Architectures on the WatchKitApp target And the WatchKit extension target.
See this apple forum post for more info on it.
This was driving me crazy for about a day and half, but seems to consistently let me build onto my watch for the last 2 hours.

Related

How to fix a broken iOS Simulator (The operation couldn’t be completed. LaunchServicesError error 0.)

When I try to run my project with my favorite simulators (iPhone 5s/8.4 and iPhone 5s/9.1) I get this error, and in syslog I see:
kernel[0]: AMFI: Simulator(pid 6881) - [deny-mmap] mapped file has no team identifier and is not a platform binary: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 7.1.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/host/liblaunch_sim.dylib
This started happening after I had built and run an xcodeproject downloaded from github. My main project had been working fine and when I switched back to it, I started getting this error.
Other simulators, such as iPhone 6/9.1, work OK.
Previously, when switching back and forth between my own project and examples projects from the internet, I have seen xcode pop up a provisioning error alert, offering to fix the problem, and when I click "Fix" I am able to continue with no issue. I'm an xcode newbie and all this is quite mystifying.
I have tried to "Reset Content and Settings" of the offending simulator, Quit the Simulator, quit xcode, and rebooted. I've checked my Provisioning Profiles in Preferences > Accounts and they look fine as far as I can tell.
Using the SimDir app I found the device directory for the simulator and dragged it to the trash. After that, the simulator worked for a little while then broke again.
I found this apple article but frankly I couldn't understand it (and I'm not running Swift. This is a react-native app.)
Oh one more thing. It's weird that the syslog message mentions iOS 7.1.simruntime when I'm using the 8.4 or 9.1 simulator. The project's deployment target is 7.0 but ???.
By the way I also tried cleaning my build folder (CMD-K) and anything else relevant in this SO question and this one.
UPDATE: Like a virus, the working simulator is now getting infected. The iPhone 6/9.1 simulator worked well for a while, but now keeps getting this error (which can be 'fixed' temporarily by Reset Content and Settings). It looks like my Provisioning Profile is OK in xcode because I can run on my iPhone, and when I build an Archive of the project and validate it with Apple it validates succesfully. It's just the simulators.
A good night's sleep resolved this issue! The next day I had the error pop up a couple of times but was resolved by "Reset Content and Settings". After that day the problem has not reappeared. I have no idea why I was seeing this... The only thing I can think of is that I might have had my own project and the example project from the web open in Xcode at the same time. You wouldn't think that should cause a problem but...
If it has an Apple Watch App bundled in you should use the bundle IDs correctly, like:
com.user.app
com.user.app.watchkitapp
com.user.app.watchkitapp.watchkitextension

Cannot run app on real Apple Watch

my configuration: Apple Watch (WatchOS 2.0.1), iPhone 5S (iOS 9.1) Xcode 7.1 on MacOS X El Capitan.
I can run my app on the iPhone just fine. However, when I try to run my app on the Apple Watch, it seems like it's not possible. What I see in the status bar is the usual steps
Building MyApp on Apple Watch
Installing to Apple Watch
Running MyApp on Apple Watch
And then, in less that a second, it shows
Finished Running MyApp on Apple Watch
As if I had just pressed the stop button in Xcode (but without my having pressed it at all). No error message or warning. It just stops.
As a result, I'm not able to debug my app on the Apple Watch to see the log messages, memory usage, etc.
Any ideas? Thanks in advance for your help!
When this happened to me, I fixed the issue by:
Making sure there are no problems with your Main.storyboard and it has an initial view controller.
Deleted app on phone
Rebooted phone
Rebooted watch
Quit xcode and rebooted mac
You could build the app to iPhone first, wait the watch app sync to watch. (Or you could sync it in companion by turn off and turn on the install switch manually)
Then keep the app running on watch, select Xcode->Debug->Attach to Process->XXXXX Extension(the name of your watch extension)
After a while you should be able to debug the watch app.
After restarting all my devices twice to no avail, here are some tips that sometimes solve the issue. (This whole thing is a headache.) I usually use the combination of these 3 things and it works 90% of the time.
Build for a simulator and then switch back to a real device again.
Switch the Info/Launch scheme setting to "Wait for the executable to be launched", run the project and then switch back to "Automatically".
Delete the Derived Data folder located under ~/Library/Developer/Xcode/DerivedData.
This drove me up the wall when starting out. I found 2 solutions:
Stop wasting time developing for Apple Watch
Found my XCode was disconnecting from my Apple ID. Went to XCode -> Preferences -> Accounts. And noticed "Your session expired, please log in." I could run to iPhone no problem with this error but on Apple Watch it would get stuck on "Running ... Apple Watch"

Lost connection to "iOS Simulator" for the first time in Xcode 6.0.1

When I run my iOS application in the Simulator for the first time in Xcode 6.0.1, I got this error message:
Lost connection to "iPad 2".
Restore the connection to "iPad 2" and run "App Name” again, or if "App Name" is still > > running, you can attach to it by selecting Debug > Attach to Process > App Name.
Can any one suggest how I can solve this error message? After I stop running and rebuild, everything works fine.
Follow 2 steps :
1- sudo DevToolsSecurity -enable
2- Edit Scheme -> Run -> Debug excitable , uncheck this checkbox it will be ok !
You will now be able to run on simulator. This worked for me.
Same here. I thinks that is the bug of XCode.
Just stop running and Run Again. This way is working fine for me.
This is a known issue with iOS 8.0 and earlier, but changes in iOS 8.0 make the issue more likely to occur than in past versions.
In addition to the lost connection message, other appearances of this bug will be an ESRCH error message (POSIX domain, 3 code), an FBS* domain with code 4, or your app getting SIGKILL and dropped to debugger. I think there may be one more message for this bug, but those are the main 4 behaviors. Which one you gets depends on exactly what point in the launch you lost the race.
At present, the workaround is just to retry Build&Run or launch the installed app in the sim and attach to the running process with the debugger.
Reseting the simulator content and settings would solve the problem. From iOS Simulator drop down select Reset Content and Settings, after that build and run again. I hope that helps.
This happens less frequently in Xcode 6.2 as compared to Xcode 6 beta version.
Only solution is to Re-run your project. This seems to be bug.

Xcode 6 process launch failed: timed out trying to launch app

I can't debug my app because when I run it, Xcode gives me the error:
Process launch failed: timed out trying to launch app
In the device I see a black screen and after the error message the app starts.
How can I fix this?
I tried to change the code signing identity and the provisioning profile, and to refresh the provisioning profiles in the Xcode > Preferences > Accounts > Details tab.
I'm using Xcode Version 6.0.1 (6A317) with an iPad mini, running iOS 8.0 and a MacBook with OSX 10.9.4.
After this, if the iPad goes into sleep mode (the screen turns off) I can't wake it anymore; I have to do a soft reset.
You are using distribution provisioning profile rather than development profile. check this link
How to Fix:
I fix it with:
clean project (Product > Clean)
hard reset device (power button + home button)
delete app from device
close xcode
CLOSE ITUNES (itunes must be closed)
re-open Xcode and run!
I think that iTunes was the problem.
EDIT: 2017/02: Solution still Woks (Thanks to #SalGad for information).
I am using Xcode 6.2, running on iPhone 4 with iOS 7.1.2, the problems happen to me as well.
It turned out that the Project and Targets' Code Signing settings are different from each other! And that's what is causing the issue.
To solve the issue, you must make sure that their Code Signing settings is the same.
One more thing that may be a reason to launch timeout arising is that you have a lot of Provision Profiles on your device. I have about 100 of them, downloaded automatically by XCode from our team dev portal. So if your team have tons of apps and Provision Profiles, you better unlink your XCode from your Apple ID, to prevent automatic downloading for unwanted PPs. It significantly decreases app launching time.
To delete unwanted PPs from your device you have to go XCode - Window - Devices, select your device and click "Show provision profiles..." on the bottom context menu. Then you have to manually remove the profiles. Tip: use key sequences "down arrow" - "backspace", to ease the hand routine.
I had this but nothing previously posted seemed to work. This is what I did to fix the issue in Xcode 6.3.2:
Go to Product->Scheme->Edit Scheme...
Select the Run Scheme
Select the Info tab
Make sure the settings are as follows:
Build Configuration is set to "Debug"
Debug Executable is checked
Launch Automatically is checked
In my case I was using the development profile, but somehow, in Build Settings > Code Signing, the Provisioning Profile for Debug was empty.
But before setting it to "iOS Team Provisioning Profile", I had to reset my account since it said " is Not on Any Development teams"
- Xcode > Preferences > Accounts
- Remove my account (click "-")
- Add the account again
That fixed the problem
Note that if the app still manages to start on the device after Xcode displays this error, you can attach to the running process with Debug->Attach to Process.
This warning is shown when you try to run and debug your code directly in device but you are using distribution profile in your Build Settings.
To directly run the code in device and debug, you need to use development profile in your Build Settings of Xcode.
After setting the development profile, just reboot your device clean your Xcode project and run again.
I hope this helps !!
An app should return from his initialisation procedure in less then 10 seconds, or it will be killed by the OS. This is probably because you are doing too many things in the startup phase.
Try to refactor your code to do it diffrently, by doing lazy initialisation, and only initialize what is really important before showing the first view.
It's hard to give better advice before knowing more about the app itself
I have faced this issue with Xcode 6.2 and Iphone 5s with iOS version 8.3.
I get this message when I deploy the application to the device for the first time.
The work around I found was that with out unintalling the application from the device,redeploy the application from Xcode.It should run perfectly this time.
I observed this only on Xcode 6.2 not on Xcode 6.3 so this might be an Xcode to iOS version compatibility issue.
Big and weird tip for this problem... this was happening to me and none of the advice helped anywhere on the web, but then i noticed if i deleted everything out of the main ViewDidLoad method it would work. I realized there was one line of code that was messing it up. It was a line that was referencing to an array of strings that was way to big. I had something like this NSString *mystring[100][1000][100]; i accidentally added some zeros and for whatever reason this problem produced the same error message that the incorrect signing gives you. So don't let your arrays or matrixes get too out of hand!
Method #1:
Lock your phone, press XCode start, wait till XCode says "unlock your device to launch", then unlock your phone, it will be launched successfully, works every time.
Method #2:
If your goal is just to debug the app, here is another simple and straight-forward approach:
After the app is deployed, launch it manually.
Goto XCode -> Debug -> Attach to Process ... to choose your app from the list, then debug properly.
This works well for me, and it saves lots of time.
I hope this helps, thanks!

Xcode will run app on simulator but not on device

I receive the following error when trying to run the app on my device.
error: failed to launch '/Users/michael/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphoneos/Word Processor.app/Word Processor' -- No such file or directory (/Users/michael/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphoneos/Word Processor.app/Word Processor)
The app runs fine in the simulator. When I try to debug on the device, it appears to copy the app (I can see the icon), but then stalls with the above message. Xcode says it is running the app on my iPod, but nothing is happening on my iPod.
When I click on the app, the app appears to launch, but seems to be missing resources.
Other projects of mine work properly. What setting do I need to change to make this work properly.? Looking at the error message, it seems to be looking in my mac for the app. But this doesn't make sense since I am trying to run it on my 4th gen iPod touch. I am using Xcode 4.3.1 and iOS 5.1
With Mountain Lion and the latest version of Xcode (4.4.4F250), none of the suggestions in this thread worked directly (clean, clean project, remove derived data folder, etc). This sequence did. From DhilipSiva:
Disconnect your device
Delete the app from your device
Quit Xcode (Don't just simply close the window, quit it)
Delete derived data folder rm -fr ~/Library/Developer/Xcode/DerivedData (console)
Start Xcode,connect device & run the project
I solve this by going to Targets-> Info -> Required Device capabilities and delete the option with armv7.
Hope this helps!
This is a recurring problem that many developers are having with the current version of Xcode. The temporary workaround has been consistently deleting the DerivedData folder.
You can add doing it to a build script or even make it a cron job:
rm -rf ~/Library/Developer/Xcode/DerivedData
Sad, but true.
For me restarting of Xcode, cleaning DerivedData and restaring device wasn't enough in most cases, until I had figured out that iTunes was also running, and after quitting iTunes everything worked fine!
So my steps now are simple:
1. Quit Xcode.
2. If iTunes is running, quit iTunes.
3. Reopen project.
No need to remove app from the device, clean project or restart/disconnect device.
I think that's because Xcode and iTunes use some common libraries (as you know, Xcode Installer always asks to quit iTunes on installing iOS SDK).
I also had this problem after changing from a lower XCode and iOS version to the current XCode and iOS version.
I fixed this problem by changing th iOS Depolyment Target to a lower version, since my Device is not updated to the latest iOS yet.
You can do this by clicking the project inside the Info tab.
Have you looked at the Developer Certs and Distribution Certs if you have. When running in debug mode from Xcode your will need your app assigned with the developer cert and not the distribution cert. The distribution certs do not allow for debugging.
This error will manifest whenever the device capabilities described in the Info.plist do not match those of the device.
In my case, I was requesting GPS support and location-services support and trying to test on an iPod touch.
I struggled with this problem for 2 days and went through all the posts, tried all the options including, restarting Xcode, device, deleting DerivedData folder etc.
Finally, the problem was with the Info.plist file. In my case, I had improper icon paths in the Info.plist file. I suggest you to archive the application and then validate it to get the exact problem in you case. Only when I did that, I was able to find the issue.
I solved this problem many times with DhilipSiva's solution. However, it may not work sometimes. If that is the case, consider deleting and re-adding the target.
Removed armv6 support and it started working again
I stumbled upon this same problem on several diferent projects, researched a lot on forums and even here on Stack overflow. A lot of solutions were given, and some people seemed to get them working, but none of them worked for me.
So we tried some pretty obvious course of action, which for some reason we didn't tought about before: I've done a CHMOD -R 777 on the EXACT path indicated by the error message (I copied it directly).
Worked like a charm, 100% times!
Hope it helps, guys!
As Chronos mentiod, the device capabilities might be the reason. In addition I would say that in my case it was all about the UIRequiresPersistentWiFi key, which (for some unclear reason) didn't let me to install my app on an iPhone4. Hope this helps ones who tried everything else and haven't fixed the problem yet.
I solve this by going to Targets-> Info -> Required Device capabilities and check id at 0 index if armv7 not in 0 index then remove other things and armv7 set on 0 index and clean app connect device and run.
Hope this helps fine!
I did these steps:
Delete derived data: rm -rf ~/Library/Developer/Xcode/DerivedData
Deep cleaned the project: Shift Key + Option Key + Command Key + letter K key
Quit the project
Quit XCode
Deleted the app from my device
When I reopened the Xcode, launched the project, and then launched the app it successively ran on my device
For me it was Command Line Tools
Go to Xcode -> Preferences -> Locations -> Command Line Tools
Make sure you select latest Xcode version. I selected Xcode 11.0, and everything started working.
I get the similar question and has searched via the internet the whole day without solution yet...
Xcode 12, iOS 14.
I'm using a cocoaPods call GCDWebServer, which will open a build-in http service in iOS. Now it works fine in simulator and I could open a home page of it in my Mac's browser. But I cannot open the home page if running it with real iPhone. The browser said "Cannot connect to server"
And in console, everything is same without any errors provided for me.
Thus, how could I debug this?
[DEBUG] Did open IPv4 listening socket 3
[DEBUG] Did open IPv6 listening socket 4
[INFO] GCDWebUploader started on port 80 and reachable at http://192.168.1.3/

Resources