file manager is not clearing from older app - ios

Hello I have an app in my code that loads a file into a Bluetooth device, but it seems like if I change that file for the new version of the app it doesn't update it if I just reinstall it. I have to actually delete the app and install it again. Anyone know why? Is there some cache storing?
NSString *fileInDocuments = [documentsDirectory stringByAppendingPathComponent:#"samplefile_pack.bin"];
NSLog(#"File: %#", fileInDocuments);
if ([fileManager fileExistsAtPath:fileInDocuments ] == NO) {
NSString *resourcePath = [[NSBundle mainBundle] pathForResource:#"samplefile_pack" ofType:#"bin"];
[fileManager copyItemAtPath:resourcePath toPath:fileInDocuments error:&error];
}

I'm assuming v1 of your app has the same code as the v2 of your app posted in your question. Assuming this is true, the behavior you see makes perfect sense.
A user runs v1 of your app. The file isn't in the Documents folder so it gets copied from the app bundle. Now, every time they run your app, the file exists and that copy in Documents is used.
Now the user updates to v2 of your app. The same check is made. The file already exists in Documents so nothing is copied.
Since your question implies that you want an updated copy of this file installed the 1st time v2 of the app is run, you need to detect whether the user currently has the file from v1 or v2 in the Documents folder.
There are a few ways to solve this. One option is to rename the file to something like samplefile_pack2.bin. Then your check can be for the new file name. You can also check for the old one and delete it if it makes sense.

Related

App creating files while iPhone is locked

I am struggling with this issue.
My app need to create, while in background, some file. It creates a temporary file (in the temporary folder), then creates a folder inside /Documents, with some files in it.
When my application is compiled in debug, it works. When I compile it in release, and only when passcode is activated, only the first set of files gets created. The second set sees only the creation of the folder inside Documents, but no file can be created, nor in temporary folder nor in Documents/newcreatedfolder.
This happens only when the application is compiled in release, and with the pass code on.
I guess it has to do with data protection and the impossibility to create new files while the phone is locked. Is there some entitlement that can give my application the possibility to create and write to new files while in background and locked?
Files are locked by standard iOS file protection policy, so after the phone is locked all files are encrypted. My solution was this, since I don't need security on those files:
[[NSFileManager defaultManager] setAttributes:#{NSFileProtectionKey:NSFileProtectionNone} ofItemAtPath:[GlobalProvider tmpFolder] error:NULL];
[[NSFileManager defaultManager] setAttributes:#{NSFileProtectionKey:NSFileProtectionNone} ofItemAtPath:[GlobalProvider documentsFolder] error:NULL];

What is the location in which I can find Couchbase lite location in IOS 8.3?

Need to install a pre-built couches lite database in my IOS application, for that I need to locate the database's .cblite file.
When I go to [[NSBundle mainBundle] bundlePath] . I cannot find anything.
You can use http://simpholders.com/ to locate the application folder in a simulator running the app with Couchbase Lite.
The cblite file and folder to store the attachments are in the folder returned by SimPholders in Library/Application Support/CouchbaseLite.
Once you have the canned database, see this documentation guide to use it as a resource in your app and to set it up with the replaceDatabaseNamed:withDatabaseFile:withAttachments:error: method.

How to build an application including a folder for further load on the device?

I have a directory structure on my computer i wanted to include into my app bundle:
#"/Users/playra/Desktop/2 DivyaLoka/Собрание Тайн";
application starts surf folders, keeping the directory tree, which is visible in the screenshot
but when using the load
self.pathProperty = [[NSBundle mainBundle] resourcePath];
or
self.pathProperty = NSHomeDirectory();
structure disappears and everything is loaded into one tableView.
How to start an application starting with a folder **Собрание Тайн** that is in the sandbox keeping structure inside for further load on the device?
First choose IOS Device
Product --> Archive
Choose Disribute
Then, Save for nterPrice or Ad-hoc Deployment
Then choose your certificate and Export
Then save the build

How to change the DisplayName of an iOS Application?

I know there are so many answers related to my question, such like.
Programmatically rename an XCode project
Renaming xcode 4 project and the actual folder
etc.
But look at following my code:
NSString *plistPath = #"...../TestingAPI-Info.plist";
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc]initWithContentsOfFile:plistPath];
[dictionary setObject:#"myTestingApp" forKey:#"CFBundleDisplayName"];
[dictionary writeToFile:plistPath atomically:YES];
I am changing the name of apps icon by above code,
Changed name "MySuperApp => myTestingApp"
SO, Is it valid to change by using above code ? I have fear of app rejection ?? I also want to set all changes through above code like, Bundle identifier, Bundle name..etc ?
Is it valid or not ?? By using above code apple reject my application or not ??
As rckoenes said correctly, this won't work on the device. Any bundle contents are readonly, including the info.plist. You can not overwrite it.
To clarify:
Just open up the Info.plist file in Xcode and rename it to whatever you want. You don't need any code for this. You will find the YourProjectName-Info.plist file within your Xcode project.
The writeToFile call will not work i.e. the contents will never get update in the Info.plist file. API call may return a false success but contents of that file will never change since application bundle is read-only (obviously the contents within it as well).
As per Appstore review guidelines there is one which suggests,
2.6 Apps that read or write data outside its designated container area will be rejected.
But whether app bundle falls under "designated container area" is a matter of speculation because only Apple can clarify this. AFAIK I have not read anywhere about app getting reject for attempting to write into application bundle.
As a side note: It may not be a good idea to change application name randomly without the users consent.
Hope that helps!
This is very unusual, app name is your brand it is finalized with lot of suggestions and thinking. What is benefits of this and why is your requirements to change name likewise.

IOS 5.1 Backup / Restore App file from Documents Directory to / from iCloud

I have created a database (IOS 5.1) with XCode 4.3.3 for the iPad and have set it up so that the user can backup and restore the database file (*.sqlite) to DropBox. Everything works fine...
Now I would like to do the same process but, set it up for iCloud. Looking for the following function:
Tap a button to backup the *.sqlite file from the Apps Document Directory up to iCloud at users preference.
Tap a button to copy the *.sqlite file down from iCloud to the Apps Document Directory.
I have been struggling trying to find the solution, any help will be greatly appreciated.
For moving any file to and from icloud you can use this code below.
[[[NSFileManager alloc]init] setUbiquitous:YES itemAtURL:your iCloudURL destinationURL:localDirectoryURL error:&errorsss];
only thing is if you are moving to icloud the code should be :
[[[NSFileManager alloc]init] setUbiquitous:YES itemAtURL:localDirectoryURL destinationURL:your_iCloudURL error:&errorsss];
and if you are getting it from iCloud to Apps Documents directory
[[[NSFileManager alloc]init] setUbiquitous:NO itemAtURL:your_iCloudURL destinationURL:localDirectoryURL error:&errorsss];

Resources