Comments (23)
Since the Mac framework was not working, I went ahead and uses the iOS framework. However, I am unable to query anything at all from a connected database. Either, I am just to noob for this or there a still some bug in your wrapper.
The database I am connection to is the Apple iCal Cache database.
from sqlite.swift.
These images do not provide enough context to troubleshoot.
In the first (Mac) project, please provide a screen shot of your entire Xcode project from the "Build Phases" screen.
In the second (iOS) project, please show me the error you're getting on that line, and please show me where you set "ZTITLE".
from sqlite.swift.
Hi, lets go with the Mac issue, since this is the one that matters to me.
from sqlite.swift.
Which of the two SQLite.framework files did you drag into the last two areas?
Alternatively, can you try the "universal-framework" branch, which simplifies the build system?
On Jan 17, 2015, at 2:27 PM, thomasschoenfeld [email protected] wrote:
Hi, lets go with the Mac issue, since this is the one that matters to me.
—
Reply to this email directly or view it on GitHub.
from sqlite.swift.
Here is a video of how I set it up. I hope you bare with even if I ask this noobisch questions. Right after adding your framework I build the app. This seems to work. But when I add another playground my database will not be accessed properly.
Here Link to my setup video: https://dl.dropboxusercontent.com/u/107444970/Xcode_and_SQlite.m4v
And here the issue I'm having:
For your previous question: I deleted the older projects already, since they were iOS and Mac mixed with your an other frameworks. Just so I don't have some unwanted stuff flying around.
What I can tell is everything you see in my code in capital letters starting with Z.... are either tables or items / rows of the tables. For example the table ZCALENDARITEM contains all items in you Apple iCal app. ZTITLE would be a row in that table containing the titles of your calendars events.
from sqlite.swift.
@thomasschoenfeld Ah, the problem seen in the video is that you need to have built the framework (for iOS) at least once for a playground to run (see the note I left at the top of the playground)—and even after that, the playground will usually keep that error visible till you edit the playground or quit/relaunch the project.
Beyond that, in your screen shot, above, you're trying to open a database file in a location that playgrounds do not have access to (they're sandboxed).
Please read the "Connecting to a Database" documentation for some examples of places to open databases:
And let me know if you have better luck importing and using SQLite.swift in actual source files in your project (rather than playgrounds).
from sqlite.swift.
I am getting started with swift just now. This is why I use playgrounds.
I did as you said. The database is now in the support files dir. I also used your code for the connection. Now I get a different error. However, I am not sure that the database is really connected. I did build, stopped, closed and reopened everything. Still my issue remains.
Again I apologise for bothering you. I can find my way around C/C++ and I am good with applescript. But I am totally new to Xcode projects / frameworkes / etc... And rather than starting with python to get an somewhat good print-out I want to do this in swift to force myself to get into and build my app.
The whole idea is to build an app around my iCal events, which will give me my time worked and some other stuff.
from sqlite.swift.
My recommendation would be to spend less time in the playground right now as you get comfortable. Try pasting this code into your AppDelegate launch code and you should hopefully get better error messages and stack traces.
I'm going to close this issue for now as there don't appear to be any specific bugs being reported.
from sqlite.swift.
I agree with Stephen.
But when you do start a project, here some extra tips:
I use Firefox's SQLite Manager. You can runs scripts on it and theres a nice GUI. Import some fake data using the CSV import option.
Drag your database into your project.
Follow the instructions in the documentation on how to install the framework.
Go to Copy Bundle Resources and add your database.
If you only need to read: its super easy: (two lines of code)
let path = NSBundle.mainBundle().pathForResource(kDatabaseName, ofType: kDatabaseType)!
let db = Database(path, readonly: true)
Then follow the docs on how to perform queries.
Good luck.
from sqlite.swift.
I tried that and is still not working. Has one of you tried open a sqlite database that way? Because I did exactly as you wrote and I still have issues. I mean, I am new to this, but not that new. If you want, we could do a short remote session. If it works, it would take about 2 Minutes to show me. But honestly I think it will not work.
Or are you saying connection to databases within playground is not supported?
Am 19.01.2015 um 19:19 schrieb Eric Gu (@ericguuu) [email protected]:
I agree with Stephen.
But when you do start a project, here some extra tips:
I use Firefox's SQLite Manager. You can runs scripts on it and theres a nice GUI. Import some fake data using the CSV import option.
Drag your database into your project.
Go to Copy Bundle Resources and add your database.If you only need to read: its super easy: (two lines of code)
let path = NSBundle.mainBundle().pathForResource(kDatabaseName, ofType: kDatabaseType)!
let db = Database(path, readonly: true)
Then follow the docs on how to perform queries.
Good luck.—
Reply to this email directly or view it on GitHub.
from sqlite.swift.
@thomasschoenfeld You should get a very specific assertion message back when running the application (rather than running a playground). Playgrounds don't play nicely with assertions, so it becomes difficult to troubleshoot those cases. Run the application with your code, above, and read the assertion's error message that prints to the Xcode console upon crash.
Beyond that, a playground runs in its own application/bundle/sandbox, so it doesn't have direct access to the resources your app target has access to (including the database file you're trying to open).
See http://stackoverflow.com/questions/24069479/swift-playgrounds-with-uiimage for more info on opening resources from within a playground.
from sqlite.swift.
mh…. ok, I tried the most stupid thing I could think of, command line tool :-D an I got this… I saw your other email an will try that as well...
Am 19.01.2015 um 20:53 schrieb Stephen Celis [email protected]:
@thomasschoenfeld You should get a very specific assertion message back when running an application. Playgrounds don't play nicely with assertions, so it becomes difficult to troubleshoot those cases. Run the application with your code, above, and read the assertion's error message that prints to the Xcode console upon crash.
—
Reply to this email directly or view it on GitHub.
from sqlite.swift.
@thomasschoenfeld Command-line tools in OS X do not support dynamic frameworks, so you'll likely have to embed the SQLite.swift files directly.
See #4.
from sqlite.swift.
understood. I tried the other thing that you gave me the link to, the one with the images etc. Still nothing (this time again with an Cocoa App) … It can not be that hard… I think I am doing something very very very stupid which keeps me from getting it to work...
Am 19.01.2015 um 21:06 schrieb Stephen Celis [email protected]:
@thomasschoenfeld Command-line tools in OS X do not support dynamic frameworks, so you'll likely have to embed the SQLite.swift files directly.
—
Reply to this email directly or view it on GitHub.
from sqlite.swift.
ok, so with playgrounds I am not getting anywhere. I also tried another framework and eliminated all „-„ in the folder paths. This seemed to be one issue as well. Now it seems it is being accessed alright, but I now get an fatal error on runtime… It is an Mac App, no playground, and the code is within the AppDelegate just as you suggested.
Am 19.01.2015 um 21:06 schrieb Stephen Celis [email protected]:
@thomasschoenfeld Command-line tools in OS X do not support dynamic frameworks, so you'll likely have to embed the SQLite.swift files directly.
—
Reply to this email directly or view it on GitHub.
from sqlite.swift.
I seem to have an issue with my iCloud account. So here is my last email again…
ok, so with playgrounds I am not getting anywhere. I also tried another framework and eliminated all „-„ in the folder paths. This seemed to be one issue as well. Now it seems it is being accessed alright, but I now get an fatal error on runtime… It is an Mac App, no playground, and the code is within the AppDelegate just as you suggested.
I think I am almost there...
Am 19.01.2015 um 21:06 schrieb Stephen Celis [email protected]:
@thomasschoenfeld Command-line tools in OS X do not support dynamic frameworks, so you'll likely have to embed the SQLite.swift files directly.
—
Reply to this email directly or view it on GitHub.
from sqlite.swift.
Please provide as much information as possible if you want help troubleshooting, e.g.:
- The actual fatal error message you're getting
- A sample project (and/or playground) with the error intact
You're unfortunately not providing enough information to really troubleshoot the issue.
from sqlite.swift.
the error reads:
fatal error: unexpectedly found nil while unwrapping an Optional value
(lldb)
here is the whole project (including the database).
https://dl.dropboxusercontent.com/u/107444970/Archiv.zip
If you think, everything is ok, then maybe for whatever reason that database is „spezial“. I couldn’t say how, because all my sqlite commands via terminal or python work as they should.
I really appreciate the help.
Am 19.01.2015 um 22:41 schrieb Stephen Celis [email protected]:
Please provide as much information as possible if you want help troubleshooting, e.g.:
• The actual fatal error message you're getting
• A sample project (and/or playground) with the error intact
You're unfortunately not providing enough information to easily troubleshoot the issue.—
Reply to this email directly or view it on GitHub.
from sqlite.swift.
This error message means there is a data issue, which has nothing to do
with SQLite.swift or Swift.
Look up "optionals"
On Mon, Jan 19, 2015 at 4:49 PM, thomasschoenfeld [email protected]
wrote:
the error reads:
fatal error: unexpectedly found nil while unwrapping an Optional value
(lldb)here is the whole project (including the database).
https://dl.dropboxusercontent.com/u/107444970/Archiv.zipIf you think, everything is ok, then maybe for whatever reason that
database is „spezial“. I couldn’t say how, because all my sqlite commands
via terminal or python work as they should.I really appreciate the help.
Am 19.01.2015 um 22:41 schrieb Stephen Celis [email protected]:
Please provide as much information as possible if you want help
troubleshooting, e.g.:• The actual fatal error message you're getting
• A sample project (and/or playground) with the error intact
You're unfortunately not providing enough information to easily
troubleshoot the issue.—
Reply to this email directly or view it on GitHub.—
Reply to this email directly or view it on GitHub
#41 (comment)
.
from sqlite.swift.
@thomasschoenfeld Please take the time to read the Swift book in iBooks. There are a lot of assumptions this code is making:
And this line isn't even in SQLite.swift yet.
You're using !
to force-unwrap an optional. In this case, NSBundle.pathForResource
can return nil
if the resource doesn't exist. It's not finding CalendarCache.sqlite3
because the only bundle resource available is CalendarCache
(you should add a suffix/extension to the resource). I also had 2 additional problems with your project because of how you packaged it, though it's probably not an issue for you in the moment:
- You didn't copy the
CalendarCache
resource into your project, so I had to manually re-add it. - You didn't package the SQLite.swift directory with the project, so I had to manually re-add it.
I'd also recommend always looking at the line in question that you're having problems with, in this case the NSBundle.pathForResource
line. Break it apart, debug every aspect of the statement, and read the Apple documentation:
func pathForResource(_ name: String?, ofType extension: String?) -> String?
Parameter Description name The name of the resource file. If name is an empty string or nil, returns the first file encountered of the supplied type. extension If extension is an empty string or nil, the extension is assumed not to exist and the file is the first file encountered that exactly matches name. Return Value
The full pathname for the resource file or nil if the file could not be located.
There's more. There's a "discussion" section and it goes on to link to a specific section of the Bundle Programming Guide.
Sorry that I can't really help more than that. It's taken a long time to get to the point of realizing that the problems you're having are iOS/Mac/Xcode development issues and were unrelated to SQLite.swift.
from sqlite.swift.
mh, what exactly did you do when you say you „manually re-added“ them? I am not that familiar with Xcode and was under the impression, once dragged into Xcode (and with „copy if needed“ checked) that Xcode would handle everything behind the scenes, linke all sources / files etc.
I added the suffix. It started running but I got this error now…..
so far so good...
fatal error: unable to open database file: file /Users/thomasschonfeld/Desktop/Scripte/SwiftandSQlite/Test201501200820/Test201501200820/SQLite.swift-master/SQLite Common/Database.swift, line 335
Did you run „my database“ without issues after you „manually re-added“ the files? There is no designated resources folder within the project folder in finde so I simply copied everything in the project „root“ folder. That did not help. So that „manually re-added“ you did is probably not what I think it is.
After being stuck on this I finished all my desired sql command and startet coding in python and had no issue with that. I wonder, if I might be better of using python, pulling the data I need into an object and working from there with swift.
Am 20.01.2015 um 00:09 schrieb Stephen Celis <[email protected] mailto:[email protected]>:
@thomasschoenfeld Please take the time to read the Swift book in iBooks. There are a lot of assumptions this code is making:
This line isn't even in SQLite.swift yet.
You're using ! to force-unwrap an optional. In this case, NSBundle.pathForResource can return nil if the resource doesn't exist. It's not finding CalendarCache.sqlite3 because the only bundle resource available is CalendarCache (you should add a suffix to the resource). I also had 2 additional problems with your project because of how you packaged it, though it's probably not an issue for you in the moment:
• You didn't copy the CalendarCache resource into your project, so I had to manually re-add it.
• You didn't package the SQLite.swift directory with the project, so I had to manually re-add it.
—
Reply to this email directly or view it on GitHub.
Mit freundlichen Gruessen
Thomas Schönfeld
Technischer Leiter
Bestellen Sie unseren Newsletter!
Sie erhalten Einladungen zu unseren kostenlosen IT-Workshop und Infos zu exklusiven Angeboten:
http://www.kleinofen.de/newsletter-bestellen.php
Kurfürstenstrasse 10
D-40211 Düsseldorf
Telefon 0211 3552-208
Handy 0173 6058520
Telefax 0211 3552-199
Geschäftsführer: Richard Kleinofen
USt-Nr.: 133/5844/0440
USt-IdNr.: DE 121301230
Amtsgericht Düsseldorf, HRB 25060
from sqlite.swift.
mh, what exactly did you do when you say you „manually re-added“ them? I am not that familiar with Xcode and was under the impression, once dragged into Xcode (and with „copy if needed“ checked) that Xcode would handle everything behind the scenes, linke all sources / files etc.
Try downloading your "Archiv.zip" on another computer and running your project.
I added the suffix. It started running but I got this error now…..
so far so good... fatal error: unable to open database file: file /Users/thomasschonfeld/Desktop/Scripte/SwiftandSQlite/Test201501200820/Test201501200820/SQLite.swift-master/SQLite Common/Database.swift, line 335
Did you run „my database“ without issues after you „manually re-added“ the files? There is no designated resources folder within the project folder in finde so I simply copied everything in the project „root“ folder. That did not help. So that „manually re-added“ you did is probably not what I think it is.
Well it appears there's a bug here or a missing implementation detail. Try removing readonly: true
for the moment. I'll investigate what else is required to get SQLITE_OPEN_READONLY
working.
Edit: You know what? I removed readonly: true
, ran it once successfully, then added readonly: true
back and it still ran just fine.
After being stuck on this I finished all my desired sql command and startet coding in python and had no issue with that. I wonder, if I might be better of using python, pulling the data I need into an object and working from there with swift.
I think you should work with what you're comfortable with or take the time to better learn Swift, Objective-C, Xcode, and Cocoa.
from sqlite.swift.
yeah, without readonly: true everything works fine. Well, and playground still does not.
Am 20.01.2015 um 18:57 schrieb Stephen Celis [email protected]:
mh, what exactly did you do when you say you „manually re-added“ them? I am not that familiar with Xcode and was under the impression, once dragged into Xcode (and with „copy if needed“ checked) that Xcode would handle everything behind the scenes, linke all sources / files etc.
Try downloading your "Archiv.zip" on another computer and running your project.
I added the suffix. It started running but I got this error now…..
so far so good...
fatal error: unable to open database file: file /Users/thomasschonfeld/Desktop/Scripte/SwiftandSQlite/Test201501200820/Test201501200820/SQLite.swift-master/SQLite Common/Database.swift, line 335
Did you run „my database“ without issues after you „manually re-added“ the files? There is no designated resources folder within the project folder in finde so I simply copied everything in the project „root“ folder. That did not help. So that „manually re-added“ you did is probably not what I think it is.Well it appears there's a bug here or a missing implementation detail. Try removing readonly: true for the moment. I'll investigate what else is required to get SQLITE_OPEN_READONLY working.
After being stuck on this I finished all my desired sql command and startet coding in python and had no issue with that. I wonder, if I might be better of using python, pulling the data I need into an object and working from there with swift.
I think you should work with what you're comfortable with or take the time to better learn Swift, Objective-C, Xcode, and Cocoa.
—
Reply to this email directly or view it on GitHub.
from sqlite.swift.
Related Issues (20)
- SqlCipher support for Swift PM, Here's a solution
- Feature: Request visionOS Support HOT 2
- Windows support HOT 3
- can not get column info with join
- Subscrip to changes
- Problem with CSQLite HOT 1
- bug in optional support for decoding HOT 1
- Version 0.15.0 Not Applied in CocoaPods HOT 10
- Swift Compiler Error when project depend SQLite.swift and sqlite3_flutter_libs HOT 1
- ncorrect checksum for freed object HOT 1
- Double quotes when using ULID HOT 1
- Unable to decode optional custom type HOT 2
- Sqllite
- Symbol not found: _$s6SQLite10ConnectionC15TransactionModeO8deferredyA2EmFWC
- Error: use of @import in framework header is discouraged, requires -fmodules
- SQLite.swift and SQLCipher HOT 1
- SQLiteCipher and visionOS support
- New SQL Coders HOT 1
- PrivacyInfo.xcprivacy HOT 2
- Will this lib consider `sendable`?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlite.swift.