ZGApkToolPath.m 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // ZGApkToolPath.m
  3. // UUTUtils
  4. //
  5. // Created by zhuge on 2017/12/27.
  6. // Copyright © 2017年 zhuge. All rights reserved.
  7. //
  8. #import "ZGApkToolPath.h"
  9. #import "ZGShellUtils.h"
  10. @implementation ZGApkToolPath
  11. + (ZGApkToolPath *)shared {
  12. static dispatch_once_t pred;
  13. static ZGApkToolPath *shared = nil;
  14. dispatch_once(&pred, ^{
  15. shared = [[ZGApkToolPath alloc] init];
  16. });
  17. return shared;
  18. }
  19. - (instancetype)init
  20. {
  21. self = [super init];
  22. if (self) {
  23. NSBundle *bundle = [NSBundle mainBundle];
  24. self.key = [bundle pathForResource:@"ApkTools/keyer/key.sh" ofType:nil];
  25. self.key_in = [bundle pathForResource:@"ApkTools/keyer/key_in.sh" ofType:nil];
  26. self.apktool = [bundle pathForResource:@"ApkTools/apktool" ofType:nil];
  27. self.sign_in = [bundle pathForResource:@"ApkTools/signer/sign_in" ofType:@"sh"];
  28. self.align = [bundle pathForResource:@"ApkTools/zipalign" ofType:nil];
  29. self.adb = [bundle pathForResource:@"ApkTools/adb" ofType:nil];
  30. [ZGShellUtils makeFileExecutable:self.key];
  31. [ZGShellUtils makeFileExecutable:self.key_in];
  32. [ZGShellUtils makeFileExecutable:self.sign_in];
  33. [ZGShellUtils makeFileExecutable:self.align];
  34. [ZGShellUtils makeFileExecutable:self.adb];
  35. [ZGShellUtils makeFileExecutable:self.apktool];
  36. NSString *aapt = [bundle pathForResource:@"ApkTools/aapt" ofType:nil];
  37. [ZGShellUtils makeFileExecutable:aapt];
  38. }
  39. return self;
  40. }
  41. @end