Can't debug iOS 8 App Extension - ios

I'm trying to debug the sample Action App Extension provided on Xcode 6 (6A313).
Even though the app runs flawlessly, I can't see any NSLog messages on the Debug Area neither Xcode will stop on my break points.
Things I've tried:
I've tried uninstalling Xcode 6, re-downloading it from the Mac Store and installing again with no success.
I've also tried to go through Debug -> Attach to Process -> By Process Identifier (PID) or Name... but the Status Bar shows "Waiting for -bundle id- to launch" when it is already running.
Tried different devices.
Tried running on the simulator, but my App Extension won't show on the App Extensions list (it is not present in the "more" list also).
I've checked this answer also, which didn't help me.
I've ran out of ideas on what to do :)

When you added the Application Extension target Xcode should have added also a new Scheme for the Extension (or you can create one in 'Manage Schemes...').
If this happened you just have to change the Active Scheme, on the very left of the drop down with which you choose the device/os of the simulator, and run.
If you change the Active Scheme to the Widget one, then breakpoint and NSLog works, at least for me.

Related

This app could not be installed at this time.Xcode 9.2

I have changed my application name and bundle identifier and now when i'm trying to run my app it is showing an error that This app could not be installed at this time . Why it is so? Why it isn't running the app?
I know the question has been answered but for others encountering the same issue I suggest following:
Check simulator logs, if its printing something useful. First, selecte simulator then from menu option open Debug -> Open System Logs.
Make sure only 1 simulator is running.
Delete the older version of app from the simulator.
If you importing a custom framework, make sure custom framework->bundle-id is not same as currentAppProject->bundle-id. If you are not sure then simply change the bundle-id of current project.
Also some of the simulators can be buggy -> Simply change the simulator, it may resolve the issue, for me changing the simulator worked.

Xcode 8 app runs on Simulator but doesn't display

I'm using the release version of xCode 8 and am trying to run my app on the simulators. They are all the iOS 10 simulators.
No matter which simulator I use, when I run the app the app icon shows up in the simulator but then that's it. The app never displays in the simulator. I only see the app icons of the iOS home screen.
I put some break points in my initial view controller at the viewDidLoad, viewWillAppear, and viewDidAppear methods. All of them triggered. So as far as my app is concerned, it is displaying on the device. I also get all the normal log output and networking calls happening just fine. It even shows the popups for permission to access the calendar and notifications. But my app is not brought to the foreground.
If I then click on the app icon in the simulator, my app runs normally. But it should be automatic when I hit run from xCode.
When I run my app on an iOS 10 device I get the same behaviour as all three of those view methods are called. However I don't get any of my normal log output. In fact I don't get any log output. However the app was already installed from when the device was on iOS 9.x. Not sure if that is a factor. But aside from the simulator issues, this is the bigger issue.
I've tried cleaning the build, deleting the app, I even tracked down the derived data folder and deleted that from the simulator. None worked. I also updated all my cocoa pods I have installed too.
Any one else experienced this?
That sounds weird but I read a lot of threads on the Apple Developer Forums on the same problem during the different Xcode 8 beta version, try these steps:
reset the simulator using the menu "iOS Simulator" -> "Reset Content and Settings..."
remove your 'xcuserdata' directory inside your .xcodeproj directory
do a clean build folder (hold down option key when selecting clean)
reboot your Mac
If these steps don't solve anything you can try this solution:
Copy-paste Xcode-beta.app from Applications folder to somewhere else, e.g. - Documents folder.
Delete Xcode-beta.app from Applications folder.
Move Xcode-beta.app from Documents to Applications folder again.
originally posted here, obviously using your Xcode.app instead of Xcode-beta.app.

Nothing in Xcode Debugger after Archiving for release

I recently archived and uploaded my app for release for the first time. However, now when I try to print to the debugger, nothing is appearing. Also, breakpoints are not being activated when I run the simulator.
I am using Xcode 7.3, the latest at the time of this writing. My app contains a keyboard extension. Neither are printing to the debugger or triggering breakpoints. The debugger pane is set to show "All Output".
As far as I can tell, it is still using the "Debug" scheme, I never manually changed it. Would it have changed when I archived and uploaded the .ipa to iTunes Connect? What would have changed?
With your suggestion, can you be thorough in your suggestion? I may not have enough experience with Xcode to understand immediately, so the more explanation the better.
Look at the "Run Scheme" for your Project (Product->Scheme->Edit Scheme or option-click on the Run button) and check the Build Configuration pulldown. Make sure that's Debug, not Release.
BTW, you can also tell what binary is actually getting run by running in the debugger, hit the Pause button, then in the Debugger Console, type:
(lldb) image list <AppName>
That will show the path to the binary that got loaded. If this is the Release version that should show up in the path and you'll know you are debugging the wrong configuration...
In archiving my app, Xcode combined the scheme of the Containing App and the Keyboard extension. As a result, the Containing App was the only selection possible when choosing a scheme and the output of the Keyboard Extension was no longer sent to the debugger.
In order to solve this, I selected "Product > Scheme > New Scheme..." and then selected my Keyboard Extension to be its own Scheme again. Once the Keyboard Extension was a scheme again, it was able to be selected as the target scheme to send output to the Debugger.

