Why sending a file to watchOS2 simulator from iPhone simulator will not work?

I am trying to copy a database from iPhone iOS 9 to watchOS 2 Apple Watch (both simulators) and nothing. File / s are / not found. (search everywhere)

I want to transfer the database when I enter the application from iPhone to Apple Watch, even if the application on iPhone is turned on (the application on watchOS2 is turned off). What am I doing wrong?

+(BOOL)initDatabase{ BOOL ok = NO; NSFileManager *fileManager = [NSFileManager defaultManager]; NSError *err; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"database.sqlite"]; ok = [fileManager fileExistsAtPath:writableDBPath]; if (!ok){ NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"database.sqlite"]; ok = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&err]; if (!ok) { NSAssert1(0, @"Failed to create writable database. Error: '%@'.", [err localizedDescription]); } } if ([WCSession isSupported]) { WCSession* session = [WCSession defaultSession]; session.delegate = self; [session activateSession]; NSLog(@"watch url: %@",session.watchDirectoryURL); // session.watchDirectoryURL; } [[WCSession defaultSession] transferFile:[NSURL fileURLWithPath:writableDBPath] metadata:nil]; [[Config sharedInstance] addSkipBackupAttributeToItemAtURL:[NSURL fileURLWithPath:writableDBPath]]; ok = [fileManager fileExistsAtPath:writableDBPath]; if (ok){ databasePath = writableDBPath; database = [FMDatabase databaseWithPath:writableDBPath]; [database open]; NSLog(@"database path: %@",databasePath); } return ok; } 
+3
source share

All Articles