Skip to content

Commit 78e3e1f

Browse files
authored
feat: apple silicon (#75)
* fix: build universal binary * chore: add lint-staged and husky to format cpp & h files
1 parent 0f7f8e2 commit 78e3e1f

33 files changed

Lines changed: 14261 additions & 13291 deletions

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/pre-commit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npm test
5+
npx lint-staged

IOSDeviceLib.xcodeproj/project.pbxproj

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@
11391139
70F6ADA31DEEB71300DD4722 /* Project object */ = {
11401140
isa = PBXProject;
11411141
attributes = {
1142-
LastUpgradeCheck = 0710;
1142+
LastUpgradeCheck = 1240;
11431143
ORGANIZATIONNAME = blackdragon;
11441144
TargetAttributes = {
11451145
70F6ADAA1DEEB71300DD4722 = {
@@ -1149,11 +1149,11 @@
11491149
};
11501150
buildConfigurationList = 70F6ADA61DEEB71300DD4722 /* Build configuration list for PBXProject "IOSDeviceLib" */;
11511151
compatibilityVersion = "Xcode 3.2";
1152-
developmentRegion = English;
1152+
developmentRegion = en;
11531153
hasScannedForEncodings = 0;
11541154
knownRegions = (
1155-
English,
11561155
en,
1156+
Base,
11571157
);
11581158
mainGroup = 70F6ADA21DEEB71300DD4722;
11591159
productRefGroup = 70F6ADAC1DEEB71300DD4722 /* Products */;
@@ -1210,17 +1210,29 @@
12101210
isa = XCBuildConfiguration;
12111211
buildSettings = {
12121212
ALWAYS_SEARCH_USER_PATHS = NO;
1213+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
12131214
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
12141215
CLANG_CXX_LIBRARY = "libc++";
12151216
CLANG_ENABLE_MODULES = YES;
12161217
CLANG_ENABLE_OBJC_ARC = YES;
1218+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
12171219
CLANG_WARN_BOOL_CONVERSION = YES;
1220+
CLANG_WARN_COMMA = YES;
12181221
CLANG_WARN_CONSTANT_CONVERSION = YES;
1222+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
12191223
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
12201224
CLANG_WARN_EMPTY_BODY = YES;
12211225
CLANG_WARN_ENUM_CONVERSION = YES;
1226+
CLANG_WARN_INFINITE_RECURSION = YES;
12221227
CLANG_WARN_INT_CONVERSION = YES;
1228+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
1229+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
1230+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
12231231
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
1232+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
1233+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
1234+
CLANG_WARN_STRICT_PROTOTYPES = YES;
1235+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
12241236
CLANG_WARN_UNREACHABLE_CODE = YES;
12251237
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
12261238
CODE_SIGN_IDENTITY = "-";
@@ -1253,17 +1265,29 @@
12531265
isa = XCBuildConfiguration;
12541266
buildSettings = {
12551267
ALWAYS_SEARCH_USER_PATHS = NO;
1268+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
12561269
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
12571270
CLANG_CXX_LIBRARY = "libc++";
12581271
CLANG_ENABLE_MODULES = YES;
12591272
CLANG_ENABLE_OBJC_ARC = YES;
1273+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
12601274
CLANG_WARN_BOOL_CONVERSION = YES;
1275+
CLANG_WARN_COMMA = YES;
12611276
CLANG_WARN_CONSTANT_CONVERSION = YES;
1277+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
12621278
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
12631279
CLANG_WARN_EMPTY_BODY = YES;
12641280
CLANG_WARN_ENUM_CONVERSION = YES;
1281+
CLANG_WARN_INFINITE_RECURSION = YES;
12651282
CLANG_WARN_INT_CONVERSION = YES;
1283+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
1284+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
1285+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
12661286
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
1287+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
1288+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
1289+
CLANG_WARN_STRICT_PROTOTYPES = YES;
1290+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
12671291
CLANG_WARN_UNREACHABLE_CODE = YES;
12681292
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
12691293
CODE_SIGN_IDENTITY = "-";
@@ -1281,6 +1305,7 @@
12811305
GCC_WARN_UNUSED_VARIABLE = YES;
12821306
MACOSX_DEPLOYMENT_TARGET = 10.10;
12831307
MTL_ENABLE_DEBUG_INFO = NO;
1308+
ONLY_ACTIVE_ARCH = NO;
12841309
SDKROOT = macosx;
12851310
};
12861311
name = Release;
@@ -1289,6 +1314,8 @@
12891314
isa = XCBuildConfiguration;
12901315
baseConfigurationReference = 70F5F4281E13EE02005196BF /* configuration.xcconfig */;
12911316
buildSettings = {
1317+
BUILD_LIBRARY_FOR_DISTRIBUTION = NO;
1318+
CODE_SIGN_IDENTITY = "-";
12921319
FRAMEWORK_SEARCH_PATHS = (
12931320
"$(inherited)",
12941321
"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks",
@@ -1304,6 +1331,8 @@
13041331
isa = XCBuildConfiguration;
13051332
baseConfigurationReference = 70F5F4281E13EE02005196BF /* configuration.xcconfig */;
13061333
buildSettings = {
1334+
BUILD_LIBRARY_FOR_DISTRIBUTION = NO;
1335+
CODE_SIGN_IDENTITY = "-";
13071336
FRAMEWORK_SEARCH_PATHS = (
13081337
"$(inherited)",
13091338
"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks",
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1240"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "70F6ADAA1DEEB71300DD4722"
18+
BuildableName = "ios-device-lib"
19+
BlueprintName = "IOSDeviceLib"
20+
ReferencedContainer = "container:IOSDeviceLib.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
<BuildableProductRunnable
44+
runnableDebuggingMode = "0">
45+
<BuildableReference
46+
BuildableIdentifier = "primary"
47+
BlueprintIdentifier = "70F6ADAA1DEEB71300DD4722"
48+
BuildableName = "ios-device-lib"
49+
BlueprintName = "IOSDeviceLib"
50+
ReferencedContainer = "container:IOSDeviceLib.xcodeproj">
51+
</BuildableReference>
52+
</BuildableProductRunnable>
53+
</LaunchAction>
54+
<ProfileAction
55+
buildConfiguration = "Release"
56+
shouldUseLaunchSchemeArgsEnv = "YES"
57+
savedToolIdentifier = ""
58+
useCustomWorkingDirectory = "NO"
59+
debugDocumentVersioning = "YES">
60+
<BuildableProductRunnable
61+
runnableDebuggingMode = "0">
62+
<BuildableReference
63+
BuildableIdentifier = "primary"
64+
BlueprintIdentifier = "70F6ADAA1DEEB71300DD4722"
65+
BuildableName = "ios-device-lib"
66+
BlueprintName = "IOSDeviceLib"
67+
ReferencedContainer = "container:IOSDeviceLib.xcodeproj">
68+
</BuildableReference>
69+
</BuildableProductRunnable>
70+
</ProfileAction>
71+
<AnalyzeAction
72+
buildConfiguration = "Release">
73+
</AnalyzeAction>
74+
<ArchiveAction
75+
buildConfiguration = "Release"
76+
revealArchiveInOrganizer = "YES">
77+
</ArchiveAction>
78+
</Scheme>

IOSDeviceLib/CommonFunctions.h

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
#pragma once
22

3-
#include <map>
3+
#include "Declarations.h"
44
#include "PlistCpp/Plist.hpp"
55
#include "PlistCpp/PlistDate.hpp"
66
#include "PlistCpp/include/boost/any.hpp"
7-
#include "Declarations.h"
7+
#include <map>
88

9-
AFCConnectionRef start_house_arrest(std::string device_identifier, const char* application_identifier, std::string method_id);
10-
inline bool has_complete_status(std::map<std::string, boost::any>& dict);
11-
ServiceInfo start_secure_service(std::string device_identifier, const char* service_name, std::string method_id, bool should_log_error = true, bool skip_cache = false);
12-
bool mount_image(std::string& device_identifier, std::string& image_path, std::string& method_id);
13-
std::string get_device_property_value(std::string& device_identifier, const char* property_name);
14-
int start_session(std::string& device_identifier);
15-
void stop_session(std::string& device_identifier);
16-
CFStringRef create_CFString(const char* str);
9+
AFCConnectionRef start_house_arrest(std::string device_identifier,
10+
const char *application_identifier,
11+
std::string method_id);
12+
inline bool has_complete_status(std::map<std::string, boost::any> &dict);
13+
ServiceInfo start_secure_service(std::string device_identifier,
14+
const char *service_name,
15+
std::string method_id,
16+
bool should_log_error = true,
17+
bool skip_cache = false);
18+
bool mount_image(std::string &device_identifier, std::string &image_path,
19+
std::string &method_id);
20+
std::string get_device_property_value(std::string &device_identifier,
21+
const char *property_name);
22+
int start_session(std::string &device_identifier);
23+
void stop_session(std::string &device_identifier);
24+
CFStringRef create_CFString(const char *str);

IOSDeviceLib/Constants.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,25 @@ static const unsigned kAMDAPIInternalError = 0xe8000067;
2626
static const int kUSBInterfaceType = 1;
2727
static const int kWIFIInterfaceType = 2;
2828
static const unsigned kAppleServiceNotStartedErrorCode = 0xE8000063;
29-
static const unsigned kMountImageAlreadyMounted = 0xE8000076; // Note: This error code is actually named kAMDMobileImageMounterImageMountFailed but AppBuilder CLI and other sources think that getting this exit code during a mount is okay
30-
static const unsigned kIncompatibleSignature = 0xE8000033; // Note: This error code is actually named kAMDInvalidDiskImageError but CLI and other sources think that getting this exit code during a mount is okay
29+
static const unsigned kMountImageAlreadyMounted =
30+
0xE8000076; // Note: This error code is actually named
31+
// kAMDMobileImageMounterImageMountFailed but AppBuilder CLI and
32+
// other sources think that getting this exit code during a
33+
// mount is okay
34+
static const unsigned kIncompatibleSignature =
35+
0xE8000033; // Note: This error code is actually named
36+
// kAMDInvalidDiskImageError but CLI and other sources think
37+
// that getting this exit code during a mount is okay
3138
static const char *kAppleFileConnection = "com.apple.afc";
3239
static const char *kInstallationProxy = "com.apple.mobile.installation_proxy";
3340
static const char *kHouseArrest = "com.apple.mobile.house_arrest";
3441
static const char *kNotificationProxy = "com.apple.mobile.notification_proxy";
3542
static const char *kSyslog = "com.apple.syslog_relay";
36-
static const char *kMobileImageMounter = "com.apple.mobile.mobile_image_mounter";
43+
static const char *kMobileImageMounter =
44+
"com.apple.mobile.mobile_image_mounter";
3745
static const char *kDebugServer = "com.apple.debugserver";
38-
static const char *kNewDebugServer = "com.apple.debugserver.DVTSecureSocketProxy";
46+
static const char *kNewDebugServer =
47+
"com.apple.debugserver.DVTSecureSocketProxy";
3948

4049
static const char *kUnreachableStatus = "Unreachable";
4150
static const char *kConnectedStatus = "Connected";

0 commit comments

Comments
 (0)