eemceebee
eemceebee

Reputation: 2666

How to hardcode CFBundleIdentifier?

what else can I say, how do I hardcode the CFBundleIdentifier in the app ?

Thanks

Upvotes: 1

Views: 1197

Answers (1)

user557219
user557219

Reputation:

If you want to change CFBundleIdentifier during runtime, you can’t unless you write to the application bundle Info.plist. That’s bad practice because the application bundle might have been moved to a read-only volume, or had its write permissions limited by the system administrator, or digitally signed to avoid tampering. I guess Launch Services wouldn’t recognise this change instantly and the application would have to be restarted. Furthermore, it is also a reason for rejection by the Mac Apple Store.

On the other hand, if you want to detect tampering of CFBundleIdentifier, you can always read its value upon application startup, e.g. in applicationDidFinishLaunching:

- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
    NSString *bundleId = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];
    if (! [bundleId isEqualToString:@"com.yourcompany.yourapp"])
    {
        // Ooops, CFBundleIdentifier doesn’t match
    }
}

Depending on your requirements, you might want to obfuscate the code above, including the literal strings. However, in general, you won’t be able to stop a determined adversary.

Upvotes: 5

Related Questions