Can't configure background image for DMG installation using CMake - background-image

I am working with CMake 2.8.10.2 on Mac OS X 10.7.5.
I've configured CMake to build a simple application with Xcode that creates an empty window. I then tried to configure CMake to build a DMG installation of the program specifying a background image using:
set(CPACK_DMG_BACKGROUND_IMAGE /path/to/image)
and custom .DS_Store to set windows size and icon placement using:
set(CPACK_DMG_DS_STORE /path/to/DS_Store file)
Xcode will successfully build the application and create the disk image. When I mount the image it comes up with the correct size and icon placement, however the background is always set to white instead of specified background image.
What is needed to get the background to display properly in the disk image?

Unfortunately no one has responded this question. This has been a frustrating experience, however, it looks like I finally solved it so I'm posting a description here to save someone else the grief if they ever have to deal with this.
In order for a background to work on an installation image, basically two things must happen; the background file must exist within the installation image, and the .DS_Store at the root of the image must be configured to use that background.
The .DS_Store file can be configured by mounting the install image in a writable state and then selecting Show View Options from the Finder's View menu. From there someone will select the Picture option for the Background and drag the background file to the placeholder in the Show View Options panel.
When working with CPack, the trick is to be able to drag the image. When someone sets the background for the installation, builds, and mounts the image it will not look like there is any background to drag to the Show View Options panel. If someone goes into the Terminal and does
ls -a
on the root of the mounted install, that command will list, among other things, a file called background.png. This file does not display in the Finder.
The reason this file displays in the Terminal and not the Finder is because it has an extended attributes that makes it hidden for the Finder. Since the file is hidden from the Finder it is not possible to drag the file to the Show View Options panel. Doing
ls -l#
will reveal what extended attributes are applied to the file. There should be only one called com.apple.FinderInfo. Removing this attribute should make the file visible in the Finder. The attribute can be removed using this command from the Terminal
xattr -d com.apple.FinderInfo background.png
After removing the attribute the background file still will not show up in the Finder right away. Someone will have to eject and remount the install image. Once this has happened, the background file should appear in the Finder and someone can drag it to the Show View Options panel, which will cause the background image to display in the Finder window for the install image. After that, someone can copy the .DS_Store file from the root of the install image and apply it to the CPACK_DMG_DS_STORE attribute, and the background image should appear whenever an install image is built.

#TronThomas response helped me out dramatically. Not to supplant his answer, here's some additional information about the process that I just worked through. For reference, this is with MacOS Sierra and CMake 3.6.2.
Set a background image with set(CPACK_DMG_BACKGROUND_IMAGE /path/to/image)
Create the DMG file using the CPack generator DragNDrop
Mount the image in read/write mode using a shadow file hdiutil attach mypackage.dmg -shadow junk.dmg
At this point, we don't see a background image, but one exists in the folder .background in the DMG file. Our strategy will be to use Finder to make the window exactly how we want, then copy out the .DS_Store file.
On the Finder menu, click View->Show View Options
Under Background:, click the Picture radio button. Then, click the image above the text Drag Image Here. Note, the current view must be as Icons otherwise this dialog will not be there.
In the file dialog, go back to the mounted DMG image. Then, press cmd-shift-. This should show the hidden folders. From here, go into the .background folder and select the background image.
If everything has worked properly, the background image should now be visible.
Adjust the windows size and view or hide toolbars as desired on the View menu. The exact settings will be replicated by the installer.
Copy off the the hidden .DS_Store file in the root directory of the volume to another location. The cmd-shift-. trick can be used view the file or just use the Terminal at this point to copy everything. Note, we can change the name of this file to DS_Store, so that it's not hidden when we store it.
Eject the DMG file from Finder. Delete junk.dmg or any shadow files remaining.
Back in the CMakeLists.txt, set the variable set(CPACK_DMG_DS_STORE /path/to/DS_Store) This is the file that we just created and moved off of the volume.
Rebuild the DMG file with CPack. Everything should be as viewed before.
As a warning, there's a lot of information that gets stored in the .DS_Store file such as file locations, user names, and the like. At the moment, I don't know how to control this information, so be a little careful when distributing the final DMG file. If you're curious as to what's in there, use a hex editor like xxd.
As a brief comment, this process is very obtuse. That said, I don't think it's Kitware's fault. Though, they could document the process better. From what I can tell, the .DS_Store file format is not well documented or disclosed, so we're basically forced to use Finder to make one for us. This is a MacOS issue that probably should be fixed.

Related

Issue viewing source files in doxygen

