at last i solved it..
for whom suffers from same problem on maui or maui blazor app
create a folder on root of your project , name it Frameworks
put xcframework folders directly to here (ex: bass.xcframework)
then open cspoj file and add these:
<Target Name="CopyBassFrameworks" BeforeTargets="PrepareForBuild" Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
<!-- Diagnostic message -->
<Message Text="Starting CopyBassFrameworks target." Importance="high" />
<Message Text="Copying for iOS Device..." Importance="high" Condition="'$(RuntimeIdentifier)' != 'iossimulator-x64'" />
<Message Text="Copying for iOS Simulator..." Importance="high" Condition="'$(RuntimeIdentifier)' == 'iossimulator-x64'" />
<ItemGroup Condition="'$(RuntimeIdentifier)' != 'iossimulator-x64'">
<!-- bass framework -->
<BassFramework Include="$(MSBuildThisFileDirectory)Frameworks\bass.xcframework\ios-arm64_armv7_armv7s\bass.framework\**" />
<!-- bassmix framework -->
<BassMixFramework Include="$(MSBuildThisFileDirectory)Frameworks\bassmix.xcframework\ios-arm64_armv7_armv7s\bassmix.framework\**" />
<!-- bassenc framework -->
<BassEncFramework Include="$(MSBuildThisFileDirectory)Frameworks\bassenc.xcframework\ios-arm64_armv7_armv7s\bassenc.framework\**" />
<!-- bassenc_mp3 framework -->
<BassEncMp3Framework Include="$(MSBuildThisFileDirectory)Frameworks\bassenc_mp3.xcframework\ios-arm64_armv7_armv7s\bassenc_mp3.framework\**" />
</ItemGroup>
<!-- For the simulator -->
<ItemGroup Condition="'$(RuntimeIdentifier)' == 'iossimulator-x64'">
<!-- bass framework -->
<BassFramework Include="$(MSBuildThisFileDirectory)Frameworks\bass.xcframework\ios-arm64_i386_x86_64-simulator\bass.framework\**" />
<!-- bassmix framework -->
<BassMixFramework Include="$(MSBuildThisFileDirectory)Frameworks\bassmix.xcframework\ios-arm64_i386_x86_64-simulator\bassmix.framework\**" />
<!-- bassenc framework -->
<BassEncFramework Include="$(MSBuildThisFileDirectory)Frameworks\bassenc.xcframework\ios-arm64_i386_x86_64-simulator\bassenc.framework\**" />
<!-- bassenc_mp3 framework -->
<BassEncMp3Framework Include="$(MSBuildThisFileDirectory)Frameworks\bassenc_mp3.xcframework\ios-arm64_i386_x86_64-simulator\bassenc_mp3.framework\**" />
</ItemGroup>
<!-- Diagnostic messages -->
<Message Text="Platform is: $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))" Importance="high" />
<Message Text="Platform2 is: $(RuntimeIdentifier)" Importance="high" />
<Message Text="ProjectDir is: $(ProjectDir)" Importance="high" />
<Message Text="Copying files from bass framework: @(BassFramework)" Importance="high" />
<Message Text="Copying files from bassmix framework: @(BassMixFramework)" Importance="high" />
<Message Text="Copying files from bassenc_mp3 framework: @(BassEncMp3Framework)" Importance="high" />
<Copy SourceFiles="@(BassFramework)" DestinationFolder="$(ProjectDir)bass.framework\%(RecursiveDir)" />
<Copy SourceFiles="@(BassMixFramework)" DestinationFolder="$(ProjectDir)bassmix.framework\%(RecursiveDir)" />
<Copy SourceFiles="@(BassEncFramework)" DestinationFolder="$(ProjectDir)bassenc.framework\%(RecursiveDir)" />
<Copy SourceFiles="@(BassEncMp3Framework)" DestinationFolder="$(ProjectDir)bassenc_mp3.framework\%(RecursiveDir)" />
<!-- Diagnostic message -->
<Message Text="Finished copying frameworks to: $(ProjectDir)" Importance="high" />
</Target>
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
<NativeReference Include="$(ProjectDir)\bass.framework">
<Kind>Framework</Kind>
<SmartLink>True</SmartLink>
<ForceLoad>True</ForceLoad>
</NativeReference>
<NativeReference Include="$(ProjectDir)\bassmix.framework">
<Kind>Framework</Kind>
<SmartLink>True</SmartLink>
<ForceLoad>True</ForceLoad>
</NativeReference>
<NativeReference Include="$(ProjectDir)\bassenc.framework">
<Kind>Framework</Kind>
<SmartLink>True</SmartLink>
<ForceLoad>True</ForceLoad>
</NativeReference>
<NativeReference Include="$(ProjectDir)\bassenc_mp3.framework">
<Kind>Framework</Kind>
<SmartLink>True</SmartLink>
<ForceLoad>True</ForceLoad>
</NativeReference>
</ItemGroup>
add other plugins as you need..
then use
public static class BassHelper
{
public static nint ImportResolver(string libraryName, Assembly assembly, DllImportSearchPath? searchPath)
{
nint libHandle = 0;
if (libraryName.StartsWith("bass"))
{
#if WINDOWS
NativeLibrary.TryLoad($"{libraryName}.dll", out libHandle);
#elif __ANDROID__
NativeLibrary.TryLoad($"{libraryName}.so", assembly, DllImportSearchPath.ApplicationDirectory, out libHandle);
#elif __IOS__
NativeLibrary.TryLoad($"./Frameworks/{libraryName}.framework/{libraryName}", assembly, DllImportSearchPath.ApplicationDirectory, out libHandle);
#else
CrossPlatform.Assert(false);
#endif
}
return libHandle;
}
}
and call like this
try
{
#if IOS
NativeLibrary.SetDllImportResolver(typeof(BassNet).Assembly,BassHelper.ImportResolver);
#endif
var init = Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
var mixer = BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_DEFAULT);
var en1 = BassEnc.BASS_Encode_GetVersion();
var en2 = BassEnc_Mp3.BASS_Encode_MP3_GetVersion();
}
catch (Exception ex)
{
}
note for @ian and @radio42
without adding bassenc.xcframework , bassenc_mp3.framework not works
is this normal?