Apple Watch Simulator completely fails to start or load app with message "Waiting to attach"

The Apple Watch Simulator always fails to load my WatchKit App. The entire process has always been quite flaky, but for a reason I can't figure out, the Watch simply hangs on a black screen without loading anything. No home screen, no app, no spinner, no time or date.
I've tried:
All combinations of clean/launch/stop/quit/reload/restart/etc..
Resetting simulator content and settings
Different versions of the sim, phone, iOS, etc
Recreating the scheme
Checking the code hasn't been trashed by accident, and the "Startup Interface"
Going to the WatchKitSettings (Apple Watch) app on the sim:- it's empty.
All I see is the title (e.g. Apple Watch 42mm); the rest of the screen is black.
The only thing that's changed in the project recently is the addition of Launch Files and Icon files. But the WatchKit target does not have any of these.
It's like there's a problem somewhere down in the depths of the WatchKit installation/xCode debugger. I often get the message "Waiting to attach" in the debug navigator (sometimes repeated multiple times), sometimes the message "No Debug Session" remains.
Does anyone please have any helpful tips or experience with a similar situation that might get me building again?
This turned out to be a combination of:
a problem with the project's (Apple Watch, iOS App & WatchkitExtension) Bundle Identifier
Check your bundle IDs are all correct and the parts that need to match match
Check your provisioning profiles include the ID, are set to the correct team and match throughout the project's targets
A problem with the signing of the WatchkitBundle
Due in parts to the issues noted above, but also related to the "Skip Install" 'Build Setting' of the Watchkit App
Usual steps of reset simulator, restart xcode and machine. XCode 7 is a poor effort so far.

How to debug iOS 8 extensions with NSLog?

