views:

114

answers:

2

Hi guys i have an executable for my cocoa application as xyz.app file. But when i copy this on windows, it is showing this as a directory with all the resource files and stuff. Is there any way to create a single file executable on mac also (like .exe file on windows) so as to disable the user from seeing the resource files and other files?

Thanks

+1  A: 

You talking about a Bundle, which is a folder that is given an extension and the OS treats it as if it is a single file, while in reality it is a folder with resources in it. The NIB files are stored in this bundle as well as your executable and the info.plist file. This is just the way apps work in Cocoa.

The only way around it would be to write your app in a different language, but i'm not sure which, if any, will give you a single file executable.

What are you storing in your app directory that you don't want people to have access to?

micmoo
i dont want people to have access to nib files and jpeg files etc
King
atleast is there any way to load these nibs and image files as object files rather than the original source files ???
King
I suppose you could create your own file format and store all your resources in that, and then write code to unpack those resources at runtime, but that seems like a lot of work to hide a bunch of files that are going to eventually be displayed on-screen anyway. Plus that's not the way Cocoa expects to load `.nib` files, so it may not even work for nibs.
mipadi
+1  A: 

There are ridiculously complicated ways to do that, sure. For example, you could gzip all your resource files and decompress them at runtime. But there's no good reason to do so — all it does is make more work for you, introduce additional complexity and make your app slow. Adobe doesn't do this, Microsoft doesn't do this, micro-ISVs don't do this — it's just not advisable.

Chuck
You can, for example, combine all your image resources into a single large bitmap and store the boundary coordinates of each (in a generated header file, e.g.) and then you just have the one thing which isn't really useful outside your context. And it improves performance doing only one load from disk and one memory allocation. :)
jeffamaphone
@Jeff: Maybe. That doesn't necessarily gain you anything. If you were going to display all the images as soon as the app loads, sure. Otherwise, you're might just be slowing down your app launch and possibly even bloating your memory footprint if a lot of the images are unlikely to be shown during an average session. It also still leaves your "source files" (images) easily viewable outside your program, so it doesn't address the question of "hiding" the files.
Chuck
Then guys if thats the case cant the end user use the nib files and modify the windows and stuff ???
King
like open the nibs and modify the strings etc...???? and change the images of the application????
King
Yes, the user can do that. But it's the user's machine, so the user can generally do whatever they want. Just don't support it. Call it out as officially forbidden in your EULA and don't worry about it
James Williams
It's possible to render nibs uneditable. But even if you actually stored the images as raw bitmaps inside your binary, it would still be possible for people to change them. Like I said, I don't see why this is a major fear for you. Nobody else seems greatly bothered by it. What is it that makes the possibility of somebody swapping images so problematic in your situation?
Chuck