xamarin-macios
xamarin-macios copied to clipboard
Can't start ShazamKit
Hi, I'm trying to implement ShazamKit in a MAUI app, by the way I'm always getting an exception when I try to instantiate a SHSession. I'm using the simulator because at the moment I don't have any physical iPhone to test, by the way a tried a native ShazamKit demo project found on Github on the simulator and it works fine.
Steps to Reproduce
- Create a basic MAUI app
- Try to instantiate a native SHSession of the iOS platform
Expected Behavior
Instantiate a SHSession
Actual Behavior
Can't instantiate a SHSession. This is the exception I'm getting:
Could not create an native instance of the type 'ShazamKit.SHSession': the native class hasn't been loaded. It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false. at Foundation.NSObject.InitializeObject(Boolean alloced) at Foundation.NSObject..ctor(NSObjectFlag x) at ShazamKit.SHSession..ctor() at Compilero.Mobile.Platforms.iOS.Services.IOsShazamKitService..ctor()
Environment
Version information
``` Xamarin iOS & Mac 15.10.0.1 iOS version 15.0 ```Build Logs
Example Project (If Possible)
Initial testing confirms this. I tried setting code signing on my maui project to match an xcode project that works on sim, but so far I'm seeing a difference. Will need to look into it more.
It doesn't look like ShazamKit is working in the simulator:
- https://developer.apple.com/forums/thread/683811
- https://www.raywenderlich.com/26236685-shazamkit-tutorial-for-ios-getting-started ("As of the time of writing, the Simulator doesn’t support ShazamKit.")
That said, Apple might have fixed their simulator support after that was posted.
Could you link us to the ShazamKit project on GitHub you used in the simulator?
Hi @vadd98. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
Sure, I used this one https://github.com/heysaik/ShazamKit-Demo
I'm aware of that issue, indeed I can't get any Match in the simulator, by the way the whole system works and returns a NoMatch result, while using Xamarin I can't even create the session.
Yes, we won't link with ShazamKit because we think it's only available on device:
https://github.com/xamarin/xamarin-macios/blob/d869a6868a0a1fb33a1bbec34a5b1542c227b9b8/tools/common/Frameworks.cs#L445
You can probably work around it by adding this to your csproj:
<PropertyGroup>
<MtouchExtraArgs>-gcc_flags="-framework ShazamKit"</MtouchExtraArgs>
</PropertyGroup>
I tried your suggestion and indeed now works in the simulator! Obviously it does not get any match, by the way I can test the implementation