我自己往xcode添加了一个sql文件,添加在类似下面Pods/Frameworks/的目录中,但是代码执行的时候貌似找不到我自己加的文件
- (instancetype)initWithDatabaseFilename:(NSString *)dbFilename { self = [super init]; if (self) { self.databaseFilename = dbFilename; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; self.databasePath = [documentsDirectory stringByAppendingPathComponent:self.databaseFilename]; [self copyDatabaseIntoDocumentsDirectory]; } return self; } - (void)copyDatabaseIntoDocumentsDirectory { if (![[NSFileManager defaultManager] fileExistsAtPath:_databasePath]) { NSString *sourcePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:_databaseFilename]; NSError *error; [[NSFileManager defaultManager] copyItemAtPath:sourcePath toPath:_databasePath error:&error]; if (error != nil) { NSLog(@"error: %@", [error localizedDescription]); } } }