Closed pang0018 closed 5 months ago
Greetings @asafkorem,
Could you please take a look at the issue and try to fix it if possible? Appium uses AppleSimulatorUtils to handle permissions, and this problem affects everyone who has upgraded their simulators to version 16 and above.
It might be helpful: I've tested idb approve $BUNDLE_ID location
and xcrun simctl booted privacy grant location-always
and they seem to work correctly.
Thank you for your time and consideration.
I just started seeing this after updating to the Xcode 15 GM and running on iOS 17. I was able to work around it by omitting "location" from the permissions I was setting entirely, since I don't need it. I am noticing that this was the same behavior as an issue with the "health" permission on iOS 16, which looks like it was fixed here: https://github.com/wix/AppleSimulatorUtils/pull/106. Maybe this is the same kind of issue?
same here, started reproducing it with Xcode 15, the issue is not only iOS17 for me, fails on 15.5 simulator as well. Command I'm running:
applesimutils --byId <device_id> --bundle <bundle_id> --setPermissions "location=always"
and the error message:
*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[5]. See “applesimutils --help” for usage.
I will take a look at this issue next week. Thank you for the report and the information provided.
I'm having the same problem setting location permissions after updating to iOS 17 / iPhone 15 / xcode Version 15.0 (15A240d) / - applesimutils version 0.9.10 / brew doctor / update
applesimutils --byOS 17.0 --byType iPhone\ 15 --bundle rs.contou.contours-development --setPermissions "location=inuse"
All other permissions are able to be set via applesimutils I.E
applesimutils --byOS 17.0 --byType iPhone\ 15 --bundle rs.contou.contours-development --setPermissions "photos=YES"
@Gnative does iOS 16 and below works for you? Are you getting error a similar to what mentioned here: https://github.com/wix/AppleSimulatorUtils/issues/117?
No, I don't have any error being displayed and my issue is only with location permissions, others work fine such as notifications, medialibrary and photos
Setting location permission, or any permissions, with iOS 15.5 is working. This is handy to know to get my e2e tests running while this is being resolved. Thanks.
applesimutils --byOS 15.5 --byType iPhone\ 13 --bundle rs.contou.contours-development --setPermissions "location=always"
Downloading iOS 16 now to try that as well to cover bases..
To note - originally I also had the same error as artem888 thou that was fixed with updating AppleSimulatorUtils to 0.9.10
Hello, I am facing a similar issue. I updated to Xcode 15 (and iOS 17) and now location permissions do not seem to be correctly applied (app is requesting location permissions, which breaks my tests). I am using the latest applesimutils version 0.9.10
.
@asafkorem I can confirm this issue is only related to iOS 17
iOS 15.5 and 16.4 work as you would expect in setting location permissions as well as the other available permissions
@dylanrandle Same problem as you are experiencing, I'm running my tests against iOS 16 for now, to be able to keep moving.
It's worth noting that the logs indicate that the permissions are set correctly, and it only seems to affect the location permissions in my case (notifications/contacts are correctly applied).
Can confirm that using iOS 16.4 resolves my issue.
I am not able to set location permission on XCode 15 iOS 17 simulator, notification and tracking permission are getting set perfectly on iOS 17. Location permission is getting set successfully on iOS 15 simulator on XCode 15 as well as on iOS 16 on previous XCode version so it seems there is a bug only for location permission and only on iOS 17. Applesimutils version latest 0.9.10
https://github.com/wix/AppleSimulatorUtils/issues/111#issuecomment-1680594128
I still have this error on the simulator with ios 16.4 and applesimutils 0.9.10 version
It appears as follows: if I apply --setPermissions location=always
, the application does not load further than the splashscreen (just where the app requests geo permission).
Even when running on iOS 16.4, using location permissions set to always
still fails in my detox tests.
The error output I get is
"applesimutils --byId 122A19D0-9C77-4CB1-81B0-02A767E36997 --bundle com.testapp.staging --restartSB --setPermissions location=always" failed with error = ChildProcessError: Command failed: applesimutils --byId 122A19D0-9C77-4CB1-81B0-02A767E36997 --bundle com.testapp.staging --restartSB --setPermissions location=always
*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[5]. See “applesimutils --help” for usage.
`applesimutils --byId 122A19D0-9C77-4CB1-81B0-02A767E36997 --bundle com.testapp.staging --restartSB --setPermissions location=always` (exited with error code 255) (code=255), stdout and stderr:
16:59:05.104 detox[6187] i
16:59:05.104 detox[6187] i *** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[5]. See “applesimutils --help” for usage.
@asafkorem Has there been any progress on this issue, or any workaround for this? I tried to downgrade my XCode version, but versions <v15 are not compatible with the Sonoma OS so that is not possible for me without downgrading my whole OS, which is not feasible
I am also hitting this issue with Location permissions not being set on iOS 17 when setting to 'Always', I am in desperate need of a solution or workaround
I'm encountering this issue as well. None of the location permission options seem to take. It makes it impossible for use to run our tests.
Since xcrun simctl
supports setting the location, we will use it on Detox and will deprecate this API on AppleSimUtils.
See xcrun simctl location --help
, https://github.com/wix/Detox/pull/4301
Do you have an example of how we can use that to set location permissions for a specific detox test? Or are you just saying that you are working on integrating xcrun simctl
into detox instead of relying on AppleSimUtils to set permissions?
Same problem here. Works on Xcode 14.1 but fails on Xcode 15.1
FAILS - applesimutils --byId mySimID --bundle mybundle --restartSB --setPermissions camera=YES,location=always
FAILS - applesimutils --byId mySimID --bundle mybundle --restartSB --setPermissions location=always
WORKS - applesimutils --byId mySimID --bundle mybundle --restartSB --setPermissions camera=YES
The failures give error:
Got error:
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
The operation couldn’t be completed. No such file or directory
No such file or directory
I was using:
EDIT: My original post was incorrect. This exact issue is not on iOS 16. It is only iOS 17. iOS 16 appears to have this issue if using an old version of ASU. I was testing on 2 machines, one of which hadn't been updated.
@micahdasMA This workaround might be of interest.
EDIT: This is only relevant if you just test against iOS 17.
It basically just running the following before the calling launchApp.
xcrun simctl privacy ${device.id} grant all my.app.bundle
I've quickly tested it and it seemed to work but it's not a great workaround. I think it would be a source of flaky tests and a better solution would be for detox to handle it. It will work for simple scenario's but if anything slightly complex I expect it will start to fail. We should probably raise a fresh issue for this as its not the same as the original post which was an issue on Xcode 13, the problem we are having only came about in xcode 15. (I'll do this tomorrow when I've had more of a think about this)
I'll be using it in the short term but will look for a better solution. Our company policy forced Somona 14 to install without warning which in turn forced be to move to Xcode 15 before I wanted too so I don't have any other options at this point in time.
const { exec } = require("child_process");
//before all hook calls launchApp
export const launchApp = async (deleteApp, newInstance, locationPerm, cameraPerm) => {
await setPermissions();
await device.launchApp({
delete: false, //MUST be false for this workaround to work
newInstance,
// PERMISSIONS WAS ORIGINALLY SET HERE
launchArgs: {
// our launch args
}
});
//CALLING SET PERMISSIONS AFTER device.launchApp WILL FAIL
};
export const setPermissions = async () => {
// Could be more specific than granting all permisions
const command = `xcrun simctl privacy ${device.id} grant all my.app.bundle`;
console.log('**** about to run command device ', command);
exec(command, (error, stdout, stderr) => {
// I had some logging here
})
};
Hey, in case you're experiencing AppleSimUtils issues with Detox, please upgrade to Detox v20.16. This version resolves this issue for Detox (we've migrated some commands from AppleSimUtils to Xcrun Simctl).
For any other use-case (not-Detox), please migrate your location permission command to Simctl. We will soon deprecate all ASU commands that have support on Xcrun Simctl.
location
option under --setPermissions
command is now deprecated, please migrate to xcrun simctl privacy
from the latest Command Line Tools for Xcode.
Check our deprecation update for more details: https://github.com/wix/AppleSimulatorUtils/blob/master/DEPRECATIONS.md
Description When setting the location permission for my app to
always
orinuse
via applesimutils, the app can no longer get the simulators locationIf you are describing an issue with
brew install
:brew doctor
and fixed all issuesSteps to Reproduce
applesimutils --byId EE55BEC3-22D4-47DE-90C9-2D3EAC26C843 --bundle com.yourbind.BindBenefits.mobile --setPermissions "location=always"
Expected Behavior App should continue to get device location
Environment
Additional Context A workaround after step 3 from above is to go to Features -> Location on the simulator menu and change to a different location and then back to the original location I had set. But, obviously, this would not work well with Detox automation testing