Flutter iOS: by pass permission pop-up on emulator — integration testing

Install applesimutils (https://github.com/wix/AppleSimulatorUtils)

brew tap wix/brew
brew install applesimutils

Create new sh file called test_driver.sh and place in project root. Update “YOUR_APPS_BUNDLE_ID_HERE” to your bundle, update permission and iOS-13–6 version if needed. To get device list call: $ xcrun simctl list

# test_driver.sh content
echo "Shutting down all existing emulators..."
xcrun simctl shutdown all
echo "Recreating the emulator..."
xcrun simctl delete iOS13TestDevice || echo Failed to delete iOS 13 device
xcrun simctl create iOS13TestDevice "iPhone 8" com.apple.CoreSimulator.SimRuntime.iOS-13-6
echo "Booting..."
xcrun simctl boot iOS13TestDevice
echo "Checking boot status..."
xcrun simctl bootstatus iOS13TestDevice
echo "Running driver tests..."
flutter drive --target=test_driver/app.dart --debug & 
echo "Modifying permissions..."
applesimutils --byName "iOS13TestDevice" --bundle "YOUR_APPS_BUNDLE_ID_HERE" --setPermissions "notifications=YES" || sleep 90

Set execute permission to sh file

chmod +x test_driver.sh

Run test

./test_driver.sh

applesimutils Available Permissions

calendar=YES|NO|unset
camera=YES|NO|unset
contacts=YES|NO|unset
faceid=YES|NO|unset
health=YES|NO|unset (iOS 12.0 and above)
homekit=YES|NO|unset
location=always|inuse|never|unset
medialibrary=YES|NO|unset
microphone=YES|NO|unset
motion=YES|NO|unset
notifications=YES|NO|unset
photos=YES|NO|unset
reminders=YES|NO|unset
siri=YES|NO|unset
speech=YES|NO|unset

Leave a Reply

Your email address will not be published.Required fields are marked *