I have an iOS project that includes a framework and a .dat file which is used by framework. I add the framework file and the .dat file to a folder in my project and things are working in this way.
However, the .dat file is so big and this makes my project size bigger. I want to download this file after installation to make my app size smaller.
Is it possible? If yes, how can I do that?
First you need to store .dat file on server and get link of that file and download it in app at very first launch.
When app is launched you need to check that .dat file is already exists in your device's doc. folder or not.
If not then you need to download it from url and store it in doc. dir.
When you successfully downloaded file you need to add a bool in user default to true to identify that file is dowloaded correctly, and you can check that too to identify whether file is downloaded or not.
if .dat file download is not successful than file will not be available in app. and you can perform some operations based on that.
Alternatively, you can just check the bool flag in user defaults to check for the successful download of file.
you can place that code in AppDelegate as there are several methods available for different app states.
Hope it will help you:)
Check this [On-Demand Resources]
https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/On_Demand_Resources_Guide/index.html#//apple_ref/doc/uid/TP40015083-CH2-SW1
Related
I want to have a custom project file that a user selects in a UIDocumentBrowserViewController. That project file would then reference files in the same directory which would be opened and written to programmatically. I can't seem to get access to the project's sibling files programmatically (presumably due to sandbox restrictions). What's the best way to get this to work?
I ended up making the enclosing folder a document package, i.e. a folder that shows up in the file browser as a single file. I then had access to read all the files in it.
https://developer.apple.com/library/content/documentation/CoreFoundation/Conceptual/CFBundles/DocumentPackages/DocumentPackages.html
What are the different ways available so that We avoid code tempring in ios. Please suggest any good way that we can check at server level to avoid code tempring not in source code. And how we can check that server call from app is from authorize app.
iOS apps are most secured itself. It can not be tempered easily. While building your app no code file and XIB's kept as it is.
You can check it in these steps:
Right click on .ipa file and select Open With and then Archive Utility
Then it will create folder named Payload with .app file in it.
Now Right Click on .app file and select Show Package Contents
This will show you one folder with multiple files in it. Now try to open each file and read it. It will be in encrypted way.
For reference read this link
On iOS, I save a file in /tmp, using NSTemporaryDirectory(). Can I access it with Xcode to see what was there ?
Note: Im not looking for NSLog for various reasons, I want to save to a file and retrieve this file with Xcode or some other tool, for debug. I don't care so much if the file is in /tmp or in another directory.
I would like to dynamically load all images in an xcassets directory. The files are named StockPhoto# where # is the number in the list. If I can access my StockPhotos.xcassets at runtime to count all the files in the directory, I won't have to manually load the files each time I add new stock photos.
If there are other solutions to this problem, I'm open to that but I'm also just very curious how xcassets are handled by the file system- whether they're just reference to a set of files, or actually their own directory. Information on this is sparse.
If there are other solutions to this problem, I'm open to that
The problem is that there is no introspection at runtime into an asset catalog: it isn't a "thing" you can "see" as far as Objective-C and Cocoa Touch are concerned.
The usual solution to this kind of problem is to drag a folder full of images into your project at the outset, and when you do, choose "Create folder references for any added folders" in the dialog - not "Create groups for any added folders". The result is that the folder is copied into your app bundle, and now you can use ordinary file system methods to say "every file in this folder".
Upon compilation of your iOS project, xcassets are compiled to produce either image files, or a proprietary .car file. In that latter case images won't be stored in a directory you can browse.
If your "Deployment Target" is less that iOS7 (meaning that your app would still be able to run on iOS6)
It will produces the same set of image files that you would have had to produce without using Assets Catalog, namely <YourImageName>.png, <YourImageName>#2x.png, <YourImageName>~ipad.png, <YourImageName>~ipad#2x.png and so on, for each image set of your xcassets.
If your "Deployment Target" is iOS7 or greater (meaning that your app would only be able to run on iOS7+)
It will produce a single big .car file in the final bundle (I don't really looked up if this file was actually an sqlite3 datatbase or some proprietary format or whatnot, but who cares, you are not supposed to manipulate it anyway). This big .car file contains all the images, with all their provided variants, and even with slicing info (if you did slice some of them for tiling or to use them as 9-patch images using the tool provided for that in the Assets Catalog editor)
Whatever the produced result you shouldn't / are not supposed to dig into internal details of your bundle like that. The format of the .car file may even change from one iOS version to another (who knows? that's internal details after all which we shouldn't have to deal with) so don't base your logic on it.
[EDIT]: If you need to be sure to have a directory with your set of images at the end of the compilation, you could instead use a folder reference (referencing a real folder in the Finder, as opposed to an Xcode "group" as only group files in Xcode's Project Navigator) then use code to browse it. But then you will have to deal with other details, like only browse files that match the current device (iPhone vs. iPad, non-retina vs. retina…), so this would only shift the problem further in your case; you really should use a constant somewhere to declare the number of images (or put this in some PLIST file for example) and iterate thru them.
As the files you provide at compile time will be in your Bundle — which cannot be altered once compiled as it is digitally signed — the number of images will never changed once the app is compiled anyway. (That's not like if you used the Documents directory and enabled iTunes File Sharing or whatever, letting the user add images himself ;-))
If you're targeting iOS 7+ then no. Xcode will package the files into a proprietary format (.car) that you can't access directly.
Either use imageNamed: methods, or don't use Image Catalogs for the files you need to access directly.
as #AliSoftware suggests you can store all assets images to plist and access them later for more details see here
When I drop a .XCodeProj or .App file in DropBox (and there I am assuming, other packages)the files in the package seems to be randomly not copied--sometimes none of them are copied, sometimes some of them, never all of them.
This happens even when I zip the file, copy it to dropbox and unzip it there.
How could DropBox have this grave an error this far along in it's existence? Lost a whole day of work finding this out. Disastrous.
In particular the project.pbxproj file was NEVER successfully copied into dropbox, or at least never made it to any of my other drives that were synced with the first.
Does anyone know if there is a fix for this?
.app is essentially a directory, so Dropbox will see it as one and uploads each individual file in there.
You need to zip your project directory then sync to dropbox; same would go for the .app.
Maybe you need to delete previous version of the file you want to upload to Dropbox (.XCodeProj, .app or .zip) with the web interface and then try upload it again. You can do this in 3 easy steps:
Log in to Dropbox
Click the "Show Deleted Files" button
Find and delete the old version of the file you want to upload (The grey one)
Also: Dropbox doesn't upload the whole file everytime you upload a newer version of it, infact it only uploads the newer parts (But I'm not 100% sure about this).
I hope my answer can help you :-)