How to distribute Image folder? - cocoa

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

Related

Website with auto updating image from latest file in folder

I am a noob with everything related to coding, except for some knowledge of the linux command line. Anyway, I have this idea for a project. I need a website with an image that updates every few hours or so. I have a folder in google drive, and every few hours a new image is uploaded. These times are not regular, but as long as the website gets the new photo within an hour-2hours, it will be fine. I was thinking of making an alias folder that links to the latest image in a folder (like how apple does it with time machine backups) if that makes sense. Then I would copy the link on google drive (of the alias folder) and put that into wordpress. It would pull that link, which would go to the latest image in a folder. I have a feeling that this would not work out, however. Basically, I just want an automated updater to pull the latest image from a google drive folder and publish it to the website. If it needs to be local, I could use the backup and sync for drive and the google drive folder would be synced to my local machine.
Another thing I was thinking of was a automatic slideshow maker. I would use some kind of script in google to delete all files in a folder except for the latest one. Then I would use the automatic slideshow maker to make a slideshow based on data in the particular google drive folder, which would be the latest photo.
Again, these are just some ideas that I have had, and they are both likely not going to work.
I have a self hosted web server (docker) and could put a wordpress instance on that, or I could use an online website builder like weebly or wix or even google sites. It needs to be free because this is for a community service project and I do not want to have to constantly fundraise. However, if my only option requires payment, I am open to that.
Does anybody have a solution for this?
Thanks!
There are several ways to achieve what you desire.
One approach:
I would suggest naming the image that you put in drive with the same filename. (renaming the old ones, as each new image is uploaded)
Google Apps script makes it easy (and free) to deploy a Web App, and using it gives you the benefit of using it's Drive Service among others.
Use a time-driven trigger to execute a function that renames your images so that the most recently uploaded one has the name of the image your website is requesting.
Alright, I have found an awesome solution! First, I setup a google account and made a folder in google drive. Then, I downloaded an app called DriveSync. I used the app Automate (by llamalab) to take photos (you can program it however you want it to trigger the photo). The trigger happens, then it deletes a file called latest.jpg in the Automate Image folder (on the android phone). Then it takes a photo with an image name of latest.jpg. And all of this is synced to the remote Google Drive Folder thanks to DriveSync. So now we have a synced google drive folder. Then, I setup a Wordpress Instance. Get the Add-On called Image and video gallery from Google Drive here https://wordpress.org/plugins/skaut-google-drive-gallery/. Now, follow the steps to link up your google drive folder to it, and configure your website to display this addon on your page of choice. It will pull the only image in the folder we configured earlier, and it will display it on the website! Plus it auto updates. Also, you can configure the image size which is helpful as this was probably meant to display more than one photo, but with only one photo there is a lot of empty space.
Hope you found this helpful!

can i send a tiny database from app inventor via whatsapp

I am trying to send a voice note from app inventor via whatsapp can I do that ,the activity starter isn't helping me at all. I tried creating a file text but still cant get through.It says unsupported file format.
Yes you can share via WhatsApp. You need to add element "sharing" for that.
Here's the example of sharing the image file to the whats app through the app created with app inventor.
But first you need to understand that there are two paths for any files while creating apps with app inventor.
Path where files are stored while development (live previews)
Path where files are stored after producing the app
path while development is:
file:///mnt/sdcard/AppInventor/assets/myFile
path after production is:
file:///android_asset/myFile
So while using "SHARE" component of app inventor you have to specify both paths to avoid any errors in future.
So here is the app:
Front End Arrangements:
Block Arrangements:
Pay attention to the if then else block.
It says if the image is not in the development path then the app is installed in the phone(produced). It saves our time to change path very often(and saves us from error if we forget to change paths)
Snapshot from the app:
After pressing share button:
After sharing through whats app:

Cocoa Mac OS X application bundling 1000 images

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.

Adding a .xcassets file to an Xcode framework project

I've got a framework project that uses a number of images. As it stands I just drag these images into the project so that they sit alongside my source files:
When I embed this project into a separate app project, I can access these resources as expected.
Ideally, I'd now like to organize my framework images with a .xcassets file. Unlike app projects, the framework project template doesn't provide one of these by default, so I've added one manually using the File > New menu. Unfortunately when I rebuild the framework and re-embed it, I can no longer access the images. Is what I'm trying to do possible?
If you want to access assets in a subproject (framework etc.) you need to make sure that you are collecting them from their own bundle since they are not part of the Main Bundle.
You can do that simply with this Swift 4 code:
let bundle = Bundle(for: type(of: self))
let image = UIImage(named: "imageName", in: bundle, compatibleWith: nil)
From what I can make out, the answer to my question is yes, sort of...
To make use of the NSImage(named: ...) API one of two things needs to be true: either the image should exist within the app's main bundle, or (to paraphrase the docs):
[there should be] an [NSImage] object whose name was set explicitly using the setName: method and currently resides in the image cache.
In the case where the image resides in an embedded framework, the first isn't true since the framework is a separate bundle, and there's no way of adding to the main bundle at runtime. This leaves the second approach.
Whenever your code is going to use NSImage(named: ...) make sure you've already loaded the image using some other way, then set its name:
let bundle = NSBundle(forClass: MyFrameworkClass.self)
let image = bundle.imageForResource(name) // image in the framework .xcassets
image.setName(name)
I don't know how much use this is, and you should definitely be aware of the notes in the docs about how the image cache operates, but it is at least one way of storing images in a .xcassets folder in one bundle, then accessing them from another.

Save image in asset catalog on runtime

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)

Resources