- (void)viewDidLoad
{
NSLog(#"%s", __func__);
// ...
}
in viewDidLoad of an iOS 8 extension. the NSLog outputs nothing in Xcode. NSLog works as usual in the container app though.
How can I get output from debug messages from an extension?
Debugging works for app extensions.
It works on simulator too.
If your app ext crashes in the simulator, you may find it is not easy to restart your app ext. Restarting your simulator is a quick solution.
Steps to debug an app extension:
Run the container app. In this step, Xcode uploads the container app and app extension to the device or simulator.
Stop the container app. This step is important when you debug in simulator. If you don't do it, Xcode will tell you the simulator is in use.
In Xcode, press menu Debug -> Attach to Process -> By Process Identifer (PID) or Name..., input the app ext's identifier, e.g. com.abc.ContainerApp.MyExtension, to start debugging. Don't forget to set break points. (Update on Aug 25, 2014: you can input MyExtension(your extension's name) directly.)
In the device or simulator, open your app extension.
Updates on Aug 23, 2014:
I found the debugging steps above do not work well on Xcode 6 beta 6 with iOS 8 SDK beta 5 on the simulator.
Solution:
Run your extension in the simulator.
Xcode menu Debug -> Attach to Process -> Choose "MyExtension(your extension's name)" in System section in the menu.
The breakpoints work. But I don't know why logs do not show in the output window.
I'm having this problem too. It works for me if you go in your Simulator under the menu Debug -> Open System Log...
From here you can see all the logs of the iPhone Simulator (included your extension's logs).
NSLog is working perfectly.
You just don't see what is being logged in the debug area of Xcode because the Xcode debugger isn't attached to your extension. Extensions are nearly completely independent from their containing app. They have separate bundle identifiers, for example, and they also are separate processes on the OS.
I have had varied success in getting Xcode to attach to extensions. Supposedly it seems it would attach automatically, and it appears in the debug navigator as "Waiting to attach", but never attaches.
Sometimes, I am able to run my extension target in Xcode:
And then have the option to choose what application to run my extension in. In this case, I would choose its recommendation of "today", which is notification center.
And then it would sometimes attach the debugger to my extension. Note this method only works on physical devices, it seems.
If it doesn't attach you can use the manual attachment method in #VinceYaun's answer,
I have also had varied success using other methods of attachment. Most have been unsuccessful, and it seems they are just bugs that will be fixed at a later date.
To view your log messages you go to Window -> Devices in the top bar and select your device. You can bring up the device log from the bottom of that window. If you are testing on a simulator, you can use #BalestraPatrick's answer.
Some of the bugs have been fixed in Beta 2, and my guess is that eventually the debugger will attach automagically when launching the extension.
Update: In the iOS 8 Beta 4 release notes:
Extensions
Fixed in beta 4
Extensions sometimes fail to launch when debugging from Xcode.
When Extension with UI is killed, it relaunches and is not dismissed.
Sometimes your Sharing or Action extension can hang.
Redeploying an extension may disable it in Notification Center.
I'm having this problem too. Xcode never attaches my debugger to the extension or displays NSLog messages. If you attach your Xcode debugger manually to your extension process, at least breakpoints work like a charm:
Debug->Attach to process->Your extension name (mine was "com.example.MyExtensionApp.MyExtension")
Create scheme for your extension
Run scheme
In a dialog choose container app
Enjoy
It works for me :)
Xcode 8 is able to debug extensions:
Choose the extension scheme in the combo next to the stop button and run it.
Select the parent application in the dialog that appears.
Result: breakpoints and log work as usual.
What finally allowed me to see the log in the debugging area, based on Michael's suggestion and Apple's documentation, is:
Build & Run the app extension in the simulator and, when prompted for a host app, choose the specific app that you're going to call the extension from. In my case I was launching my Action extension from Safari by pulling up a share sheet on a PDF.
What wasn't working before was following other people's suggestions of using Today as the host but then leaving that app and going over to Safari to call my extension. I no longer even need to run my containing app first before running the extension.
From Apple's Documentation:
In your extension scheme’s Run phase, you specify a host app as the executable. Upon accessing the extension through that specified host’s UI, the Xcode debugger attaches to the extension.
I actually got the logs to run quite simply in Xcode 6.3. Firstly, build and run the containing app. Once the containing app is running on the device, build and run the app extension by changing the scheme to the app extension.
Apple has documentation directly related to debugging, profiling and testing your app extension.
A trick which works for me (although it is quite an ugly one) is to place a dummy UILabel somewhere in the bottom corner of my extension. I usually call it logLabel. It is then possible to update the text of this label with any log statement that you want to get logged. Such approach is not very good if you need to log statements from instances of different classes. And, obviously, it clutters your UI.
However, if you have a fairly simple widget and you don't mind about slight cluttering of the UI this does the trick. I have tried all other solutions outlined in this discussion and, sadly, none of them worked for me.
The only way debugging works for me is by selecting Debug->Attach To Process By PID or Name
Then enter the PID not the extension name.
You can find the PID by running the extension on a device, go to Window->Devices. Find your device and viewing the console. When you see the name of your extension, its followed by 5 digit number. That is the PID
I also put a bunch of NSLog's in the extension in order to find the PID as well.
This is on xCode 7
Encounter the same problem about extension for NSLog, and break points. I have fought it with many days.
Device log can be found as following image. It is at XCode -> Window -> Devices and Simulators.
After enter the Open Console, there is a search field at the top-right of dialog. I can apply filter rule in there. For example, a process name contains Notification key word, or process name must equal to the name of extension target, ex: equal to MyNotificationServiceExtension process name.
Clearly something is broken in Xcode6-B5.
If I try to run a Photo extension on the Simulator I cannot see any Photos.app as an option for the extension attaching process.
The same, running on a real device, give me the correct behaviour.
In the first case any breakpoint is not honorated. In the latter case, breakpoints work like a charm.
You should know that the container app and extension are totally two difference process in iOS while the LLVM debugs only a thread a time, so when you are debugging, the console never log the extension and never stop at breakpoint.
You can solve most of the problems by #Vince Yuan's method.
However, my problem is that Xcode debugger hardly hook on my keyboard extension on both iOS Simulator and devices, like 1 time in 7-8 runs, It's totally a matter of probability. #Vince Yuan's method also work for just sometimes.
My little experience is that when you run you debug scheme, if the debug Session in the left panel showing that 'No Debug Session', there is no need to open your extension and test it, the debugger didn't hook on, just run again for lucky.
but when you see com.xxx.xxx.xxx is waiting to Attach, the extension can definitely get debugged.
This is a little trick for whom cannot debug iOS extension, especially keyboard extension.
As of Xcode 6 Beta 5, I've been able to use an actual device running iOS8 to debug my extension. Try running it on a device and select Safari to launch into
To overcome all the states caused by ever changing IDE, I'm using iOS Console by lemonjar.com – it displays a console window for any connected iOS device rendering syslog messages regardless the process ID. You can see both app and extension debug log messages at once here.
I could debug my extension with the way I describe below:
Xcode : Debug -> Attach to process by PID or Name. Your extension scheme name.
Then select your main app target and run.
I hope it also works for you guys.

Resources