When I run my Today Extension on the simulator everything works fine and it displays the following as expected:
However when I run it on my devices (iPod touch and iPhone 5s) the body won't show (don't mind the title and icon, that was changed)
I attached the debugger to my extension and I got this:
I have no idea what all of this means...
I removed all code for the Today Extension to check if there was a problem with my code and nothing changed so I doubt theres a problem with my code. Any suggestions on how to fix this would be greatly appreciated.
(I do have app groups enabled if thats of any significance)
Make sure extension target version
Please make sure your extension target version is correct. Xcode'd give you the highest version by default such as 8.3, and if your iOS version is lower than it, Xcode'd give your a crash.
I found out that I was accessing my app group with the wrong suitename. Just make sure you access the app group with "group.something.something" not just "something.something"
I found the solution for my case. I just had to specify arm64 as valid architecture for the widget target.
On the Widget Target
Build Settings > Valid Architectures
I was having just armv7 and armv7s. I added arm64 and it worked like charm in my 5s device
Few points to remember while using app extensions
Bundle Identifier for the target extension should be com.companyName.AppName.ExtensionName
You need to have separate AppID for the target extension, with identifier specified as com.companyName.AppName.ExtensionName and create provisioning profile with this AppID.
Also, the appGroupID created should be embedded in both the AppIDs(for application as well as extension).
Since you didn't share any piece of code, I cannot help you with a specific answer. Please try to debug your widget by using following steps Debug->Attach to Process->(select your widget from the menu) and debug your viewdidload viewwillappear and - (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler methods. Hope it helps.
The sources of my problems:
on simulator viewDidLoad was called each time, on the device the view is loaded once and only viewWillAppear is called.
the widget does not receive core data changes notifications
do not call NCWidgetController.widgetController().setHasContent from widgetPerformUpdateWithCompletionHandler. The best place to use it (mostly) is your containing app, not the widget itself.
hope this helps someone
In my case I set preferred content size and it is starting working on device
self.preferredContentSize = CGSizeMake(UIScreen.mainScreen().nativeBounds.width, 100.0)
I had an issue using custom ViewController in my Share Extension. It turns out that the resources are limited in Extension mini-apps, so when my Extension was generating thumbnails, it crashed the extension because too many background threads were being used. Reducing thumbnail generation to a single one at a time fixed the issue.
The confusing part was that this limitation was not seen in Simulator, only on a real device.
Related
iOS 10 / Xcode 8 GM build getting the below, never had it before on Xcode 7. Any ideas?
objc[25161]: Class PLBuildVersion is implemented in both
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices
(0x12049a910) and
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices
(0x1202c4210). One of the two will be used. Which one is undefined.
(NOTE: Only seems to happen in simulator, does not appear on real device).
Main Idea
Main idea is simple:
If your app (or dependencies, such as Pods) uses framework, that uses explicit (or implicit) PhotoLibraryServices.framework or AssetsLibraryServices.framework as dependency, Xcode warns you (even if you are using only one of them). It might be Photos/PhotosUI.framework or AssetsLibrary.framework, or another (I don't have full list of dependencies, but it is possible).
What is the problem?
Class with name PLBuildVersion is defined in both PhotoLibraryServices.framework and AssetsLibraryServices.framework. Class name is unique in Objective-C (you can't define 2 classes with same name), so it is undefined which one will be used in runtime.
However, I think that it will not be a problem, because both classes have same methods and fields (checked this with disassembler) and I guess that both were compiled from the same source.
Radar is already sent.
As per answer from Apple employee on Apple's Developer Forum:
You don't control either of the class sources listed, so there isn't anything you can or should do – aside from Reporting a Bug.
I was unable to find a way to get rid of the warning, but if you want to prevent the app from crashing, you need to provide a description for why you are accessing the camera, photo library, etc. This is new in iOS10.
Input the following into your Info.plist file.
Photo
Key: Privacy - Photo Library Usage Description
Value: $(PRODUCT_NAME) photo use
Camera
Key: Privacy - Camera Usage Description
Value: $(PRODUCT_NAME) camera use
More info can be found here: https://iosdevcenters.blogspot.com/2016/09/infoplist-privacy-settings-in-ios-10.html
I find you can get this error merely by using a UIWebView. My solution was to replace my use of UIWebView with WKWebView.
I had this after adding Answers on Fabric to my project.
Deleting derived data did the trick for me. (shift alt command k in XCode)
Edit a year later:
After deleting derived data, always exit XCode and start it again.
In unrelated cases I have the impression that deleting derived data does not clear XCode’s in memory caches of the derived data.
Resetting the iOS simulator fixed this for me. Simulator -> Reset Content And Settings.
In my case this warning started to appear after opening a second xcode project and running the second app on the simulator. After changing back to the first app, the warning started to appear. I just quit the Simulator and Xcode and reopened my project. The warning disappeared after that. If that doesn't solve it, proceed with the other answers. Xcode can be really picky sometimes.
I am trying to debug and run the app on apple watch simulator. I have tried by using different target for notification, Glance and Watch app but apple simulator don't shows any thing.. It stuck in waiting for attach process of extension. I just see a black screen for the Apple Watch Simulator.
What did I do wrong?
How to overcome this issue ?
This post from the dev forums solved my issue. More specifically, this excerpt:
In order for Watch apps to function properly, certain properties
must match across the Watch app and its App Extension (18857540):
The WKAppBundleIdentifier property of NSExtensionAttributes in the WatchKit App Extension’s Info.plist must match the
CFBundleIdentifier of WatchKit App's Info.plist.
The WKCompanionAppBundleIdentifier property of the WatchKit App's Info.plist must match the CFBundleIdentifier of the Containing iOS App's Info.plist.
I have exactly same problem. I created a new project and added WatchKit extension in Xcode 6.2 beta 4 with WatchKit. I tried all ways mentioned in other answers but still failed to let watch app run in the simulator. Finally, I made it work.
My steps:
Delete the containing app in the iPhone simulator.
Clean your project in Xcode.
Do not run the containing app, run the WatchKit app from Xcode.
I had the same issue. The only thing that helped was to delete and recreate the target scheme.
Before spending a lot of time on changing things, restart Xcode. Sometimes, this solves the problem.
Even if everything is configured correctly, it may take 20 seconds to attach the process to the debugger.
You need to run the Watch App target and then from iPhone/iPad simulator check (Hardware -> External displays), any one of the Apple Watch options.
I was experiencing the same issue. Mainly when creating an app extension in an existing app.
I was able to consistenly solve it by doing the following steps:
Make sure that the app extension gets the .appex extension. XCode tends to set it to .app. You can do this under 'build settings' -> 'wrapper'.
Under the 'Build Phases' tab in your target, your app extension should be listed under 'Embed App Extensions'. If you don't see this section, you can enforce it by adding a normal app extension to your app (fe. action extension). The section will now be visible. Replace the dummy extension you just created with the Watch app extension.
Start the host app and then start the Watch app, it should be working now.
I had some trouble on iPhone 6 simulator, but each time I switch on iPhone5S it works.
In my case the trouble was caused by a scheme with missing target although not the one I was trying to run.
Hope that helps somebody.
I was running into this problem as well and tried a few of the suggestions above. I found that deleting and recreating the target scheme resolved it. Everything is working fine now.
I'm trying to distribute a simple today widget with an ad-hoc profile.
The widget works flawlessly when invoked from XCode in debug mode,
but appears empty when the ad-hoc app is installed on the device.
I've asserted that
the provisioning profile is correct
the app (which has almost no code) launches and displays the trust request
preferredContentSize has been set
the widget appears in the widget list (edit mode)
the widget appears in the notification center, with its title,
but with zero height.
Any clues? Thanks.
UPDATE:
the widget is actually executed (loadView, viewDidAppear, ...) but crashes. Given that its almost empty, and it works in debug mode, it's pretty strange. The crashreport has no useful info.
UPDATE 2:
Adding an MKMapView to the controller's view makes it crash. Pretty strange.
It seems the widget crashes due to memory pressure. MKMapView is known to
be memory hungry.
Few things you can check:
Is your bundle identifier different on the ad hoc profile? If so, you'll need to create a new info.plist for both Extension and App so they match.
Are you using any dependencies that don't support 64bit (Arm64)? I've seen an issue where the extension binary wasn't created correctly with older frameworks that don't support 64bit. It worked fine on armv7 devices but didn't show up on arm64 as you describe.
Are you using a app group container? The names must match on the ad hoc profile.
That's all I can think of at the moment. I had a similar issue running iOS 8 beta where I would have to restart the device every now and then to resolve the symptom you describe, but not with the release version as of yet. Hope this helps.
- (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.
After moving to XCode 5 and the iOS7 base SDK, some of the UI widgets in my app still look like iOS6-style (gradients, frames) on iOS7 devices. This doesn't happen on the equivalent emulator for iOS7. This also doesn't happen for all widgets, UIDocumentInteractionController's popup looks like iOS7 on device, but UIPopoverController doesn't. The keyboard for renaming a file also shows this discrepancy between emulator and device.
How does iOS determine the visual style of UI elements? Is it based on a statically linked library or something determined at runtime? I've tried purging the app from the device completely, but no change.
Emulator for retina iPad: UIPopoverController
iPad 3rd gen with iOS 7: UIPopoverController
The code in this case is fairly straightforward, no customization of the rendering or layout.
self.poController = [[UIPopoverController alloc] initWithContentViewController:audioCopyController];
[audioCopyController showDoneButton:NO];
audioCopyController.view.frame = CGRectMake(0,0,350,250);
_poController.popoverContentSize = audioCopyController.view.bounds.size;
_poController.delegate = self;
[_poController presentPopoverFromRect:view.audiocopyButton.frame
inView:view
permittedArrowDirections:UIPopoverArrowDirectionDown
animated:YES];
Thanks for the help in advance.
Check you Project config file and Target config file.
It is probably set with an iOS 6.X base SDK.
For this:
Go to your project config file in Xcode 5
Click the Build Settings tab
Edit the base SDK field to switch it to iOS 7.
Sometimes, we've experienced issues with Xcode not taking the current setting into account.
Changing it and compiling helps it understand that it needs to be changed.
Make sure you configure this correctly for your Project config and each and every target config file you run this from.
You might well have 2 different targets for simulator and for your devices.
Hope this helps
Regards
David
Ok, I found out what the problem was. David's suggestion got me thinking.
I am maintaining multiple apps at the same time, and one of them is quite old. The new Interface Builder in XCode5 breaks the transparency for a lot of the fields in the old app so I was keeping XCode4 in a separate installation folder alongside of XCode5. It seems that somehow my XCode5 project was still pointing at the SDK folders of XCode4 (not sure how this was possible, looking at the actual linker command line would probably shed some light), so after deleting XCode4's 6.1 SDK folder from my machine, a clean build with XCode 5 produced the correct iOS 7-looking widgets in my iOS-supported app.
The moral of the story is, be very careful with multiple XCode/SDK installations on the same machine. Hopefully this can help other folks who may be trying something similar to provide support for legacy apps.