Short answer:
It is easier to get .Net iOS Splash Screen (LaunchScreen) to work on an actual device, rather than on Simulator.
REASON: Simulator won't show Splash Screen for an unsigned app; e.g. a Debug build.
I discovered this via .Net Maui / iOS not show splash screen:
... as of iOS ~16.4 you will NOT be able to see your splash screen on an IOS simulator
(...BUT keep reading, there is a solution below for Simulator...)
Although I am not developing a Maui app, I am using .Net 8 for iOS, which has similar issue.
UPDATE A later section of this answer shows what to add to .csproj, to enable code-signing, so can see Splash Screen in simulator with a Debug build.
Long answer:
These steps worked:
Create LaunchScreen.storyboard in Xcode on mac in a simple native (Objective C or Swift) project. If using Swift, be sure to specify that LaunchScreen is via "Storyboard".
Use Xcode to modify LaunchScreen as desired. As a first simple test, add a View and set its Background Color (no Image yet).
Verify this native app shows LaunchScreen.
Copy LaunchScreen.storyboard into C# ".Net for iOS" project's Resources folder.
Add to info.plist:
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
- Deploy Debug build to an ios device attached to the mac. [Testing Debug build on Simulator didn't show the LaunchScreen.]
Result: The LaunchScreen color appears, then app's Main screen appears.
For Step (6.) above, Splash Screen can be tested on Simulator by adding code-signing to .csproj file:
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<EnableCodeSigning>true</EnableCodeSigning>
<CodesignRequireProvisioningProfile>true</CodesignRequireProvisioningProfile>
<DisableCodesignVerification>true</DisableCodesignVerification>
</PropertyGroup>
[It might be necessary to restart Simulator on mac, to see this change.]
Credit: Based on a comment in
dotnet / macios / Enable codesigning by default in the simulator.
NOTE: I tested in an iOS-only project. If targetting multiple platforms, change first line to:
<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) And '$(Configuration)' == 'Debug'">
Troubleshooting:
Make a change, but previous version of Launch Screen is still seen.
Launch Screen apparently is cached on device.
restart (power off, then back on) the device or (quit) Simulator.
If still not seeing the change, quit Visual Studio, delete bin and obj folders. After this, restart device/Simulator again.
I've had situations where change still was not seen. Perhaps some cache on mac not updated. Quit Xcode if it is running.
Delete app from device/Simulator.
If all else fails: Power off pc and mac. Repeat the above steps, before running Visual Studio again. Perhaps edit LaunchScreen.Storyboard again in an external text editor, so it has a new modified date.
Add an image, but it is not seen.
FIRST get it working in a native (Swift or Objective C) app in Xcode. Then copy needed files to C# project. NOTE: Image can either be a single .png or an asset catalog (containing a content.json and one or more versions of image).
Place relevant files (LaunchScreen.Storyboard, yourimagename.png) in C# project's folder "Resources".
Asset catalog(s) go in project folder "Assets.xcassets". This seems to work whether inside "Resources", or as its own folder in project root.
No build actions needed on the files: these files are sent to Xcode, which processes appropriately.
Launch Screen not appearing on Simulator.
Test it on a physical device. If it works there, double-check the code-sign properties described above.
If using ".Net for iOS" (but NOT Maui), the place to report bugs is:
https://github.com/dotnet/macios/issues
(Consider first posting a StackOverflow question, in case it isn't actually a bug.)
If you are using .Net Maui, and encounter issues on iOS, report bugs here:
https://github.com/dotnet/maui/issues
Contents of LaunchScreen.storyboard:
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="iosLaunchImage.png" translatesAutoresizingMaskIntoConstraints="NO" id="KEL-HK-vdv">
<rect key="frame" x="16" y="59" width="361" height="759"/>
</imageView>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" red="0.0" green ="0.0" blue="1.0" alpha="1" colorSpace="custom" customColorSpace="sRGB" />
<constraints>
<constraint firstItem="KEL-HK-vdv" firstAttribute="bottom" secondItem="6Tk-OE-BBY" secondAttribute="bottom" id="BvB-83-3Ty"/>
<constraint firstItem="KEL-HK-vdv" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leadingMargin" id="F7Y-zg-6OF"/>
<constraint firstItem="KEL-HK-vdv" firstAttribute="trailing" secondItem="Ze5-6b-2t3" secondAttribute="trailingMargin" id="NfD-Qh-mDE"/>
<constraint firstItem="KEL-HK-vdv" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" id="kVK-62-x1g"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="52.671755725190835" y="374.64788732394368"/>
</scene>
</scenes>
<resources>
<image name="iosLaunchImage.png" width="722" height="409.69015502929688"/>
</resources>
</document>
Adapting to different device sizes:
imageView .. contentMode="scaleAspectFit"
autoresizingMask .. Yes
constraints for the 4 edges of view. There must NOT be constraints that set Width/Height to constant values.
color key="backgroundColor" ... blue="1.0" set background color to blue, so I could tell the storyboard was being used, even before I added an image. Useful in case image is somehow not being found.