I'm using Doxyfile 1.8.17, and decompiling an Android app, with apktool, and also unzipping the APK to view some files in there too with Doxygen. I've managed to pull only what I need using EXCLUDE_PATHS. SOURCE_BROWSER is set to YES. My problem is whenever I go to click on the file in File List, I just get a link to go to the source code of the file. When I click it, it opens the source code in the right plane. I would like to just click the left plane and view the source code instantly in the right plane, however, there doesn't seem to be an option to change the behaviour. In the html output folder there is two types of files. foo.html and foo_source.html. This is the same for every file that you pull from INPUT sources. I just want it to show me foo_source.html and nothing else. Is this possible?

How to change location of iPhone app icon?

Okay, I am a noob. It must be simple but I stuck here.
I do rigth-click and choose 'select file'.
After I choose the file the dialogue appears:
I want to keep my icons not in the root directory. But I can't figure out how to do this. I tried different ways, even create project from scratch...
Please help.
When you bring image assets into Xcode they will all be in your application bundle's root directory at run time.
It appears that you've added a file named "icon#2x.png" to your project at one time already. Go to the project's summary page in Xcode click Build Phases and then expand the section titled Copy Bundle Resources. There you'll find the reference to the resources that will be copied to your bundle at run time.
More on bundle structures here:
https://developer.apple.com/library/mac/#documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html
Anyway, the way I've done this in the past is to:
Remove the existing image duplicate from Xcode and from the folder structure in Finder.
Add a new folder in Finder call it "/AppIcons" (or whatever).
Copy all the app icons to that folder in Finder.
Drag the "/AppIcon" folder into your XCode project. I typically put images in an "/Images" subdirectory in the Xcode project. Again you can put it wherever you'd like.
In Xcode on the project summary panel, add your app icons from the folder "/AppIcons" by dragging / dropping or by right clicking and adding them as separate files.
Alternatively in the past when I've had problems with this sometimes Xcode will copy the app icons to the root project directory. If that happens, I make sure that I have the "/AppIcons" folder structure on disc (in Finder) and in my Xcode project. I add the app icons to the project, then move them to /AppIcons in Finder, and re-reference them all over again.
Your Copy Bundle Resources should then have the proper file reference. Note that my apps icons go in "/Images/AppIcons"
Good luck!
I would add the image files to your project with the name icon#2x.png. To do this right click where you want to add the files in xcode and click add file/s. Then search for your image and add them using the dialogue that pops up. - there is a check box so that you can either copy them to the projects destination folder which will copy them into you project folder or leave it unchecked (inadvisable) which would reference it's current location on your HDD. Make sure the file doesn't already exist in the project before doing this!
EDIT:
Sorry I forgot to mention then drag and drop the file from within xcode onto the image location box.
In XCode 4 (I'm using 4.6.2) you will get this confusing message if you've just moved the target's info.plist file, but not corrected the location at the top of the summary panel. Fix this and the icons will reappear, assuming they are added to the project, or if not you should now be able to drag them in without xcode insisting on making extra copies.
This tends to happen when you're starting a project and sorting out the mess of default file locations that xcode gives you. I like my project structure to be 99% the same as the file system structure.
This is an easy fix. If the image you want as your App Icon resides outside of the root of your project, when you get that dialog just click "Yes", and then click delete on the newly created file in the root, and "Move to Trash".
The reference is still there and works without a hitch, since the file will still be in the root at runtime

Set Application Icon Using Canonical Quickly

Is there a simple way to set an application's icon using canoncial-quickly? I have tried setting the icon file of the main window within Glade, but the application still uses one of the stock GTK icons as its main icon in Unity on Ubuntu 12.04 LTS.
Navigate to the directory with your Quickly Ubuntu application in it. Let's say it's called myproj. Inside myproj is a directory named data. Inside data is a directory named media. And in there you should see a graphic file named myproj.svg. Replace myproj.svg with a scalable vector graphics image of your choice. You can either download an svg off the web, or create one for yourself in Inkscape. The next time you run your application, it will pick up myproj.svg as its icon.

Could not load "my-icon.png" image referenced from a nib (iPhone)

I am receiving the following error message:
2011-02-11 14:47:13.815 myProject[13177:207] Could not load the "icon-troubleshoot.png" image referenced from a nib in the bundle with identifier "com.myCompany.myProject"
This file is an old file that was being used before, but has now been deleted. As far as I know icon-troubleshoot.png is not used anywhere in my project. I tried cleaning and rebuilding, emptying caches but it didn't work. Searching for the string troubleshoot as a textual reference and "contains" selected returned nothing. Does anyone know how I can find what is causing this error?
The warning message suggests there is a reference to this png file in your .xib or .nib file(s).
Now the question is how to find it. Xcode is poor at doing this. Opening every nib file in a text editor like textedit and manual searching is time consuming.
The best solution I have for such searching tasks is to fire up terminal and use grep command. Go to source folder of your project in terminal then you can run the following in your case:
grep -i -r --include=*.xib "my-icon.png" ./
This will return all *.xib files where my-icon.png is referenced.
Later when you will see those *.xib files in xcode you'll find a '?' sign in place of my-icon.png showing that image is indeed missing as you deleted it. Now you deleted it to replace it with another image. So select '?' mark symbol, open Utilities area (to the right) and choose the correct file name. That is all.
as far as I know the search tool of x-code do not search inside the xib files that's why your search returns nothing. Anyway It's really probable there's still a reference in a xib file somewhere. Because xib files are just xml, if you don't want to check all them manually, try to open all your xib with a text editor like TextMate and perform a global text search over the content for the .png filename.
Hope this helps.
Ciao!
Clean the whole project and recompile.
There must be a reference to this file in one of the nibs. If you can't find it, try deleting the nib file where the image was used, and create a new one.
Also, check your bundle for a reference to the image file.
I had this exact same issue and I found that when I included this file in the project I didn't specify both my Development and Distribution targets, only Development, so as soon as I tried building Distribution target, it wasn't found. You have to delete reference to this image, then re-add it and make sure you checkmark all of the targets that it should be found in.
This could happen if you only have an imageName#2x.png image and have run a low resolution non-retina display build.
Cut the height and width in half in your favorite image editor and then save it in the same folder as the #2x as imageName.png
Select your storyboard object in solution explorer, right click on storyboard->"Open As"->"Source Code", now you will see xml code from storyboard. Search your image name with Cmd+F and replace or remove it.

Problem removing and re-adding an image file into my iOS4 app bundle

My problem is something that should be so simple it is mind boggling. When I change the look (in PhotoShop) of an image file that is being stored in my app bundle. My method for replacing the old image in the bundle with the new one is this:
1) remove the old image from the app bundle (choosing to also move to trash)
2) drag the new image into my file hierarchy in xcode (choosing to copy to app directory)
when I do this, the app cannot find the image no matter what I do. The new images have the same name as the old images but none of the image loading methods (imageNamed, imageWithContentsOfFile, nibs) work. (Although I believe nibs also load with imageNamed, i'm not sure).
Is there something that I am missing here? I feel like it should be a relatively simple process but I am having all kinds of trouble. I also make sure to delete the app off of the target device and clean all targets before rebuilding and running after changing the image files just in case.
Any help would be appreciated.
Thanks
Your problem is probably that the image is not copied to the target. In xcode groups & file pane, fine the node for targets, expand your app target and you'll see Copy Bundle resources expand it and you'll see all the files copied to the default resource bundle when you deploy your app to the sim/device. Only the resources found there will be available to your app. If you don't see your image there you can just drag it there and everything will work.
Now, in order to understand why this might happened we need to look at the different options for adding files to xcode.
When you're adding a file to xcode you are presented with a dialog that includes a few interesting and sometimes overlooked option.
The first - Should the file be copied to the project folder, or should it just point to the file original location. The safest way will be to always copy the files to the project's path. However for images (such in your case) I do it differently. I maintain a separate graphics folder for every app, I save images there (both sources, and final png). When I add an image I do not copy it to the project folder, rather xcode just points to its location. That way I can just edit the image in photoshop, do a rebuild, and the updated image will show up on the phone. Whats important to understand that the directory structure of files you include in the project have almost no meaning, files that appear in the Copy Bundle Resources for the target will always be copied to a single (and flat) bundle/"directory" on the phone. The only exception for this is if you actually add directories to xcode (Personally I recommend against it).
The second option when adding files, is to which targets to add the file. This is the list with checkboxes on the bottom, if when you added the image, your app target wasn't checked the file won't be included in the target Copy bundle resource, and won't be available for the phone.
A few caveats - When using references to files in other location, that location is relative to the project's path, so it's a good idea to keep all the files in directories below the project's root directory. That way you can still copy the entire project to a different location and it will still work.
Great advice above: I thought I would add more for future searches on this topic:
I was adding and removing images to the project just like above:
Remove the old image from the app bundle (choosing to also move to trash).
Drag the new image into my file hierarchy in xcode (choosing to copy to app directory).
However when I tried to drag the new image with the same name to my file hierarchy in xcode I was getting an error that this was not allowed.
Turns out when I was removing the old image Xcode was removing it from the project file hierarchy but the actual file wasnt being removed from the project's root directory.
I solved my problem by removing the image from the project's root directory and added the image again!
Do you put your images in a custom sub-folder? If you just drag in images into the Xcode project tree, if you copy them, the images will be copied to the root of the project directory, instead of the "Images" or other folder you might have set up.
Note that you can right-click on the image in your bundle, select "Get Info..." and reset its location, if it has been moved or copied to a folder you didn't expect.