I searched SO ,find nothing about PBItemCollectionServicer.
My question become form my app crash(because of memory rise violently), then print:
PBItemCollectionServicer connection disconnected.
The screen shot:
I have no idea about the PBItemCollectionServicer, whats mean of that?
and how does it work?
why it print here?
Is it relate to my app crash?
Edit -1
As Nir's comment, he suspect if I use the under link framework.
https://github.com/JaviSoto/iOS10-Runtime-Headers/tree/master/PrivateFrameworks/Pasteboard.framework
No , I didn't, I searched my project with no result:
Well, I guess those annoying PBItemCollectionServicer logs appear seconds after you copied (Command+ C) something into your iOS devices or iOS simulator which is running apps via Xcode.
The "universal clipboard" service (seems to) collects strings or images to share between your own iCloud devices (Mac, iOS devices ...)
It works in Sierra & iOS 10 environment
Check this article
This log happens only when under simulator/iOS device while running on Xcode, I think.
I don't know why Xcode team let this somewhat should-be-hidden log displayed... for developers? But couldn't find any documentation... blah blah
"PBItemCollectionServicer connection disconnected." also logs when using iOS 11 table view drag-and-drop and completing a drop. It's benign there, from all I've observed.
I was receiving:
Console Log: "PBItemCollectionServicer connection disconnected."
all of a sudden while debugging an iPhone app while connected via the USB cable to my MacBook.
After a bit of searching it turned out that it was hanging for some time because of this line of code where I was clearing the pasteboard:
[pasteBoard setValue:#"" forPasteboardType:UIPasteboardNameGeneral];
After a lot of google searching without any luck I noticed that it only happens when the iPhone was connected to my Mac.
It turned out to be the shared clipboard causing the hang/delay and log message.
If you turn off "Handoff" on the iPhone (Settings/General/Handoff) and Mac (System Preferences/General/Allow Handoff) then the problem was resolved.
The problem also goes away when you disconnect the USB cable from the Mac so it doesn't affect regular use.
For me, the error occurred when PHAssetCollection fetchAssetCollectionsWithType : called with a block predicate:
PHFetchOptions *fetchOptions = PHFetchOptions.new;
// correct
fetchOptions.predicate = [NSPredicate predicateWithFormat:#"localizedTitle = %#", targetAlbumName];
// wrong
// crash with the error message "PBItemCollectionServicer connection disconnected."
//fetchOptions.predicate = [NSPredicate predicateWithBlock:xxx];
PHAssetCollection * assetCollection = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:fetchOptions].firstObject;
I found that when working with drag and drop this error gets cleared up when adding
view.addInteraction(UIDropInteraction(delegate: self))
to the viewDidLoad of the view you are dropping into.
Firstly, this is not an answer to the question. And I failed to find one. It's just some information I think may be helpful for someone who can dig into this and find an answer.
I was tinkering with the copy(_:), cut(_:) and paste(_:) functions of UITextField. Almost every time I did copy/cut/paste in in field, the Xcode gave this message:
2020-07-17 15:45:38.796510+0800 MyApp[3062:1763915] [general] Connection to daemon was invalidated
2020-07-17 15:45:54.179188+0800 MyApp[3062:1763859] PBItemCollectionServicer connection disconnected.
2020-07-17 15:46:53.097783+0800 MyApp[3062:1763859] PBItemCollectionServicer connection disconnected.
2020-07-17 15:46:57.180499+0800 MyApp[3062:1763859] PBItemCollectionServicer connection disconnected.
2020-07-17 15:48:34.901502+0800 MyApp[3062:1764656] PBItemCollectionServicer connection disconnected.
The only relevant code is an extension to UITextField:
extension UITextField {
open override func copy(_ sender: Any?) {
print(sender)
print(text)
}
open override func paste(_ sender: Any?) {
print(sender)
print(text)
}
open override func cut(_ sender: Any?) {
print(sender)
print(text)
}
}
And none of them was called. How weird. Then I commented out this extension, and to my surprise, Xcode still gave the exactly same message. Anyway, after I searched here and there, I found this in Apple Developer Forums, which is discussion about the failure of UIDropInteraction with the same error message. As all the other answers mostly talked about UIPasteboard, I think it is necessary to put it here although it doesn't contain a solution or answer.
I tried running on both Simulator(13.5) and device(13.4.1), with Xcode 11.5, and got the same error message.
I was also receiving a PBItemCollectionServicer connection disconnected line in the console log, when testing an UICollectionViewDragDelegate implementation.
It turned out that my Info.plist file didn't have that required NSUserActivityTypes configuration with the activity identifier of the NSUserActivity used in the NSItemProvider as part of the dragged UIDragItem. After fixing this, the drag-and-drop action finally worked, and the console did log the mysterious line anymore.
In order to make sure drag-and-drop works for you,
you need to specify your type identifier (e.g. com.xxx.TodoList.todoItem) in Info.plist like this:
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.text</string>
</array>
<key>UTTypeDescription</key>
<string>com.xxx.TodoList.todoItem</string>
<key>UTTypeIconFiles</key>
<array/>
<key>UTTypeIdentifier</key>
<string>com.xxx.TodoList.todoItem</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array/>
</dict>
</dict>
</array>
Related
The bounty expires in 4 days. Answers to this question are eligible for a +50 reputation bounty.
Cedric wants to draw more attention to this question.
I got it to work on Android, the WebViewWidget displays correctly with the html content, no problem.
For iOS it just displays blank/white. I tried what I have seen suggested by people all over the internet, which is to add a few lines to Info.plist, that allow the WKWebView in iOS to load and display http (not secure, not only https):
<key>io.flutter.embedded_views_preview</key>
<string>YES</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
(^^I don't really know what these lines individually do)
(^^I have also tried lowercase "yes" and <true/> as values for the first one)
I ran flutter clean, then flutter pub get, deleted Podfile.lock, ran pod install (in the ios folder) a bunch of times, but I still can't get the content to show in the webview on iOS (it works on Android), only blank white space where the html content is supposed to appear.
It's important to mention that I get my html from neither http nor https, but I load a String (which is html) and set it like this:
String text = ...
await _controller.loadHtmlString(text);
Is there maybe a way of tricking iOS to think that the html comes from https?
These are some common messages I see printed out in the console (not red, just regular color), and I only get these messages when running the app from android studio, not XCode (on a real iOS device):
[assertion] Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}>
[ProcessSuspension] 0x12d07df20 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'ConnectionTerminationWatchdog' for process with PID=47861, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}
and:
Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service
UPDATE: I found out, it also shows a blank/white page on iOS even when I use https, like _controller.loadRequest(Uri.parse('https://flutter.dev'));.
I solved the problem, it was unexpected and not related to http/https stuff... See the comments in below code for explanation
_controller.setNavigationDelegate(
//...
onNavigationRequest: (NavigationRequest request) {
print('onNavigationRequest');
//I first had this line to prevent redirection to anywhere on the internet via hrefs
//but this prevented ANYTHING from being displayed
// return NavigationDecision.prevent;
return NavigationDecision.navigate; //changed it to this, and it works now
},
);
I also removed all those lines from Info.plist, and it still works.
Since the update to IOS 13 importing custom UTI files is not working (works perfectly on devices with 12.4)
I've downloaded the simple working project form this page: https://www.raywenderlich.com/813044-uiactivityviewcontroller-tutorial-sharing-data , which i also used as a base for the sharing system of my app.
On IOS 13 (12.4 works), when get the sample file (from email o data folder) and click on Copy To App, IOS goes back to the main screen, and after a few seconds i get a Safari crash error.
This is the project info.plist section for exporting files:
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>Book Tracker Document</string>
<key>UTTypeIconFiles</key>
<array>
<string>book_320.png</string>
<string>book_64.png</string>
<string>book_44.png</string>
<string>book_22.png</string>
</array>
<key>UTTypeIdentifier</key>
<string>com.raywenderlich.BookTracker.btkr</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>btkr</string>
<key>public.mime-type</key>
<string>application/booktracker</string>
</dict>
</dict>
</array>
</key>
Things i tried:
Add an UTImportedTypeDeclarations, with the same details as UTExportedTypeDeclarations ones as there is none in the project ---- STILL CRASH
In this post about at the end, was suggested to remove the section from the info.plist (Not modifying the Document Types section) and create it anew from the interface ---- STILL CRASH (it also causes an infinite loop in xcode when adding array items for public.filneame-extension or mime-type)
Various combinations of the solutions above
This is the main error i always get:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
terminating with uncaught exception of type NSException
Full log is here: log
I'm kind of out out ideas! Please help!
I don't have the answer to your question but I have a similar problem with this same sample app from Ray Wenderlich. Unfortunately the comment section for this tutorial is closed.
I am using the "finished" version which has all the UTI information already set.
In my case I want to save the ".btkr" document to the Files application. That works OK but then if I tap on the .btkr document saved in Files, it opens the BookTracker application but quietly fails in the Book.swift importData(from url: URL) method.
I unraveled the guard statement into do/try/catch blocks and what I see is "The file “New Book.btkr” couldn’t be opened because you don’t have permission to view it." This is being thrown from the "let data = try Data(contentsOf: url)" statement.
The odd thing is if I share the same document via eMail, a tap on the .btkr attachment successfully opens the app and imports the .btkr just fine. Share via AirDrop works as well.
I do not know if this is only an iOS 13 bug because I no longer have any devices with older iOS's. Since the tutorials from Wenderlich are generally very good (this one is from February 2019, before iOS 13) I suspect your problem and my problem are iOS 13 bugs.
I'm seeing exactly the same thing here on my app. Wrapping readFromURL and writeToURL in between startAccessingSecurityScopedResource & stopAccessingSecurityScopedResource helped on my iPad running iOS 13.2.3, but I'm still seeing the Safari crash and unable to open the documents on the iPhone running 13.2.2.
I just installed the first iOS 11 beta to an iPhone 7 and am interested in trying the NFC. There's nothing about it in settings. I am wondering if there's any sample code out there showing how to read a tag. Can anyone show how to use the Core NFC SDK, in a code snippet?
In the Apple Developer site, create a new App ID and make sure that NFC Tag Reading is enabled.
Add the following lines to your .plist file:
<key>NFCReaderUsageDescription</key>
<string>NFC Tag!</string>
and these to the entitlements file:
<key>com.apple.developer.nfc.readersession.formats</key>
<array>
<string>NDEF</string>
</array>
It should look something like this in the corresponding files:
Also Core NFC can be enabled via the Capabilities tab in Xcode.
Objective-c
Import CoreNFC
#import <CoreNFC/CoreNFC.h>
and set the delegate:
#interface YourViewController : UIViewController <NFCNDEFReaderSessionDelegate>
In viewDidLoad:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NFCNDEFReaderSession *session = [[NFCNDEFReaderSession alloc] initWithDelegate:self queue:dispatch_queue_create(NULL, DISPATCH_QUEUE_CONCURRENT) invalidateAfterFirstRead:NO];
[session beginSession];
}
In the delegate callback:
- (void) readerSession:(nonnull NFCNDEFReaderSession *)session didDetectNDEFs:(nonnull NSArray<NFCNDEFMessage *> *)messages {
for (NFCNDEFMessage *message in messages) {
for (NFCNDEFPayload *payload in message.records) {
NSLog(#"Payload data:%#",payload.payload);
}
}
}
You must also add the didInvalidateWithError delegate callback or you'll not conform with protocol:
- (void)readerSession:(nonnull NFCNDEFReaderSession *)session didInvalidateWithError:(nonnull NSError *)error {
}
You can stop the reader with:
[session invalidateSession];
Swift 3/4
Import CoreNFC
import CoreNFC
and set the delegate:
class YourViewController: UIViewController, NFCNDEFReaderSessionDelegate
In viewDidLoad:
override func viewDidLoad() {
super.viewDidLoad()
let session = NFCNDEFReaderSession(delegate: self,
queue: DispatchQueue(label: "queueName", attributes: .concurrent), invalidateAfterFirstRead: false)
session?.begin()
}
In the delegate callback:
func readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage]) {
for message in messages {
for record in message.records {
print(record.payload)
}
}
}
You can stop the reader with:
session.invalidateSession
Usage
After launching the view you should immediately see the iOS NFC reader dialog like so:
Once this dialog appears you have about a second to place the iPhone near the NFC tag you want to read. Otherwise, the field is deactivated (this seems to be a bug on Apple's end). I often needed to cancel and retry to get consistent readings. More details here.
To fix this issue you can add com.apple.developer.nfc.readersession.formats key into your entitlements file. The key should be associated with the array of enabled NFS types.
For instance, you can try the following:
<key>com.apple.developer.nfc.readersession.formats</key>
<array>
<string>NDEF</string>
</array>
It worked for me.
Updated for second Xcode beta.
Add the NFC capability to your app from the Developer Center. Identifiers -> App IDs -> enable "NFC Tag Reading".
If your project does not have an entitlement file, let Xcode create one for you by just activating and then subsequently deactivating any capability from within Xcode -> Project Targets -> Capabilities. You will find a new [AppName].entitlements file in your project navigator. Right-click on that file and select "Open as -> Source Code". Enter the following entry manually between <dict></dict>:
<key>com.apple.developer.nfc.readersession.formats</key>
<array>
<string>NDEF</string>
</array>
As soon as Xcode 9 allows enabling NFC Tag Reading from the Capabilities selection this step becomes obsolete because all you have to do is to enable it there. The current (first) Beta version does not support this.
You also need to enter a usage description for the privacy warning iOS will show the user. (At the moment (beta 1) this warning will be displayed when the device is ready to scan and shows a native system dialogue which will include this message. However, this seems to be unploished.) Open your target's Info.plist and start typing "Privacy" and you can scroll down to "Privacy - NFC Usage Description" to select it by hitting return. Enter a meaningful explanation to your user in the right column.
Now you should be able to import CoreNFC, in Swift:
import CoreNFC
Then head over to Apple's documentation.
Important: If the compiler returns an error with No such module 'CoreNFC' check if you have selected an actual iOS 11 device to build for, not a simulator. It also has to be the iPhone 7 or 7 plus. This might change in a future version, but testing NFC will only ever be fully working with actual hardware. (cp. Core Bluetooth where you can run on Simulator but not test the actual capabilities.) Beta 2 doesn't have this issue anymore. However, actual hardware in form of iPhone 7/p is still required for actual testing.
Just to enrich previous answers, it's important to bear in mind these considerations specifically of the NFCNDEFReaderSession class:
Reader session for processing NFC Data Exchange Format (NDEF) tags. This session requires the "com.apple.developer.nfc.readersession.formats" entitlement in your process. In addition your application's Info.plist must contain a non-empty usage description string.
A NDEF reader session will automatically scan and detect NFC Forum
tags that contain a valid NDEF message. NFC Forum Tag type 1 to 5
that is NDEF formatted are supported. A modal system UI will present
once -beginSession is called to inform the start of the session; the
UI sheet is automatically dismissed when the session is invalidated
either by the user or by calling -invalidateSession.
An opened session has a 60 seconds time limit restriction after -beginSession is called; -readerSession:didInvalidateWithError: will return NFCReaderSessionInvalidationErrorSessionTimeout error when the time limit is reached.
Only 1 active reader session is allowed in the system; -readerSession:didInvalidateWithError: will return NFCReaderSessionInvalidationErrorSystemIsBusy when a new reader session is initiated by -beginSession when there is an active reader session.
-readerSession:didInvalidateWithError: will return NFCReaderSessionInvalidationErrorUserCanceled when user clicks on the done button on the UI.
-readerSession:didInvalidateWithError: will return NFCReaderSessionInvalidationErrorSessionTerminatedUnexpectedly when the client application enters the background state.
-readerSession:didInvalidateWithError: will return NFCReaderErrorUnsupportedFeature when
reader mode feature is not available on the hardware
client application does not have the required entitlement.
You need to make sure the usage description is in place and also add the capability to the app inside of the Apple Developer Center.
I have a tutorial based on my experience (Swift 4-based). It's available here: Core NFC Tutorial
I added Core NFC to a project using the resources in these answers. One additional thing that wasn't noted though was that even if you add the capability manually via the entitlements, Xcode doesn't seem to look at the file unless you have a capability turned on. This is probably due to Xcode 9 Beta 1 not having Core NFC as a capability switch for lots of people's sample projects. So just be sure to turn at least one other capability on if you're still seeing issues! I was seeing an unexpected termination error immediately return until I did this.
I would leave this as a comment as it belongs, but don't have enough reputation yet to do so. Figured this was important enough to note.
my two cents:
1) under xcode 9.0 (beta 4 9M189t ) if You have already added capabilities,
no need to manually add:
<key>com.apple.developer.nfc.readersession.formats</key>
<array>
<string>NDEF</string>
</array>
it is done automatically
2) no crash if not using iPhone 7 OR you are in simulator:
You wil be called in:
func readerSession(_ session: NFCNDEFReaderSession, didInvalidateWithError error: Error) {
print(error.localizedDescription)
}
it will show:
"Feature not supported"
3) dont miss:
self.nfcSession?.begin() // will trigger callback
so:
final private func setup(){
self.nfcSession = NFCNDEFReaderSession(delegate: self, queue: nil, invalidateAfterFirstRead: true)
self.nfcSession?.alertMessage = "Put your NFC TAG over iPhone.."
self.nfcSession?.begin() // will trigger callback
}
4) if user cancels, you will get:
"Session is invalidated by user cancellation"
in didInvalidateWithError callback.
I keep getting
"Error Domain=com.facebook.sdk.login Code=308 "The operation couldn’t
be completed. (com.facebook.sdk.login error 308.)""
upon trying to login with Facebook from my device.
My code works on the simulator, but not on an actual device. Has anyone ran into this error code before? I'll be more than happy to share code upon request.
The solution below works for iOS9 + running on Xcode 8, for Swift3.0
The steps are
Setup Facebook Launch
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
Setup Open Url
guard let source = options[UIApplicationOpenURLOptionsSourceApplicationKey] as? String else { return false }
let annotation = options[UIApplicationOpenURLOptionsAnnotationKey] as? String
return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: source, annotation: annotation)
Fix Keychain permission issue as shown in the image below
One solution, at least for me, is to not run on device via the Xcode debugger. If I run the app on device outside the debugger the Facebook login works fine. If I run the app in the sim via the debugger the Facebook login works fine.
Only if I run the app on device via the Xcode debugger do I get the com.facebook.sdk.login error 308 every time.
You should enable Keychain Sharing on the Capabilities tab.
I had exactly the same problem and was able to find the solution by modifying the Info.plist
I've added all the possible schemes to LSApplicationQueriesSchemes
The complete list looks like this:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fbapi20130214</string>
<string>fbapi20130410</string>
<string>fbapi20130702</string>
<string>fbapi20131010</string>
<string>fbapi20131219</string>
<string>fbapi20140410</string>
<string>fbapi20140116</string>
<string>fbapi20150313</string>
<string>fbapi20150629</string>
<string>fbauth</string>
<string>fbauth2</string>
<string>fb</string>
<string>fb-messenger-api20140430</string>
<string>fb-messenger-platform-20150128</string>
<string>fb-messenger-platform-20150218</string>
<string>fb-messenger-platform-20150305</string>
<string>fb-messenger-api</string>
<string>fbshareextension</string>
</array>
I'm getting the exact same thing FB SDK 4.6.0 Xcode 7.0 iOS9. All the setup & instructions on the facebook developer site were followed to the letter.
None of the above solutions worked for me. I'm finding that the behaviour is worse when you're deploying to the device live and feeding back to the Xcode console while doing the login procedure. It's really pot luck if it actually logs you in or not. It seems to behave in a more predictable way when you just re-launch your app cold after deployment. -Yes this is in fact the case!
When it decides to fail to login it results in the following error:
Error Domain=com.facebook.sdk.login Code=308 "(null)"
My solution on Xcode7.1, Swift2.0
Step 1. Clean your build folder: option + command + K
or: Choose Product > Clean
Step 2. Clean your derived data: Choose Window > Projects:
and then choose Delete:
I had the same problem and fixed it refreshing the system credentials
[FBSDKLoginManager renewSystemCredentials:^(ACAccountCredentialRenewResult result, NSError *error) {
[[[YourAuthManager manager] facebookLoginManager] logInWithReadPermissions:#[#"email"] fromViewController:nil handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
// Handle error
} else if (result.isCancelled) {
// Handle cancellations
} else {
// If you ask for multiple permissions at once, you
// should check if specific permissions missing
if ([result.grantedPermissions containsObject:#"email"]) {
// Do work
}
}
}];
}];
This solution is less radical than reinstalling and you assure your users won't have to do it. My guess is that FBSDK 4.6 has some conflicts with iOS 9 system FB authentication credentials.
Edited: After some time testing it kept happening, not as often as before but it was still an issue, so we downgraded to a previous version of FB SDK. Hopefully someone finds a better solution.
Did some digging around in FBs code and it looks like this is simply an entitlements issue.
FB uses the keychain to store an authorization challenge during login. When returning it attempts to get the value from the keychain and fails. See this SO answer for more info.
Security entitlements can change between provisioning profiles, and as we all know, keeping our profiles and build configurations and devices/sims straight is like herding cats. This could explain why people experience such inconsistent behavior.
So it might be safe to assume that in a production environment, everything will work fine, and if things aren't working during testing then you need to double-check the entitlements on your provisioning profiles.
In my case it was fixed by updating to latest FB SDK. 4.10 at the moment.
I fixed the problem by uninstalling the app and re-installing and it worked right away.
The error is probably related to iOS 9. Since iOS 9, I think the SDK uses SafariViewController and it seems to create issues when you are already logged.
I was getting the same error on xcode 7.1 ios 9.1 FB SDK 4.7.1. .
Uninstalling, installing and testing without xcode works fine for the first time.
This will allow you to plug back in the device and run it at least a couple of times (it seems to be a bit inconsistent...)
Same problem FB SDK 4.5.1 and none of the above solutions worked for me.
I solved this by adding Bolts framework to project by drag & drop (from FacebookSDK directory)
and then adding bolts framework to appDelegate
#import <bolts/bolts.h>
In the FBSDKDelegate Method loginButtonWillLogin put this
- (BOOL) loginButtonWillLogin:(FBSDKLoginButton *)loginButton{
[FBSDKAccessToken setCurrentAccessToken:nil];
return YES;}
Updating to the latest (4.11) FB SDK fixed this for me as well. Don't forget to clean your project after updating to see if it works for you!
I was able to get login working again on iOS9 with SDK 4.6.0 by adding the new plist key/value
<key>FacebookDisplayName</key>
<string>{Your App Name}</string>
Source code.
I also took the steps in some other answers here to implement a shared FBSDKLoginManager() instance.
To Resolve this issue you needs to just enable "Keychain Sharing" in capabilities.
I followed Suraj Pathak with Xcode 9.4.1 and Swift 4.2
Add to AppDelegate didFinishLaunchingWithOptions
SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
Add to AppDelegate delegate function
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
return SDKApplicationDelegate.shared.application(app, open: url, options: options)
}
Allow Keychain in Capabilities.
If you are using FBSDK 4.38 there is a bug with the parsing of challengeExpected in FBSDKLoginManager.m.
I found a hot fix of rinat-enikeev for it:
https://github.com/facebook/facebook-sdk-swift/issues/286
https://github.com/facebook/facebook-objc-sdk/pull/922/commits/bcf7f787e92320a6322fb3f6130fdc3815bbafb7
Just change
NSString *challengeExpected = [self loadExpectedChallenge];
to
NSString *challengeExpected = [[self loadExpectedChallenge] stringByReplacingOccurrencesOfString:#"+" withString:#" "];
Thats solved the issue for me.
I am having a hard time to get HealthKit working for my iOS App. I have done all the steps I have found so far and none seem to solve my problem I keep getting this error when trying to authorize Healthkit:
Error Domain=com.apple.healthkit Code=4 "Missing com.apple.developer.healthkit entitlement." UserInfo=0x78fa24e0 {NSLocalizedDescription=Missing com.apple.developer.healthkit entitlement.}
Here is my code asking for authorization:
if([HKHealthStore isHealthDataAvailable]) {
self.healthStore = [[HKHealthStore alloc] init];
[self.healthStore requestAuthorizationToShareTypes:nil readTypes:[self dataTypesToRead] completion:^(BOOL success, NSError *error) {
if (!success) {
NSLog(#"HK Error: %#", error);
[self presentHealthAlert:#"You didn't allow APP to access HealthKit Data. Please go to Settings and set up APP permissions." withTitle:#"Error"];
} else {
[self presentHealthAlert:#"Thank You For Access" withTitle:#"Success"];
}
}];
} else {
[self presentHealthAlert:#"Health Data Not Available" withTitle:#"Success"];
}
And Yes, I have enabled it on my project Capabilites, and yes I have enabled it in my Dev Center App ID. Is there anything else I might be missing?
I had this problem with a watchOS 2 app. The resolution was to ensure I had enabled the HealthKit entitlement for both the iOS app and the watch extension.
I had wrongly assumed the switch for the iOS app would be inherited by the watch extension.
You have to make sure that you click on your program on the left side of Xcode (the top of your file hierarchy). You'll come to a general settings screen in the main window (to the right) where you will see your bundle identifier, deployment target, and additional settings. Click on the tab at the top that says Capabilities. Now you will see a toggleable list which includes HealthKit. You have to activate it here before you can use it in the app.
Edit: Here is an image from Xcode that might help you find this if you're not familiar with setting dependencies or other program specific settings.
It is in this list on the right, towards the bottom you'll see HealthKit. It will check several things once you toggle it on and verify that you can use it.
A bit old, but for anyone else who has issues, I had to manually refresh my provisioning profiles as well in XCode 6.2 (Preferences -> Accounts).
I ended up here after reaching my wit's end. Nothing worked and I clearly had the HealthKit entitlement enabled so finally I just restarted the phone. Voilà. Restarting cleared the missing entitlement errors.
Click on the Watch App Extension target.
Tap on the Capabilities.
Scroll down to the bottom and turn on the HealthKit.
I managed to get my entitlement working by ensuring that I had a device registered. Once I got my iPhone showing under the simulator and I didnt have any unresolved issues under the identity section of the app it all loaded ok.
You may find that although you have turned on the HealthKit entitlement on in xcode that there is a second entitlements file that does not contain the healthkit boolean. I found that while the obvious entitlements file (at the top level) had the correct information, a different entitlements file had been created under Resources that did not contain the healthkit entitlement. fixing that file fixed my problem.