question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

Description

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

  1. Create a new Maui Blazor app
  2. add platform capabilities in DI container
		builder.Services.AddSingleton<IConnectivity>(Connectivity.Current);
		builder.Services.AddSingleton<IGeolocation>(Geolocation.Default);
		builder.Services.AddSingleton<IMediaPicker>(MediaPicker.Default);
  1. Added 3 buttons for each of the services
  2. 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;
                    }
                }
  1. 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>
  1. 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 !

  2. 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>
  1. Used transporter/testflight to publish
  2. 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:closed
  • Created a year ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
arthastheking113commented, Dec 8, 2022

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

<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
		<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
		<MtouchUseLlvm>False</MtouchUseLlvm>
		<!-- Only needed when you have a need for entitlements -->
		<!-- <CodesignEntitlement>Entitlements.plist</CodesignEntitlement> -->
		<CodesignKey>Apple Distribution: {My Name} ({My Code})</CodesignKey>
		<CodesignProvision>{My App Code}</CodesignProvision>
		<ServerAddress>{My Server Address}</ServerAddress>
		<ServerUser>{My Server User}</ServerUser>
		<ServerPassword>{My Server Password}</ServerPassword>
		<TcpPort>58181</TcpPort>
		<ArchiveOnBuild>true</ArchiveOnBuild>
		<BuildIpa>true</BuildIpa>
    <_DotNetRootRemoteDirectory>/Users/{My Server User}/Library/Caches/Xamarin/XMA/SDKs/dotnet/</_DotNetRootRemoteDirectory>
    
</PropertyGroup>

My publish command: sudo dotnet publish -c:Release -f:net6.0-ios

I sent my .ipa file to Apple using Transporter.

0reactions
christallirecommented, Dec 30, 2022

I created https://github.com/dotnet/maui/issues/12353 for your convenience

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix exception using FlyoutBackgroundImage on iOS (#7879)
Maui Blazor for iOS works on macbook from command line but fails to start when installed on Iphone using TestFlight. Using IConnectivity, IGeolocation...
Read more >
TestFlight for Mac shows "Not Available for Testing"
Hi team, recently after apple made TestFlight available for Mac. We want to test our mac App using testFlight for Mac. So we...
Read more >
.NET MAUI unable to debug iOS on simulator or phone - ...
I'm new to .NET MAUI and I'm experimenting with a MAUI Blazor App. However, I'm having no luck getting it to debug on...
Read more >
While launching MAUI App, it is crashing on iPhone ...
ios - While launching MAUI App, it is crashing on iPhone (device and Emulator) - Stack Overflow.
Read more >
Debugging iOS app running on MacOS via Test Flight
I have developed an iOS application which works well when run from Test Flight on my iOS device. ... I cannot locate any...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found