Local development of Flaneur.Launching with example projects use a file reference instead of a package reference. You need to manually build a debug configuration of the Flaneur.Launching.MSBuild project before testing your changes with samples so the required assemblies are available.
-
Make the Flanuer URL variable work out-of-the-box.
Create a new source code-only project, Flaneur.Launching, that makes the Flaneur URL variable available at build time via an environment variable. (See also whatever
fable.core\4.0.0\contentFiles\any\netstandard2.0\RELEASE_NOTES.md
is doing to add itself, maybe it doesn't need to be a new project.) -
Rebuild the host project if a file in
FlaneurWorkingDirectory
has changed.This might also be achieved by replacing the
FlaneurWorkingDirectory
with a Flaneur-tagged project reference (or a FlaneurReference?) so we can still find the right working directory and the default up-to-date-check of Visual Studio works. -
Detect if the HTTP url (
FlaneurHttpUrlCommand
,FlaneurHttpUrl
) is active and if so, don't runFlaneurHttpCommand
.
You can configure how the host launches your wapp at build time by setting a Flaneur URL variable and using the FSharp.Data.LiteralProviders package.
AppDelegate.fs
type private LaunchUrl = Env<"FLANEUR_URL", "bundle://main">
[<Register(nameof AppDelegate)>]
type AppDelegate() =
inherit UIApplicationDelegate()
override val Window = null with get, set
override this.FinishedLaunching(application: UIApplication, launchOptions: NSDictionary) =
this.Window <- new UIWindow(UIScreen.MainScreen.Bounds)
this.Window.RootViewController <- new WebAppViewController (new NSUrl(LaunchUrl.Value), handler)
this.Window.MakeKeyAndVisible()
true
For example, you can use a hot reload server while you're developing but use optimized bundled assets for a production release.
CLI
# TODO: start your wapp hot reload server, then
export FLANEUR_URL=http://localhost:8080
dotnet build -t:Run -f net7.0-ios -p:_DeviceName=:v2:udid=MY_SPECIFIC_UDID
package.json
{
"private": true,
"scripts": {
"build:wapp": "echo build your wapp",
"build:host": "dotnet publish -f net7.0-ios -r ios-arm64 -c Release",
"build": "npm-run-all build:wapp build:host",
"start:wapp": "echo start your wapp hot reload server"
"start:host": "cross-env FLANEUR_URL=http://localhost:8080 dotnet build -t:Run -f net7.0-ios -p:_DeviceName=:v2:udid=MY_SPECIFIC_UDID",
"start": "npm-run-all --parallel start:*"
},
"devDependencies": {
"cross-env": "7.0.3",
"npm-run-all": "4.1.5"
}
}
If you have the Flaneur.Launching.MSBuild
package installed, you can set the FLANEUR_URL
environment variable using the MSBuild property FlaneurUrl
.
CLI
dotnet build -t:Run -f net7.0-ios -p:_DeviceName=:v2:udid=MY_SPECIFIC_UDID` -p:FlaneurUrl=http://localhost:8080
You can also specify the behaviours for how Flaneur launches with HTTP and bundle so your wapp is built or started when you build or run the host in Visual Studio or via the dotnet CLI.
You can control whether your wapp is launched via HTTP or bundle with the property FlaneurMode
. If you don't specify a mode, it'll use HTTP if you're running a Visual Studio 'Start Debugging (F5)' build, or otherwise use bundle.
fsproj and package.json
<PropertyGroup>
<FlaneurWorkingDirectory>../Flaneur.Examples.iOS.App</FlaneurWorkingDirectory>
<FlaneurHttpRunCommand>npm run start</FlaneurHttpRunCommand>
<FlaneurHttpPrintUrlCommand>npm run -s print:start-url</FlaneurHttpPrintUrlCommand>
<FlaneurBundleBuildCommand>npm run build</FlaneurBundleBuildCommand>
<FlaneurBundlePrintFilesCommand>npm run -s print:build-assets</FlaneurBundlePrintFilesCommand>
<FlaneurMode>Bundle</FlaneurMode>
</PropertyGroup>
{
"private": true,
"scripts": {
"print:start-url": "node --print \"require('running-at')(5173).network\"",
"print:build-assets": "glob --nodir \"dist/**/*\"",
"install": "dotnet tool restore",
"build": "dotnet fable . -o bin/wwwroot --run vite build --outDir dist --emptyOutDir",
"start": "dotnet fable watch . -s -o bin/wwwroot --run vite dev --host 0.0.0.0 --port 5173 --strictPort"
},
"devDependencies": {
"glob": "10.3.3",
"running-at": "0.3.22",
"vite": "4.4.2"
}
}
MSBuild Properties
Property Name | Description | Allowed Values |
---|---|---|
FlaneurMode | The mode Flaneur Launching should use. | 'HTTP' or 'Bundle'. |
FlaneurWorkingDirectory | The working directory to which all commands and files are relative. | Directory path. |
FlaneurRestoreCommand | A command that restores packages for a wapp. | Command line expression. |
FlaneurBundleBuildCommand | A command that produces a wapp to be bundled. | Command line expression. |
FlaneurBundlePrintFilesCommand | A command that prints a list of files to be bundled | Command line expression that prints file paths separated by new lines. |
FlaneurBundleDirectory | A path to a directory to bundle. All subpaths will be bundled. | Directory path. |
FlaneurBundleFiles | Paths to files to bundle. | File paths separated by semicolons. |
FlaneurBundlePrintUrlCommand | A command that prints the URL to launch on startup if in Bundle mode. | Command line expression that prints a URL. |
FlaneurHttpUrl | The URL to launch on startup if in Bundle mode. | URL. |
FlaneurHttpRunCommand | A command that serves a wapp over HTTP. | Command line expression |
FlaneurHttpPrintUrlCommand | A command that prints the URL to launch on startup if in HTTP mode. | Command line expression that prints a URL. |
FlaneurHttpUrl | The URL to launch on startup if in HTTP mode. | URL. |
⚠️ Currently unused.
Code generation for Flaneur.
-
Reintegrate generators in example projects
-
Add generator to
Flanuer.Examples.iOS.App.fsproj
.<Compile Include="Services.g.fs" FlaneurRemotingSourceFile="Services.fs" FlaneurRemotingGenerators="FlaneurRemotingProxyGenerator" />
-
Add generator to
Flaneur.Examples.iOS.Host.fsproj
.<Compile Include="Services.g.fs" FlaneurRemotingSourceFile="../Flaneur.Examples.iOS.App/Services.fs" FlaneurRemotingGenerators="FlaneurRemotingHandlerGenerator" />
-
Uncomment
Flaneur.Remoting
references inDirectory.Build.props
. -
Add a project reference from
Flanuer.Examples.iOS.Host.fsproj
toFlanuer.Examples.iOS.App.fsproj
. -
Attempt a release build for iOS.
Last time we had it integrated, the trimmer was trying to analyse Myriad and failing. If it does the same this time, investigate how to exclude the references from the build output.
-
For NuGet packages it can be controlled with metadata.
-
However, our example project uses project references.
Publish: PrivateAssets=All not honored on ProjectReference items
-
-
-
Implement all the things. (Proxy generator, handler generator, etc.)
-
Consider some values which could be opaque to the wapp. For example, a host might return a record which needs to be sent to a different endpoint. The wapp doesn't need to decode it, so the type doesn't need to be turned into a contract, but it does need to be able to pass it along. This could be marked in the interface by an single case DU,
type SomeRecord = SomeRecord
.Code generation will need to have a facility for the wapp to and the host to avoid automatically decoding of this DU (because it won't actually be this DU, it will be the record) and (1) for the wapp, just pass around the opaque record and (2) for the host, explicilty decode it into the known record.
-
-
Allow for other ways of remoting. For example, developers could use Elmish Bridge instead of Flaneur.Remoting.