DisyInformationssysteme / Cordova-spatialite-storage

A Cordova/PhoneGap plugin to open and use sqlite databases on Android/iOS/Windows Universal(8.1)/Amazon Fire-OS/WP(7/8) with HTML5/Web SQL API
Other
24 stars 17 forks source link

IOS BUILD FAILED Cordova/NSData+Base64.h' file not found #1

Closed Cultrarius closed 7 years ago

Cultrarius commented 7 years ago

Hi, I am new to github so I am not sure if this is the right place to write but I don't see way to create issue. I am writing cordova map application which is heavily using cordova-spatial-storage plugin. On Android works like a charm but have problem on IOS. It doesn't compile and I get error mentioned in title. I have macOS Sierra 10.12.13 Xcode 8.2.1 cordova-ios 4.1.1 cordova-cli 6.4.0 and trying to compile it from Visual Studio 2015 installed on win10 machine. As I did some searches bug is caused by some changes in cordova and many plugins face it, including main branch of sqlite plugin. Is there a chance to have a upgrade this plugin to latest cordova ?

Cultrarius commented 7 years ago

Hey @LukeeK, we are currently using cordova version 5.4.1, so we do not face this problem.

The cause is apparently not the cordova version, but the version of the ios module: https://github.com/apache/cordova-ios/blob/master/guides/API%20changes%20in%204.0.md#nsdatabase64h-removed

I do not know if this can be easily fixed, maybe it requires a separate branch.

KimberleeDArmstrong commented 7 years ago

I looked through the bugs on the parent sqlite plugin as it seems to be more active and kept up to date. I found a solution there. You can replace SQLitePlugin.m file in plugins/src/ios with the SQLItePlugin.txt file I attached just rename the file to SQLitePlugin.m Git hub doesn't recognize the .m file extension. SQLitePlugin.m.txt

Cultrarius commented 7 years ago

Thanks @KimberleeDArmstrong but the file you attached did not have the fix included, maybe you linked the wrong file? Your file still includes the problematic header #import <Cordova/NSData+Base64.h>.

I merged the missing commits from upstream, so it should work now. I tested it for cordova-ios version 3.8.0, but not with the problematic version from @LukeeK. When someone with a version > 4.0.0 could test it now and report back that would be great! (you probably have to remove and reinstall the plugin via cordova for it to work)

The fix from upstream basically disables the SQLite blob storage; if you need the feature to work you have to #define the READ_BLOB_AS_BASE64 macro.

LukeeK commented 7 years ago

Hi, thanks for quick response. I will check it on monday when I get to work, where I have my Mac. Btw, You are right not cordova itself but cordova-ios.

LukeeK commented 7 years ago

Hi, I tried to build default apache cordova project from Visual Studio with newest spatialite plugin version but got some linker errors: Undefined symbols for architecture x86_64: "_uncompress", referenced from: _gaiaXmlBlobCompression in libspatialite.a(gg_xml.o) _gaiaXmlTextFromBlob in libspatialite.a(gg_xml.o) _gaiaXmlFromBlob in libspatialite.a(gg_xml.o) _gaiaXmlBlobSetFileId in libspatialite.a(gg_xml.o) _gaiaXmlBlobSetParentId in libspatialite.a(gg_xml.o) _gaiaXmlBlobAddFileId in libspatialite.a(gg_xml.o) _gaiaXmlBlobAddParentId in libspatialite.a(gg_xml.o) ... "_compressBound", referenced from: _gaiaXmlToBlob in libspatialite.a(gg_xml.o) _gaiaXmlBlobCompression in libspatialite.a(gg_xml.o) "_compress", referenced from: _gaiaXmlToBlob in libspatialite.a(gg_xml.o) _gaiaXmlBlobCompression in libspatialite.a(gg_xml.o) "_crc32", referenced from: _evalGeosCache in libspatialite.a(gg_relations.o) _gaiaXmlToBlob in libspatialite.a(gg_xml.o) _gaiaXmlBlobCompression in libspatialite.a(gg_xml.o) _gaiaIsValidXmlBlob in libspatialite.a(gg_xml.o) _is_valid_legacy_xml_blob in libspatialite.a(gg_xml.o) ld: symbol(s) not found for architecture x86_64 clang : error : linker command failed with exit code 1 (use -v to see invocation)

Cultrarius commented 7 years ago

@LukeeK thank you for the test. Are you building your iOS project from Visual Studio? Maybe try to use XCode, I think it has better support.

You might also try to add libz.dylib as lib to your project: http://stackoverflow.com/a/8768277/2092777 Please open another ticket if this problem persists, so it does not get mixed up with this one.

LukeeK commented 7 years ago

@Cultrarius, thanks for info. I've already built and run my app with old version of spatialite plugin (before last commits, including Cordova/NSData+Base64.h' file not found bug) directly on mac with Xcode. I had to include NSData+Base64.m, NSData+Base64.h files add refence to libz.1.2.8.tbd and do few more tweeks. And of course that is the option, however I was hoping to have it run from vstudio as I am more familiar with it and it gives more options to debug (at least from my perspective).

Cultrarius commented 7 years ago

@LukeeK we only support XCode for iOS projects, but we are happy to accept a pull request if you get it to work with VS. Maybe check out the plugin.xml: under <platform name="ios"> there are several entries such as <framework src="libiconv.dylib" />. Try to add the libz.dylib, libz.1.2.8.tbd, libz.tbd (or whatever its name now is) as a framework before installing the plugin.

LukeeK commented 7 years ago

@Cultrarius ,thanks I will check it. Btw is there a way to debug cordova app run in xcode on mac in real time (except using Safari)?

Cultrarius commented 7 years ago

@LukeeK You can use XCode to debug the native parts (e.g. the spatialite lib), whereas Safari is used to debug the JavaScript parts of cordova. They go hand in hand ;) I do not know of any alternatives to these two.

LukeeK commented 7 years ago

@Cultrarius thanks for debug possibilities info and for <framework src="libiconv.dylib" /> tip. That made a job and I can compile, run and debug on mac my app from visual studio

Cultrarius commented 7 years ago

Great, thanks! I will close the issue then.