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

Failed to unhide archs in executable file:///private/var/installd/Library/Caches/com.apple.mobile.installd.staging/temp #14100

Closed
yanchunhuo opened this issue Mar 24, 2020 · 14 comments
Labels
Enhancement feature iOS related to iOS native driver(s)

Comments

@yanchunhuo
Copy link

The problem

I can't use appium desktop to install ". IPA" package to the real device by setting the app of capability, but I can install it normally by using ideviceinstaller - I ". IPA". When I use ideviceinstaller - I ". IPA" to install, I can use bundleid to start the app

Environment

  • Appium version (or git revision) that exhibits the issue: appium1.15.1
  • Last Appium version that did not exhibit the issue (if applicable):
  • Desktop OS/version used to run Appium: macOS 10.15.3
  • Node.js version (unless using Appium.app|exe):
  • Npm or Yarn package manager:
  • Mobile platform/version under test: iOS12.4
  • Real device or emulator/simulator: Real device
  • Appium CLI or Appium.app|exe: appium-desktop

Details

I can't use appium desktop to install ". IPA" package to the real device by setting the app of capability, but I can install it normally by using ideviceinstaller - I ". IPA". When I use ideviceinstaller - I ". IPA" to install, I can use bundleid to start the app

Link to Appium logs

[error] [XCUITest] Error: Unexpected data: {"Error":"APIInternalError","ErrorDescription":"Failed to unhide archs in executable file:///private/var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.T1ia91/extracted/aaa.app/%E6%8E%8C%E9%80%9A%E5%AE%B6%E5%9B%AD%E5%9B%AD%E4%B8%81"}
[error] [XCUITest] at InstallationProxyService._isFinished (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-ios-device/lib/installation-proxy/index.js:132:13)
[error] [XCUITest] at InstallationProxyService._isFinished [as _waitMessageCompletion] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-ios-device/lib/installation-proxy/index.js:124:16)
[error] [XCUITest] Error: Could not install app: 'Unexpected data: {"Error":"APIInternalError","ErrorDescription":"Failed to unhide archs in executable file:///private/var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.T1ia91/extracted/aaa.app/%E6%8E%8C%E9%80%9A%E5%AE%B6%E5%9B%AD%E5%9B%AD%E4%B8%81"}'
[error] [XCUITest] at IOSDeploy.install (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/lib/ios-deploy.js:41:13)

@mykola-mokhnach
Copy link
Collaborator

It looks like the application bundle has some resources inside it that are named weirdly. Make sure the file names inside the app bundle only contain ASCII characters.

@mykola-mokhnach mykola-mokhnach added the Needs Info typically non-actionable; needs author to respond label Mar 24, 2020
@yanchunhuo
Copy link
Author

It looks like the application bundle has some resources inside it that are named weirdly. Make sure the file names inside the app bundle only contain ASCII characters.

@mykola-mokhnach Is it because of these filenames
filenames

@mykola-mokhnach
Copy link
Collaborator

I assume these file names must be fixed in order to make it working with appium. In general, zip archives are not very happy about unicode chars in file names.

@yanchunhuo
Copy link
Author

I assume these file names must be fixed in order to make it working with appium. In general, zip archives are not very happy about unicode chars in file names.
@mykola-mokhnach These file names are in Chinese. Can appium support them? But the same ". IPA" package, why can I use ideviceinstaller to install.
filenames

@mykola-mokhnach
Copy link
Collaborator

@mykola-mokhnach These file names are in Chinese. Can appium support them? But the same ". IPA" package, why can I use ideviceinstaller to install.

Because this might take too much effort to make it working. I have proposed an easy and fast workaround though. Feel free to commit a PR to Appium if you have any good ideas.

@mykola-mokhnach mykola-mokhnach added Enhancement feature iOS related to iOS native driver(s) and removed Needs Info typically non-actionable; needs author to respond labels Mar 25, 2020
@yanchunhuo
Copy link
Author

@mykola-mokhnach These file names are in Chinese. Can appium support them? But the same ". IPA" package, why can I use ideviceinstaller to install.

Because this might take too much effort to make it working. I have proposed an easy and fast workaround though. Feel free to commit a PR to Appium if you have any good ideas.

@mykola-mokhnach I have modified the file names of Chinese characters. All file names are ASCII characters, but they cannot be installed。

Link to Appium logs

Error: Unexpected data: {"Error":"APIInternalError","ErrorDescription":"Failed to unhide archs in executable file:///private/var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.l0isN7/extracted/ztjyyd.app/%E6%8E%8C%E9%80%9A%E5%AE%B6%E5%9B%AD%E5%9B%AD%E4%B8%81"

@KazuCocoa
Copy link
Member

KazuCocoa commented Jul 4, 2020

Copied app already had wrong file name. The µùѵ£¼Φ¬₧.png should be 日本語.png.

$ ls /var/folders/y6/524wp8fx0xj5q1rf6fktjrb00000gn/T/202064-53753-11msanj.01vrk/Payload/kazu-sample.app/
Assets.car               Info.plist               _CodeSignature           kazu-sample
Base.lproj               PkgInfo                  embedded.mobileprovision 日本語.png

allExtractedItems in https://github.com/appium/appium-base-driver/blob/f4a20fbe8bdd3cae9ddef2b3fdcb866da3d5731b/lib/basedriver/helpers.js#L325 already had the wrong file name.

@mykola-mokhnach
Copy link
Collaborator

This is most likely related to max-mapper/extract-zip#74

Long things short - Zip files officially support charset encodings other than CP437 and UTF-8, but the zip file spec does not specify how it works. This library makes no attempt to interpret the Language Encoding Flag.

@KazuCocoa
Copy link
Member

Yeah, I read the same place.
As another workaround, users can do:

  1. Rename test.ipa to test.zip
  2. Unzip it to Payload/test.app
  3. Set test.app as app capability

@mykola-mokhnach
Copy link
Collaborator

mykola-mokhnach commented Jul 4, 2020

@KazuCocoa I would say this is an issue of MacOS ZIP library itself. See https://stackoverflow.com/questions/13261347/correctly-decoding-zip-entry-file-names-cp437-utf-8-or

In theory zip libraries that use UTF-8 to encode file names must trigger the General Purpose Unicode flag for such archive. yauzl properly handles files and defaults to CP437 if the flag is not set. A possible solution could be to repack the archive manually and set the necessary flag.

Another solution would be to guess file names encoding upon file extraction as it is stated in thejoshwolfe/yauzl#42 (comment). This could potentially bring new issues, since file names parsing will be completely on our side (currently the https://github.com/maxogden/extract-zip wrapper over yauzl is used for zip extraction)

@KazuCocoa
Copy link
Member

thanks.
I toyed entry.fileName a bit, but I finally thought giving troubleshooting was the most reasonable

@KazuCocoa
Copy link
Member

KazuCocoa commented Jul 4, 2020

appium/appium-base-driver#418 may fix this without the workaround...

@KazuCocoa
Copy link
Member

unzipper did not work, but the below could be the next item.

https://github.com/appium/appium-support/blob/master/lib/zip.js#L25-L27

decodeStrings is true by default. So, potentially we can handle the file name encode in our side with setting it false and trap it with entry.fileName (and make it configurable via capabilities)

@mykola-mokhnach
Copy link
Collaborator

The patch has been published to appium@beta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement feature iOS related to iOS native driver(s)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants