make it easy to debug databases in iOS applications iOS debug database
To integrate YYDebugDatabase into your Xcode project using CocoaPods, specify it in your Podfile
:
pod 'YYDebugDatabase'
If use Swift, remember to add use_frameworks!
use_frameworks!
pod 'YYDebugDatabase'
github "y500/iOSDebugDatabase"
run carthage update
Add all three .frameworks
to your target “Embedd Frameworks” Build Phase:
iOSDebugDatabase.framework
FMDB.framework
GCDWebServers.framework
First, add configurations in Podfile.
pod 'YYDebugDatabase', :configurations => ['Debug']
Then, run the following command:
$ pod install
import at AppDelegate.m:
#import DebugDatabaseManager.h
making one line code at application:didFinishLaunchingWithOptions
:
[[DebugDatabaseManager shared] startServerOnPort:9002];
#ifdef DEBUG
[[DebugDatabaseManager shared] startServerOnPort:9002];
#end
If use Swift:
import at Appdelegate.swift:
import YYDebugDatabase
making one line code at application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?)
:
DebugDatabaseManager.shared().startServer(onPort: 9002);
It only shows the databasesin in Documents directory and Library/Cache directory by default, if you want show databases in other directories, you can use:
- (void)startServerOnPort:(NSInteger)port directories:(NSArray*)directories
for example:
NSString *resourceDirectory = [[NSBundle mainBundle] resourcePath];
NSString *databaseDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/database"];
NSString *documentDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString *cacheDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Cache"];
[[DebugDatabaseManager shared] startServerOnPort:9002 directories:@[resourceDirectory, databaseDirectory, documentDirectory, cacheDirectory]];
If use Swift:
let directory:String = (Bundle.main.resourcePath)!;
let documentsPath:String = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
let cachePath:String = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true)[0]
DebugDatabaseManager.shared().startServer(onPort: 9002, directories: [directory, documentsPath, cachePath]);
That’s all(you can look at the Demo for details), just start the application :
Now open the provided link in your browser, and you will see like this:
query:
edit:
delete:
Important:
###other more:
you can find the address and bojourname address in the console like below:
[INFO] DebugDatabaseManager started on port 9002 and reachable at http://192.168.0.67:9002/
[INFO] DebugDatabaseManager now locally reachable at http://y500.local:9002/
Copyright (C) 2016 y500
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.