ms-intune-app-sdk-ios icon indicating copy to clipboard operation
ms-intune-app-sdk-ios copied to clipboard

Incorrect dylib load path for IntuneMAMTelemetry framework

Open erikkerber opened this issue 2 years ago • 4 comments

Describe the bug:

An app built with IntuneMAMTelemetry may crash at launch due to an incorrect load path. The path appears to be what one would expect for system libraries, not a path relative to the @rpath

IntuneMAMSwift vs IntuneMAMTelemetry

CleanShot 2022-08-19 at 12 34 36@2x CleanShot 2022-08-19 at 12 34 05@2x

To Reproduce Steps to reproduce the behavior:

  1. Link IntuneMAMTelemetry into a test bundle or app
  2. Run the executable
  3. Observe the crash

Xcode may mask this behavior. Using an alternate build system such as Bazel will expose it.

Expected behavior:

Use the @rpath in the load commands and not crash

Screenshots and logs:

image

 2022-08-19 12:15:40.956 xctest[90769:73175634] (dlopen(/tmp/test_runner_work_dir.Q6VQsP/IntuneServiceTests.xctest/IntuneServiceTests,
       │  0x0109): Library not loaded: /Library/Frameworks/IntuneMAMTelemetry.framework/IntuneMAMTelemetry
7799   │   Referenced from: /private/tmp/test_runner_work_dir.Q6VQsP/IntuneServiceTests.xctest/IntuneServiceTests
7800   │   Reason: tried: '/Applications/Xcode-13.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/
       │ Contents/Resources/RuntimeRoot/Library/Frameworks/IntuneMAMTelemetry.framework/IntuneMAMTelemetry' (no such file), '/Library/Frameworks/IntuneMAMTelemetry.framew
       │ ork/IntuneMAMTelemetry' (no such file), '/Applications/Xcode-13.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/R
       │ untimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/IntuneMAMTelemetry.framework/IntuneMAMTelemetry' (no such file))

Smartphone (please complete the following information): N/A

Intune App SDK for iOS (please complete the following information):

All 6.0.0+

erikkerber avatar Aug 19 '22 17:08 erikkerber

This can be worked around by doctoring the supplied xcframework/framework

install_name_tool -id @rpath/IntuneMAMTelemetry.framework/IntuneMAMTelemetry IntuneMAMTelemetry.xcframework/ios-arm64_x86_64-simulator/IntuneMAMTelemetry.framework/IntuneMAMTelemetry
install_name_tool -id @rpath/IntuneMAMTelemetry.framework/IntuneMAMTelemetry IntuneMAMTelemetry.xcframework/ios-arm64/IntuneMAMTelemetry.framework/IntuneMAMTelemetry

erikkerber avatar Aug 19 '22 19:08 erikkerber

Hi @erikkerber . Thanks for reporting this issue. Another work around would be to simply include IntuneMAMTelemetry.framework in your application's Frameworks directory. The Intune MAM SDK will load it dynamically. Your application doesn't need to link to it directly.

Thanks, Neil

msft-neiljac avatar Aug 19 '22 19:08 msft-neiljac

Hey @neiljac1! It is already included in Frameworks, but since the load path is pointing to the system library directories it can't be found.

It's a bit of a bulge of text, but the locations the runtime looks for it are listed in the last snippet above:

Reason: tried: '/Applications/Xcode-13.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/
       │ Contents/Resources/RuntimeRoot/Library/Frameworks/IntuneMAMTelemetry.framework/IntuneMAMTelemetry' (no such file), '/Library/Frameworks/IntuneMAMTelemetry.framew
       │ ork/IntuneMAMTelemetry' (no such file), '/Applications/Xcode-13.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/R
       │ untimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/IntuneMAMTelemetry.framework/IntuneMAMTelemetry' (no such file))

CleanShot 2022-08-19 at 14 41 35@2x

erikkerber avatar Aug 19 '22 19:08 erikkerber

I am able to work around the issue for now by patching the SDK in-situ from our builds using a variation of the command above. It works for tests, and I assume (but we'll know soon) that it fixes on device as well.

erikkerber avatar Aug 19 '22 19:08 erikkerber

@neiljac1 was this fixed intentionally? I don't appear to see it in 18.0.1, but also haven't checked recent versions.

erikkerber avatar Sep 21 '23 18:09 erikkerber

Hi @erikkerber, yes this was fixed in 17.7.2.

Thanks, Neil

msft-neiljac avatar Sep 21 '23 18:09 msft-neiljac