In my Xamarin Android app I have set the following in the Manifest:
<application android:allowBackup="false" />
I had to do this cause everytime I was installing the app, it kept track of the previous image of the sqlite database when some information was stored. A
fter adding that line to the Manifest, everytime I reinstall the app I have a clean database to work with, so no previous info is getting used.
But this creates another issue. I have a button on my app that simply creates a copy of the local database to the external storage.
This copy works fine if I don't set up the allowBackup="false" in the Manifest, but since I have to (for the problem I mentioned earlier), I find myself in the
impossibility to have both things working (i.e. the clean DB after each installation and the possibility to create copies of the DB to external drive).
I think that a possible workaround could be to keep the allowBackup="false" in the Manifest but change it to "true" just before creating a copy of the database.
I can then change the flag back to "false".
But how can I achieve this? I haven't found anything online on this. Thank you.
The purpose of the manifest is that it can't be changed. For example this is where you declare on what your app will have access to (until Android Marshmallow this was the only way to make such a declaration). Obviously such things cannot change at the runtime.
Also the purpose of the backup is to restore in all cases including the one that you don't like (for whatever reason which is still not clear as I don't see why your app cannot continue to work with the data it had worked properly before the app was uninstalled), so basically you don't want the backup and you should set it to false.
Related
I am trying to write a thumbnail provider extension (on macOS) that accesses the Core Data store of the main application, shared via an app group, to find images to base icon thumbnails on. This worked fine until I added one attribute to the Core Data model. Now the extension always crashes with An error occurred during persistent store migration and attempt to write a readonly database.
Creating a new default model version and deleting the Core Data Store doesn't help. Somehow the thumbnailer extension still thinks that the store written by the main application uses an earlier model, which makes no sense.
If I set shouldMigrateStoreAutomatically to NO, I get The managed object model version used to open the persistent store is incompatible with the one that was used to create the persistent store.
If I set readOnly = YES on the NSPersistentStoreDescription, I get The file couldn’t be saved because you don’t have permission. which I think may be a concurrency isse, caused by lots of thumbnail provider threads trying to migrate the store all at once.
EDIT: Original code here: https://github.com/angstsmurf/spatterlight/blob/quicklook/SpatterlightThumbnails/ThumbnailProvider.m
Right, I got this to work, but I'm not sure how.
Some of the things I did: cleaned up the build folder, deleted all copies of the main application from my hdd, built a new release version of it, put it in Applications, picked that one when Xcode asked me to choose an app to run after building the thumbnail provider extension. That still didn't work, but afterwards I no longer got any store migration errors when building and running in Xcode.
So basically the problem seems to have been that Xcode picked an old build of the main application to run along with the extension, which created an old version of the Core Data store. Or the old store was still being cached somewhere. Just cleaning the build folder was not enough to fix this.
I want to update my application declarations (add some new) in .appxmanifest file. Also, my application has sensible data in LocalState folder, so it cannot be lost.
The question is if I add these declarations (change .appxmanifest file) will it trigger the application reinstall and as a result data loss in LocalState folder?
I found in documentation and Q&A that changes to AppManifest can trigger app reinstall but there are no details which changes exactly will bring me to this situation.
If you change this file locally and then rebuild the project the app will be reinstalled when debugging.
Changes like these won't cause a reinstall when updates are distributed through the store.
Periodically I launch my app from Xcode to find Core Data errors due to an empty model file. The versioned model files are found in the main bundle but the model file still inits to nil. See my answer for partial workarounds but no solution to date.
I've verified that the files exist and are accessible using the access function. I've tried using initWithContentsOfURL and mergedModelFromBundles with the same result.
This happens randomly and I suspect something is changing the model file behind the scenes but I don't know what.
Restarting my computer seems to have solved the security related crash but this also necessitates removing the existing Core Data store file as it complains the existing one doesn't match the model file.
[UPDATE]
Restarting does not solve the problem. But reseting the current version of the Core Data model file did the trick. I changed it to an older version and then back. This question helped me think of this as something to try. Using mergedModelFromBundles: and versioning (CoreData) Still not sure what the root problem is.
[ANOTHER UPDATE]
I put a file monitor on the .xccurrentversion file in my Core Data momd file bundle to observe when the file is being touched. I've noticed that XCode (or some build tool) updates the .xccurrentversion file periodically when XCode comes to foreground (either when the project is opened or when it's been in background for a while). When it did this today it updated the file setting _XCCurrentVersionName to the main momd file bundle rather than the version file. I replaced the .xccurrentversion file with an older version and it launched. This would explain why reseting the current model version fixes this issue. I have no idea what the conditions are for XCode to update this file.
I am currently working on a project which runs just fine in both the simulator and on device except for one particular method which does not update on the device or in the simulator. It seams that I can put whatever I like in it and it just runs an old version. If I change other methods in the same file they build and run with the changes. Any ideas why this is happening or what I could do to solve it?
One suggestion I heard was to start a new project and copy my code in. I would like to avoid that if possible but it looks like I might have to.
Sometimes you need to do a clean build because Xcode does not always notice dependency changes (e.g. changes to source files).
Some people do not configure their dependencies (e.g. static/dynamic libraries) correctly. If you are using the auto-detect-dependency feature, it still has some bugs, so you may need to configure this explicitly.
FWIW, starting a new project has never been necessary for me...
I built a simple app that I'd like to submit to the Apple store, but I am not sure whether my project Release settings are set correctly. I adjust a few things, based on what I could find online, but I might've created more problems than I solved.
I would very much appreciate if somebody could provide a copy of working Release settings which would sure work for my project. I don't store/read any files, the application just runs a few commands. Basically, I just need it to run and install in that /Applications folder so the user could trigger a launch.
Basically use default settings, move your source code to a new project, read up the guidelines and see if anything is told to change, otherwise it's just fine. Cheers.