cannot transfer file to watch

I have an iOS app that sends data to a watch running watchOS 4 beta 8. The iPhone is running iOS 11 beta 8.

The file is send like this:


- (void)sendFileToWatch:(NSString *)filePath withType:(NSString *)type andMetaData:(NSDictionary *)extraMetaData {
    if (filePath && type && [self sessionIsReadyForCommunication]) {
        NSURL *fileUrl = [NSURL fileURLWithPath:filePath];
        NSMutableDictionary *metaData = [@{FileMetaDataNameKey: fileUrl.lastPathComponent,
                                           FileMetaDataTypeKey: type} mutableCopy];
        if (extraMetaData) {
            [metaData addEntriesFromDictionary:extraMetaData];
        }       
        [self.watchConnectivitySession transferFile:fileUrl metadata:metaData];
    }
}


The delegate method is called

- (void)session:(WCSession *)session didFinishFileTransfer:(WCSessionFileTransfer *)fileTransfer error:(NSError *)error {
    NSString *fileName = fileTransfer.file.fileURL.lastPathComponent;
    [self.analyticsManager logWatchFileSent:fileName error:error];   
}

with the error being:

Error Domain=WCErrorDomain Code=7013 "WatchConnectivity session cannot access the file."
UserInfo={NSLocalizedRecoverySuggestion=Verify the file path is accessible.,
          NSLocalizedDescription=WatchConnectivity session cannot access the file.,
          NSLocalizedFailureReason=Invalid file path, or insufficient permissions to access the file.
}


this does not happen in the non-beta versions. The error is nil there. I have filed a bug report and it was closed as dublicate to an open bug.


My question: Did you experinced something similar and found a workaround? Thanks

Replies

Hi,


Sorry to hear you have hit a bug. Is the file being sent hosted in a shared app group container? If so, one thing you can try is to copy or move that file to the app's own container and then try the transfer. Obviously this should be considered a workaround until the actual system bug is fixed.

Hi tweedeviking,

I´m experiencing the same error. Have you already found a workaround or implemented the workaround explained by viking? Could you please forward the reference to the bug report (is there a way to monitor whether someone at Apple is working against this bug?)

I too am experiencing the same error, with GM seeds of ios 11 and watchos 4. I do happen to be sending from a shared group container.

Exact same code works flawlessly with ios 10/watchos 3.

I'll try implementing saving/sending the file from the local app sandbox, and report back

Report: sending files works just fine when they aren't stored in the shared container. Use that as a workaround, and you'll be good to go.

Still an issue in iOS 11.0.1. But thankfully, I found this thread and was able to quickly implement a fix: copy the file I want to transfer from my shared container to the app's caches directory and transfer that copy.

I just found this thread after experiencing the same problem.

I have an app that's been using the shared container as the payload file holding place prior to calling [[WCSession defaultSession] transferFile

It's been on the App store for 6 months and has worked fine.

Now I'm using Watch OS 4.1 beta (which I can't seem to get rid of and go back to the standard release), iOS 11.0.3 & XCode 9.0.1 I get "access denied" in the logs when transferFile is called.

I switched to storing the file in NSTemporaryDirectory() instead of the share container and it all started working again.


EDIT:

I should have mentioned that it worked fine on the simulator "iPhone 8 Plus + Apple Watch Series 3 42mm" (11.01 & 4.0 resp)

The issue was with my own iPhone 6 Plus & Series 1 42mm (11.0.3 & 4.1beta resp)


Question is: Which one is correct and which do I release into the wild?