It's the situation: I have my xcode project, a sqlite database, and images.
In the database I have the relative paths (VARCHAR) so I can access to the images salved in the document folder. If I let user download images after installation, it takes so long.
How can I preload images in document folder when the app is installed?
Thank you in advance.
Related
My application has one of these files but it doesn't seem to do anything and when I click on it, then it shows as empty.
That is an Asset Catalog Image Sets
Asset Catalog Image Sets - Use Asset Catalog Image Sets to manage and
group all version of a given image asset required by an app.
You can add images to your iOS solution, using Resources, or creating a Catalog Image Set.
You can read the official Apple Documentation
There is no default file called Styles.xcassets in the iOS project. And I think this is a normal Asset Catalog Image Sets file created by someone.
In an iOS project, the is a default Asset Catalog Image Sets called Assets.xcassets file and manager your image there.
Also, instead of using the Assets.xcassets, you can create more ....xcassets to manager your images. It can be more clear and is easier to distinguish different kinds of images.
For example, if there is a Styles.xcassets, you can put all images of style into this file. You can also create a Home.xcassets there to put all images in the homePage there.
Hope you understand What's a Styles.xcassets file in the iOS project used for now.
I have a sandboxed osx app which contains a huge number of logos as png-files.
If there are any logos missing, the app downloads the missing logos automitcally from the web.
Because the app is sandboxed, all logos are stored in a folder in Library > Applikation Support.
My question is now, how I could distribute the already existing logos with an app bundle?
The best way would be, if the app launches the first time, the logo-folder inside Application Support gets created and all Logos are copied from the bundle inside the new folder.
Is this possible with an app bundle or do I have to create an installer?
Any help would be much appreciated.
Let's see if we can round out the comments you've received so far.
My question is now, how I could distribute the already existing logos with an app bundle?
Short answer: just include them in the bundle as resources. Many applications include images for use in their GUI the only difference you have is maybe its a "huge number".
Long answer:
Here is the outline one way to do it:
Create a Group in Xcode, say Logos, which is associated with a folder (in Xcode 9 New Group generates the folder, prior to that you can create the folder-less Group and then use the File Inspector to add one).
Add your logos to this group. Do not mark these images as part of your target (otherwise Xcode will copy and flatten your folder structure)
Add a Copy Files or Run Script Build Phase to copy the images to a subfolder of Resources, say Logos.
As the images are part of your app bundle you can access them directly from there using standard bundle and file routines. There is no need to copy them anywhere.
Finally you managed to cause some confusion with the statement:
Because the app is sandboxed, all logos are stored in a folder in Library > Applikation Support.
It is unclear which folder you mean here, there are three obvious candidates:
System: /Library/Application Support
User: ~/Library/Application Support
Sandboxed App: ~/Library/Containers/<bundle id>/Data/Library/Application Support
If you are using the APIs (URLsForDirectory:inDomains:, URLForDirectory:inDomain:appropriateForURL:create:error:, NSSearchPathForDirectoriesInDomains), request the user domain, and are in a sandboxed app then (3) is returned instead of (2) and your sandboxed app has access to it with asking permission from the user.
A subfolder of Application Support (whichever one you use but (3) is recommended), typically named according to the bundle ID of your app, is the place you should store logos your app downloads – there is no need to copy images you include in your app bundle into the same location.
HTH
We have a Cocoa Mac OS X application in which we want to bundle around 500 images. Each image is around 10kb so size isn't a problem.
These images are not exactly resources in the app, they are sample images.
Basically, we have simple button that would let the user copy these images to a directory.
The solution also needs to be "dump in, dump out" -- so we don't want to store individual image file names somewhere in our application; we just want to have a directory of images that can be copied.
How do I package these into my application?
The question turns into: How do I make a directory resource containing the images.
In our case everything gets flattened into the MyApp.app/Contents/Resources and this approach would require us to put image names in the app so that we can copy those.
Put the images into a folder. Drag the folder into your project in Xcode. In the resulting dialog, make sure you copy, make sure you create a folder reference, and make sure you add to your app target. Done. Now the folder is part of your app bundle and you can refer to it from your code without knowing anything about its contents.
The folder /Library/Application Support is for support files that, if deleted, would not affect the execution of an application. I would suggest this is ideal for your product's sample images.
As Apple's documentation states for Application Support:
Use this directory to store all app data files except those associated with the user’s documents. For example, you might use this directory to store app-created data files, configuration files, templates, or other fixed or modifiable resources that are managed by the app. An app might use this directory to store a modifiable copy of resources contained initially in the app’s bundle.
So, use pkgbuild / productbuild to install them to /Library/Application Support/<ProductName>/
Because size is not an issue, you can just put all your sample images in separate Asset Catalog file.
I have to download new images from backend in background process and i need to save them for use later in the app.
In the other way, the original app images are in the asset catalog and when i add the new ones all images must accessed from the asset catalog.
I try to add images to directory's app but when i have to load any image the app do not know to discriminate between images in asset catalog and other, and i thing this is not the best solution for this
I do not know how add images to asset catalog on runtime or if i have to try other way to support this.
Any help i been so grateful
Many thanks!
Asset catalog is a resource file/folder, that means this is placed inside your bundle.
All files inside your bundle means it is not writable. The files inside bundle has only read permissions.
You have to store in any one of the sandboxed folders (Documents, Library and temp)
I have an iPad application which has many categorized images I need to switch between.
I store the categories in a database, along with the image prefix and number of images for that category. Using a random number in the range of 0-to-image_count_for_category, I get an image name like this:
[image_prefix][random_number].png => "SomeCategory3.jpg"
The images themselves are included in the project file structure and are not stored in the database.
All the image swapping is going fine. The problem lies in some of the image usage... I used to have an image "SomeCategory3.jpg", which was in the application, and has been displayed. Now, I replace the image named SomeCategory3.jpg, and the old image shows up ... Um ... how is that possible?
I have tried removing the app from the device, cleaning the project, re-building, and re-copying to the device for debug. Still, the old image comes up in that random rotation.
My app never copy the images anywhere. I simply reference them using the app folder with the image name appended.
I have verified that the old images are not in the folder or referenced by the project. I have viewed all the images in xcode to ensure the image displays properly.
Yet somehow ... the old image gets used in my random image swapping rotation.
It's driving me mad trying to figure out how the old image is there.
Any ideas?
Thanks!
Kevin
Xcode can't tell the image changed and did not overwrite the one in your app bundle's Resources folder. Right-click the image in your Xcode project and click "Touch" then rebuild. That or clean your target and rebuild.