-
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(parse_app_package): fix failure to parse
Property List Binary
f…
…ormat
- Loading branch information
Showing
15 changed files
with
76 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,4 @@ SPEC CHECKSUMS: | |
|
||
PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 | ||
|
||
COCOAPODS: 1.11.3 | ||
COCOAPODS: 1.14.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/hello_world/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 0.4.0 | ||
|
||
* bump `parse_app_package` to 0.4.0 | ||
|
||
## 0.3.6 | ||
|
||
* bump `shell_executor` to 0.1.5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 0.4.0 | ||
|
||
* fix failure to parse `Property List Binary` format | ||
|
||
## 0.3.8 | ||
|
||
* bump `archive` to 3.4.10 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
|
||
```yaml | ||
dependencies: | ||
parse_app_package: ^0.3.6 | ||
parse_app_package: ^0.4.0 | ||
``` | ||
## Usage | ||
|
54 changes: 10 additions & 44 deletions
54
packages/parse_app_package/lib/src/parsers/ipa/app_package_parser_ipa.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,33 @@ | ||
import 'dart:convert'; | ||
import 'dart:io'; | ||
|
||
import 'package:app_package_parser/app_package_parser.dart'; | ||
import 'package:archive/archive.dart'; | ||
import 'package:archive/archive_io.dart'; | ||
import 'package:xml/xml.dart'; | ||
import 'package:plist_parser/plist_parser.dart'; | ||
|
||
class AppPackageParserIpa extends AppPackageParser { | ||
@override | ||
String get name => 'ipa'; | ||
|
||
_handleElem(XmlElement el) { | ||
switch (el.name.local) { | ||
case 'string': | ||
return el.value; | ||
case 'real': | ||
return double.parse(el.value!); | ||
case 'integer': | ||
return int.parse(el.value!); | ||
case 'true': | ||
return true; | ||
case 'false': | ||
return false; | ||
case 'date': | ||
return DateTime.parse(el.value!); | ||
} | ||
} | ||
|
||
@override | ||
Future<AppPackage> parse(File file) async { | ||
final ipaBytes = file.readAsBytesSync(); | ||
final archive = ZipDecoder().decodeBytes(ipaBytes); | ||
|
||
String xmlString = ''; | ||
Map<dynamic, dynamic>? result; | ||
for (final item in archive) { | ||
if (item.isFile && item.name.endsWith('.app/Info.plist')) { | ||
final data = item.content as List<int>; | ||
xmlString = utf8.decode(data); | ||
final data = item.content; | ||
result = PlistParser().parseBytes(data); | ||
break; | ||
} | ||
} | ||
|
||
XmlDocument xmlDoc = XmlDocument.parse(xmlString); | ||
XmlElement elPlist = xmlDoc.getElement('plist')!; | ||
XmlElement elDict = elPlist.getElement('dict')!; | ||
|
||
List<String> keys = elDict.childElements | ||
.where((e) => e.name.local == 'key') | ||
.map((e) => e.value!) | ||
.toList(); | ||
List<dynamic> values = elDict.childElements | ||
.where((e) => e.name.local != 'key') | ||
.map(_handleElem) | ||
.toList(); | ||
Map dict = Map.fromIterables(keys, values); | ||
|
||
AppPackage appPackage = AppPackage( | ||
if (result == null) throw Exception('Can\'t parse .ipa file.'); | ||
return AppPackage( | ||
platform: 'ios', | ||
identifier: dict['CFBundleIdentifier'], | ||
name: dict['CFBundleDisplayName'], | ||
version: dict['CFBundleShortVersionString'], | ||
buildNumber: int.parse(dict['CFBundleVersion']), | ||
identifier: result['CFBundleIdentifier'], | ||
name: result['CFBundleDisplayName'], | ||
version: result['CFBundleShortVersionString'], | ||
buildNumber: int.parse(result['CFBundleVersion']), | ||
); | ||
return appPackage; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters