Skip to content

Conversation

@wilhuff
Copy link
Contributor

@wilhuff wilhuff commented Jun 14, 2019

This fixes #3184, where under some circumstances some bundles have no
CFBundleIdentifier in their Info.plist.

This fixes #3184, where under some circumstances some bundles have no
CFBundleIdentifier in their Info.plist.
@wilhuff wilhuff force-pushed the wilhuff/bundle-identifier branch from cf88c0e to 2219cc0 Compare June 14, 2019 14:17
if (!bundle) return "(nil bundle)";

NSString* identifier = [bundle bundleIdentifier];
if (!identifier) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is still Objective-C, this function could be:

NSString* identifier = [bundle bundleIdentifier];
identifier = [bundle bundlePath];
return identifier ? util::MakeString(identifier) : "(missing bundle identifier)";

Your version is much more explicit, though, and you can leave it as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second line of your suggestion doesn't work since we only want to do that if the -bundleIdentifier returned nil.

In general I'm not in favor of relying on nil dispatch. It's too easy to accidentally do when it's not intended and when reading code later it's hard to understand if it's intended or not. It also hides the conditional behavior in a way that's easy to overlook.

I did make the final line the ternary though.

@wilhuff wilhuff merged commit fa33421 into master Jun 14, 2019
@wilhuff wilhuff deleted the wilhuff/bundle-identifier branch June 14, 2019 19:23
@morganchen12 morganchen12 added this to the M51 milestone Jun 14, 2019
@firebase firebase locked and limited conversation to collaborators Oct 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FindCertFileInResourceBundle crashes when [NSBundle bundleIdentifier] is nil

4 participants