Search code examples
objective-cnwjs

Inlcuding another .app in an objective c application


Here's the situation. I have created an application using nw.js, which is great because I like using html, css and javascript. However now I would like to sell this application. What I'd like to do is make a small wrapper application in objective-c that will verify the users serial number and provide some level of copy protection. In my mind I imagine having an application that would be in objective-c. That would start and verify the user, then if the user was legitimate it would unpack some essential files into the nw.js bundle and start that application.

Now the nw.js executable is already in an application package, what I'd like to do is nest that package inside the objective-c one and then run it at the appropriate time. Can anyone advise on whether this is possible and if not how else I could approach the problem to secure my application.

Thanks for any help.


Solution

  • There's no problem with this, and nesting applications this way is pretty common on OS X (since you say ".app" I'm assuming this is OS X, and not iOS. This is impossible on iOS). I doubt it'll be particularly effective as a copy-protection mechanism, but that's a completely different question (see the links for several discussions on this topic).

    To the question of "what would be highly effective?" unfortunately the answer is "if you have to ask on Stack Overflow, then nothing you do is likely to be highly effective; do something simple and move on." It doesn't mean you're a bad programmer or anything; it's just that copy protection is a game of obfuscation, and if you're using things you found on Stack Overflow, they're probably not that obfuscated. Anything you come up with over a week probably isn't that obfuscated. And if you do come up with something really good, you'll still need to keep updating it regularly every time it gets broken. Apple has a whole team devoted to this, and they control every part of the system including the hardware, and still there are jailbreaks.

    Again, that doesn't mean you can't do anything. You can stop a few people, maybe, particularly if your app isn't that interesting. But don't waste too much time on it, because it's not going to be that effective. (If this really is important for your business plan, you should research commercial solutions. I have no recommendations there, but expect to spend some money, and to update to new versions as they're defeated.)

    That said, nesting apps isn't hard.

    Make the "sub-app" a dependency of your target.

    Add a new "Copy Files" Phase to your build:

    enter image description here

    Set the destination to "Executables" and drag the app bundle here:

    enter image description here

    When you're to launch it, just find it using NSBundle.pathForResource:... and then launch it with an NSTask.