audioplayers icon indicating copy to clipboard operation
audioplayers copied to clipboard

fix: Audio not working in iOS 17 for UrlSource

Open samdeane opened this issue 1 year ago • 11 comments

This is a re-tread of @andyshephard's PR https://github.com/bluefireteam/audioplayers/pull/1728#issue-2037815778.

It looks like the tests are failing on that one (maybe just because linting is failing?), so I've recreated it in a place where I can potentially fix it.

samdeane avatar Mar 14 '24 16:03 samdeane

Hey @samdeane I already was working on fixing this PR in https://github.com/bluefireteam/audioplayers/pull/1763, where I also included some tests.

But I still struggle to make it work on macOS 14. I don't have a Mac (only validating via CI), so maybe you can help me out there. I prefer a proper solution, which also fixes the other bugs.

Gustl22 avatar Mar 14 '24 17:03 Gustl22

I can take a look, but I don't have a lot of time to spend on it, unfortunately.

Do you know what is failing on your #1763 branch? It looks like the iOS tests are failing along with the macOS 14 ones?

samdeane avatar Mar 15 '24 09:03 samdeane

The thing is I tried to make data uris work on ios 16 and 17. And there I need two different sets of options. And in xcode for ios 16 the option for ios 17 is not recognized, although it is wrapped within #available see:

Swift Compiler Error (Xcode): Cannot find 'AVURLAssetOverrideMIMETypeKey' in scope 

/Users/runner/work/audioplayers/audioplayers/packages/audioplayers_darwin/darwin/Classes/WrappedMediaPlayer.swift:184:36

And macOS 14 is failing in the tests regardless of my changes.

I guess we have to rebuild the ios/macos folder with the new flutter version and do a pod install to work properly. (Just a guess)

Gustl22 avatar Mar 15 '24 09:03 Gustl22

This is likely to be the problem on mac-os. The tests are throwing up a system dialogue and will hang until it goes away.

image

Need to take a look at the code signing options to see why that dialogue is appearing.

samdeane avatar Mar 15 '24 09:03 samdeane

There's a difference between testing for iOS 16 and building with an old version of XCode that only knows about iOS 16.

To use the code wrapped in #available you still have to be building against a version of the SDK that knows about that version - which means using a Github Actions mac runner with Xcode 15.

samdeane avatar Mar 15 '24 09:03 samdeane

It looks like the GH actions macos-13 image has Xcode 15 installed, and also has both the iOS 16 and ios 17 SDKs, so using that should be sufficient: https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md.

You should be able to test the different iOS builds by just picking a different simulator.

This stuff here is picking the device to run on: ``` UDID=$(xcrun simctl list devices | grep "iPhone" | sed -n 1p | grep -E -o -i "([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})") echo "Using simulator $UDID" xcrun simctl boot "${UDID:?No Simulator with this name iPhone found}"


It just picks the first device, which is fairly random.

You could instead use simctl to create test devices with specific device/sdk combinations, and then run the tests on each on in turn.

Something like: ```
UDID=$(xcrun simctl create test-se-17-4 com.apple.CoreSimulator.SimDeviceType.iPhone-SE-3rd-generation com.apple.CoreSimulator.SimRuntime.iOS-17-4)
xcrun simctl boot "${UDID:?No Simulator with this name iPhone found}"

samdeane avatar Mar 15 '24 10:03 samdeane

Thank you for your help and the detailed answers!

This is likely to be the problem on mac-os. The tests are throwing up a system dialogue and will hang until it goes away.

The thing is, it passes several tests, but not the others. So this is unlikely to be a signing problem, I think: https://github.com/bluefireteam/audioplayers/actions/runs/8293438418/job/22696520861?pr=1769

I vaguely remember to change the app id or team id to some random one in order to work locally: Something like this: https://stackoverflow.com/questions/77457132/every-time-i-run-my-app-in-xcode-it-asks-if-im-sure-i-want-to-allow-it-to-run

To use the code wrapped in #available you still have to be building against a version of the SDK that knows about that version - which means using a Github Actions mac runner with Xcode 15.

Yeah that's what I thought, too.

It looks like the GH actions macos-13 image has Xcode 15 installed, and also has both the iOS 16 and ios 17 SDKs, so using that should be sufficient

But it seems, that I have to build with xcode 15, and then somehow run on XCode 14 in order to get the required iOS version 16. 16 is not available on XCode 15 (macOS 13).

You could instead use simctl to create test devices with specific device/sdk combinations, and then run the tests on each on in turn.

Thank you :) That's what I actually tried here, but fails, because ios 16 is not available in that XCode version. https://github.com/bluefireteam/audioplayers/pull/1763/commits/1471576c0a017f1d5721099d0a26dff4cd812377

Gustl22 avatar Mar 15 '24 10:03 Gustl22

But it seems, that I have to build with xcode 15, and then somehow run on XCode 14 in order to get the required iOS version 16. 16 is not available on XCode 15 (macOS 13).

16 is not available by default on Xcode 15, but it is installable. That GH page I linked to implied that a number of SDKs are installed on the macos-13 image, including both the 16 and 17 ones. If I get time I can try a few experiments but you should be able to install and run with the iOS 16 SDK on Xcode 15.

samdeane avatar Mar 15 '24 10:03 samdeane

Ok thanks for your help. I appreciate it. I try to get it working ;D

Gustl22 avatar Mar 15 '24 10:03 Gustl22

If I get some time, I will experiment and let you know what I come up with.

samdeane avatar Mar 15 '24 11:03 samdeane

I finally got ios 16 working, by switching with sudo xcode-select -switch /Applications/Xcode_14.3.1.app/Contents/Developer.

Gustl22 avatar Mar 15 '24 11:03 Gustl22

This should be covered in #1763, the tests are tried to be fixed in #1769, I appreciate any help though.

Gustl22 avatar Aug 11 '24 13:08 Gustl22