Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a command to check whether a device has enabled developer mode. D… #563

Merged
merged 5 commits into from
Aug 26, 2022

Conversation

ivanhernandez13
Copy link

…eveloper mode was introduced in iOS 16. When checking devices on older versions the command will print an unsupported error.

Retry of #556 that guards the developer mode check by a preprocessor define so that it is not build by default. Developer mode requires a MobileDevice method introduced with Xcode 14 so including it by default will break builds where Xcode 14 is unavailable.

ivanhernandez13 and others added 2 commits August 11, 2022 15:20
…eveloper mode was introduced in iOS 16. When checking devices on older versions the command will print an unsupported error.

Retry of ios-control#556 that guards the developer mode check by a preprocessor define  so that it is not build by default. Developer mode requires a MobileDevice method introduced with Xcode 14 so including it by default will break builds where Xcode 14 is unavailable.
@@ -91,6 +91,9 @@
mach_error_t AMDeviceLookupApplications(AMDeviceRef device, CFDictionaryRef options, CFDictionaryRef *result);
int AMDeviceGetInterfaceType(AMDeviceRef device);
AMDeviceRef AMDeviceCopyPairedCompanion(AMDeviceRef device);
#if defined(XCODE_14_OR_NEWER_AVAILABLE)

Choose a reason for hiding this comment

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

What happens if you compile this on Xcode14 and then run it against Xcode12? Wouldn't AMDeviceCopyDeveloperModeStatus not exist?

Copy link
Author

Choose a reason for hiding this comment

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

It would still work because there is a single MobileDevice.framework that gets updated along with each Xcode release. As long as the user installed Xcode 14 at one point and installed the developer tools, this feature will work.

Choose a reason for hiding this comment

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

What about centrally compiled versions? e.g. I believe Flutter and Cordova compile the ios-deploy binary on their server and then distribute that binary.

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure, I don't have a machine that hasn't had Xcode 14 installed but I think that would result in a crash when the program attempts to use the invalid symbol. I don't know of a good way around that so for that reason this feature is disabled by default and requires building with "-DXCODE_14_OR_NEWER_AVAILABLE=1" to enable. Then any tools that invoke ios-deploy would need to perform their own checks that Xcode 14 is available before attempting to use this feature.

Copy link

@gabebear gabebear Aug 22, 2022

Choose a reason for hiding this comment

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

For compiling it would be best to switch to a tbd file, so we don't have to gate on the version of Xcode used to compile, but requiring Xcode14 to compile is also an option.

For run-time checking I'd just put these calls not in the main path. If it fails we should try to tell them they need Xcode14 installed, but it's fine if it fails.

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure what "switching to a tbd file" means. ios-deploy won't compile if Xcode 14 has not been installed to the system because the MobileDevice framework that is dynamically linked won't have the symbol defined (the reason why I rolled back the previous commit). A tbd would fail the same way.

For runtime, I guess we could dlopen and dlsym to check if the symbols exists before we attempt to call it but simply noting the requirement in the usage + README.md seems sufficient to me

Copy link
Author

Choose a reason for hiding this comment

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

From our discussion offline, it seemed we had a misunderstanding over when the define would be defined, and by extension when the feature would be enabled. I've renamed XCODE_14_OR_NEWER_AVAILABLE to IOS_DEPLOY_FEATURE_DEVELOPER_MODE so it is clear that this define must be manually provided in order to enable the developer mode option. This feature is opt-in because it requires Xcode 14 on the machine that builds ios-deploy AND on the machine that runs it.

XCODE_14_OR_NEWER_AVAILABLE sounds like a define guard provided by Apple so I changed it to IOS_DEPLOY_FEATURE_DEVELOPER_MODE to make clear that this define needs to be provided manually.
@ivanhernandez13 ivanhernandez13 merged commit f36ec2b into ios-control:master Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants