Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some smallish fixes to the README #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,42 @@ Builds an obelisk frontend as a static library for use in an iOS project. Check

## Adding the dependency

```sh
mkdir dep
cd dep
nix-thunk create https://github.com/obsidiansystems/obelisk-ios-libfrontend.git
```

Add this package to the [overrides](https://github.com/obsidiansystems/obelisk/#adding-package-overrides) in your obelisk project's default.nix:

```
obelisk-ios-libfrontend = haskellLib.dontStrip (self.callCabal2nix "obelisk-ios-libfrontend" (hackGet ./dep/obelisk-ios-libfrontend + "/exe") {});
obelisk-ios-libfrontendconfig = self.callCabal2nix "obelisk-ios-libfrontendconfig" (hackGet ./dep/obelisk-ios-libfrontend + "/lib") {};
```nix
project ./. ({ pkgs, hackGet, ... }: {

...

overrides = self: super: {
obelisk-ios-libfrontend = pkgs.haskell.lib.dontStrip (self.callCabal2nix "obelisk-ios-libfrontend" (hackGet ./dep/obelisk-ios-libfrontend + "/exe") {});
obelisk-ios-libfrontendconfig = self.callCabal2nix "obelisk-ios-libfrontendconfig" (hackGet ./dep/obelisk-ios-libfrontend + "/lib") {};
};
```

Make sure to include `dontStrip`.

## Adding iOS config to your frontend code

Add `obelisk-ios-libfrontendconfig` to your frontend's `library`'s `build-depends` in `frontend/frontend.cabal`.

In your `frontend/Frontend.hs`, you'll need to add something like this:

```haskell
...
import Obelisk.Frontend.iOS
import Obelisk.Frontend.IOS

...
myHtmlHead = do
el "title" $ text "Obelisk Minimal Example"
elAttr "script" ("type" =: "application/javascript" <> "src" =: $(static "lib.js")) blank
elAttr "link" ("href" =: $(static "main.css") <> "type" =: "text/css" <> "rel" =: "stylesheet") blank

iosConfig :: IO (IosConfig (R FrontendRoute))
iosConfig = do
Expand Down