@@ -73,30 +73,40 @@ Application::Application(std::string appBundlePath)
7373 {
7474 throw SignError (SignErrorCode::InvalidApp);
7575 }
76-
76+
77+ // Required properties
7778 auto nameNode = plist_dict_get_item (plist, " CFBundleDisplayName" );
7879 if (nameNode == nullptr )
7980 {
8081 nameNode = plist_dict_get_item (plist, " CFBundleName" );
8182 }
8283
8384 auto bundleIdentifierNode = plist_dict_get_item (plist, " CFBundleIdentifier" );
84- auto versionNode = plist_dict_get_item (plist, " CFBundleShortVersionString" );
8585
86- if (nameNode == nullptr || bundleIdentifierNode == nullptr || versionNode == nullptr )
86+ if (nameNode == nullptr || bundleIdentifierNode == nullptr )
8787 {
8888 plist_free (plist);
8989 throw SignError (SignErrorCode::InvalidApp);
9090 }
91-
92- char *name = nullptr ;
93- plist_get_string_val (nameNode, &name);
9491
95- char *bundleIdentifier = nullptr ;
96- plist_get_string_val (bundleIdentifierNode, &bundleIdentifier);
97-
98- char *version = nullptr ;
99- plist_get_string_val (versionNode, &version);
92+ char * name = nullptr ;
93+ plist_get_string_val (nameNode, &name);
94+
95+ char * bundleIdentifier = nullptr ;
96+ plist_get_string_val (bundleIdentifierNode, &bundleIdentifier);
97+
98+ // Optional properties
99+ auto versionNode = plist_dict_get_item (plist, " CFBundleShortVersionString" );
100+
101+ std::string version (" 1.0" );
102+ if (versionNode != nullptr )
103+ {
104+ char * versionString = nullptr ;
105+ plist_get_string_val (versionNode, &versionString);
106+ version = versionString;
107+
108+ free (versionString);
109+ }
100110
101111 _name = name;
102112 _bundleIdentifier = bundleIdentifier;
@@ -105,7 +115,6 @@ Application::Application(std::string appBundlePath)
105115
106116 free (name);
107117 free (bundleIdentifier);
108- free (version);
109118
110119 plist_free (plist);
111120}
0 commit comments