Maui Blazor for iOS works on macbook from command line but fails to start when installed on Iphone using TestFlight. Using IConnectivity, IGeolocation, IMediaPicker
See original GitHub issueDescription
I have added 3 pages to the default Maui Blazor template app (files attached). Build IDE: Visual Studio Professional 2022 for Mac Preview Version 17.3 Preview (17.3 build 198)
Build Host: Macbook Air (M1)
When I run from vs2022 in debug mode all works, however in release mode nothing happens.
Steps to Reproduce
- Create a new Maui Blazor app
- add platform capabilities in DI container
builder.Services.AddSingleton<IConnectivity>(Connectivity.Current);
builder.Services.AddSingleton<IGeolocation>(Geolocation.Default);
builder.Services.AddSingleton<IMediaPicker>(MediaPicker.Default);
- Added 3 buttons for each of the services
- Added code to access these services that are called from the button callbacks:
public bool IsThereConnectivity()
{
if (connectivity.NetworkAccess != NetworkAccess.Internet)
{
return false;
}
else
{
return true;
}
}
Location location;
await CheckAndRequestLocationPermission();
location = await geolocation.GetLastKnownLocationAsync();
if (location == null)
{
location = await geolocation.GetLocationAsync(
new GeolocationRequest
{
DesiredAccuracy = GeolocationAccuracy.Medium,
Timeout = TimeSpan.FromSeconds(30)
}
);
}
return location;
if (mediaPicker.IsCaptureSupported)
{
FileResult photo = await MediaPicker.Default.CapturePhotoAsync();
if (photo != null)
{
// save the file into local storage
string localFilePath = Path.Combine(FileSystem.CacheDirectory, photo.FileName);
using Stream sourceStream = await photo.OpenReadAsync();
using FileStream localFileStream = File.OpenWrite(localFilePath);
Result = localFilePath;
await sourceStream.CopyToAsync(localFileStream);
return Result;
}
}
- Updated info.plist:
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to location services</string>
<key>NSCameraUsageDescription</key>
<string>This app needs access to the camera to take photos.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app needs access to microphone for taking videos.</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>This app needs access to the photo gallery for picking photos and videos.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app needs access to photos gallery for picking photos and videos.</string>
-
Ran local release on my macboor air (M1)
dotnet build -t:Run -c:Release -f net6.0-maccatalyst MyMauiBlazorApp.csproj
ALL WORKS FINE IN THE APP ! -
Created archive for iOS
dotnet publish MyMauiBlazorApp.csproj -f:net6.0-ios -c:Release /p:ServerAddress=<my macbook ip address> p:ServerUser=<username> /p:TcpPort=58181 /p:ArchiveOnBuild=true /p:_DotNetRootRemoteDirectory=/Users/<username>/Library/Caches/Xamarin/XMA/SDKs/dotnet/ /p:EnableAssemblyILStripping=false /p:ServerPassword=<macbook user password>
- Used transporter/testflight to publish
- Installed the app on my iphone 12 pro max using TestFlight
==============. FAILS =========== 12. When I try to open the app, the app flashes the screen and then closes 13. If I undo all my changes and install the default Maui Blazor app all works fine.
Kindly advice.
Version with bug
7.0 Release Candidate 1 or older
Last version that worked well
Unknown/Other
Affected platforms
iOS, macOS
Affected platform versions
macOS 12.3.1 (21E258)
Did you find any workaround?
No
Relevant log output
No response
Issue Analytics
- State:
- Created a year ago
- Comments:11 (1 by maintainers)
Top GitHub Comments
I have the same issue.
Working fine is Android both in simulator and physical devices.
On iOS, work fine in simulator, got error in TestFlight.
Get rejected from Apple Review team since it could not pass the flash screen.
I could not reproduce the error in the simulator.
I wonder if this is because of I published the app using my m1 Mac.
My publish settings
My publish command:
sudo dotnet publish -c:Release -f:net6.0-ios
I sent my .ipa file to Apple using Transporter.
I created https://github.com/dotnet/maui/issues/12353 for your convenience