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

How to call diagnosticsForApplicationWithBundleID from fbsimctl? #391

Open
bootstraponline opened this issue Mar 5, 2017 · 5 comments
Open

Comments

@bootstraponline
Copy link
Contributor

bootstraponline commented Mar 5, 2017

I'm trying to get the data/Containers/Data/Application/<app_id> path using the diagnose command.

$ fbsimctl --state=booted diagnose bundle.id

xcrun works.

$ xcrun simctl get_app_container booted bundle.id

[diagnose] Action: Diagnose
===========================

	diagnose {{ --current-format | --path | --content }} [diagnose/query]

	--content                	
	--current-format         	
	--path                   	


[diagnose/query] Diagnose: Query
================================

	{{ <application> | <bundle-id> }} <string>+
@lawrencelomax
Copy link
Contributor

get_app_container in simctl will only return the location that the Application Bundle is installed into and not the "Home Directory" of an Application that is used at runtime. These are different directories and there is know currently known API for obtaining this directory. You can see the install path for an application by using list_apps, but not for the Application's Documents Jail.

This can currently be inferred from a running Application, but not for an Application that is not running. We could expose this in list_apps instead, which might make more sense.

@lawrencelomax
Copy link
Contributor

We could persist this data by writing to a file that maps bundle_id to Application Documents jail every time FBSimulatorControl launches an Application. This means that the directory could be inferred assuming there was a prior launch of the Application.

@bootstraponline
Copy link
Contributor Author

bootstraponline commented Mar 6, 2017

I'm currently using this approach. I calculate the data application path:

def app_path(bundle_id)
    path = `xcrun simctl get_app_container booted #{bundle_id}`.strip
    raise 'get_app_container command failed' unless $CHILD_STATUS.success?
    path = join(path, '../' * 4, 'Data/Application')
    raise "path doesn't exit: #{path}" unless File.exist? path
    path
  end

then parse the plists until I find a match:

def metadata_id(plist)
    result = `/usr/libexec/PlistBuddy -c 'Print MCMMetadataIdentifier' "#{plist}"`.strip
    raise 'PlistBuddy command failed' unless $CHILD_STATUS.success?
    result
  end

This can currently be inferred from a running Application, but not for an Application that is not running

I think exposing the currently app's directory is sufficient for my use case. EarlGrey writes data to this directory and I'm trying to copy the results to a new folder after the tests finish executing.

We could persist this data by writing to a file that maps bundle_id to Application Documents jail every time FBSimulatorControl launches an Application.

If there was a fbsimctl command to list all the currently known bundle_id mappings then I think that'd work as well.

@lawrencelomax
Copy link
Contributor

I wasn't aware that it was possible to get the App Container in that way, but I suppose that makes sense given iOS has to know the path of the Application container in any case.

With that knowledge it should absolutely be possible to add this as an API in FBSimulatorControl, we just need to get the path to the same plist parse it and then combine this data with the list of installed Applications.

@jmoody
Copy link
Contributor

jmoody commented Mar 13, 2017

This is how we have been finding the data container in Calabash iOS and in Xamarin UITest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants