Code Monkey home page Code Monkey logo

iosdebugdatabase's Introduction

YYDebugDatabase

YYDebugDatabase is a powerful library for debugging databases in iOS applications. Which like Android Debug database

YYDebugDatabase allows you to view and edit databases directly in your browser in a very simple way.

What can YYDebugDatabase do?

  • See all the databases.
  • Run any sql query on the given database to update and delete your data.
  • Directly edit the database values.
  • Directly add a row in the database.
  • Delete database rows.
  • Search in your data.
  • Sort data.
  • Download database.

Release 2.0.0:

  • Replace CocoaAsyncSocket with GCDWebServer, which is higher level server that more convenient.
  • Satisfy with Firefox, Safari, Chrome.
  • Use bonjourname as the server address, for example: http://y500.local, http://macbook.local:9002...
  • print link address and bonjour name of the server in the console

Installation

Podfile

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'

Carthage

  • Cartfile
github "y500/iOSDebugDatabase"
  • run carthage update

  • Add all three .frameworks to your target "Embedd Frameworks" Build Phase:

    • iOSDebugDatabase.framework
    • FMDB.framework
    • GCDWebServers.framework

Not build in Release

First, add configurations in Podfile.

pod 'YYDebugDatabase', :configurations => ['Debug']

Then, run the following command:

$ pod install

USage

import at AppDelegate.m:

#import DebugDatabaseManager.h

making one line code at application:didFinishLaunchingWithOptions:

[[DebugDatabaseManager shared] startServerOnPort:9002];

Not run in Release

#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);

Advanced

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:

  • Your iPhone and laptop should be connected to the same Network (Wifi or LAN).
  • the host of you link address is the iPhone's net address.
  • If you use Simulator you can use address: http://127.0.0.1:9002.
  • the port must be same as you write in Appdelegate.m

###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/

License

   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.

iosdebugdatabase's People

Contributors

fallending avatar y500 avatar yixiangboy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iosdebugdatabase's Issues

Edit无效

打开页面后,Edit某一条数据库修改后不生效

无法更新数据库

image

2020-09-07 15:53:29.455246+0800[11482:1629114] delete DELETE FROM "folder" WHERE id[INTEGER] = '1'
2020-09-07 15:53:29.456885+0800[11482:1629114] [logging] near "[INTEGER]": syntax error in "DELETE FROM "folder" WHERE id[INTEGER] = '1' "
2020-09-07 15:53:29.457170+0800[11482:1629114] DB Error: 1 "near "[INTEGER]": syntax error"

为啥后面会加一个[字段类型]

报错

ld: 45 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

打开网址后空白,但会下载首页

demo运行后,根据输出信息,在chrome里打开网址后,直接下载一个叫“下载”的无后辍文件,内容为首页html代码
运行环境:
mac:M1 11.6
xcode:13.2.1
模拟器:iOS15.2
chrome:98.0.4758.109(正式版本) (arm64)

网页上查看表数据时crash

报错:Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (_NSInlineData)'
ps: 我们表的主键都是GUID类型 是类型转换问题吗

关于集成代码

大佬,我正在写一个用于 debug 的插件,开源的,非商用。我觉得你的这个点子很好,准备集成到里面去,应该会根据自己的需求修改一些代码。请问一下可以吗?我会 README 注明的

Unknown error calling sqlite3_step (8: attempt to write a readonly database) eu

[DEBUG] Connection on socket 8 preflighting request "GET /deleteRecord" with 1098 bytes body
[DEBUG] Connection on socket 8 processing request "GET /deleteRecord" with 1098 bytes body
2018-09-14 08:28:01.460804-0700 YYDebugDatabase[1992:1299402] delete DELETE FROM "cars" WHERE id = '2'
2018-09-14 08:28:29.295797-0700 YYDebugDatabase[1992:1299402] Unknown error calling sqlite3_step (8: attempt to write a readonly database) eu
2018-09-14 08:28:29.296000-0700 YYDebugDatabase[1992:1299402] DB Query: DELETE FROM "cars" WHERE id = '2'
2018-09-14 08:28:29.296101-0700 YYDebugDatabase[1992:1299402] Unknown error finalizing or resetting statement (8: attempt to write a readonly database)

Javascript 不支持Long类型,导致数据精度丢失显示异常。

数据库中integer存储的是Int64的数字,在传输过程中,Long长度大于17位时会出现精度丢失的问题。

在Chrome浏览器调试时也发现,Preview与Response因为精度丢失的原因,显示的数据不一致。

比如 365942491263795226 会显示成 365942491263795200 。

一种方案是将Long类型的整形转成String传输。
一种方案是前端反序列化时不使用默认的JS解析器。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.