{"id":15873815,"url":"https://github.com/phronmophobic/grease","last_synced_at":"2025-08-22T01:12:54.971Z","repository":{"id":42384959,"uuid":"477161182","full_name":"phronmophobic/grease","owner":"phronmophobic","description":"An example of building a clojure library for iOS with graalvm native-image.","archived":false,"fork":false,"pushed_at":"2025-03-16T19:02:51.000Z","size":64548,"stargazers_count":83,"open_issues_count":1,"forks_count":5,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-02T05:07:22.725Z","etag":null,"topics":["clojure","graalvm","graalvm-native-image","ios","membrane"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phronmophobic.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-02T20:13:11.000Z","updated_at":"2025-03-16T19:02:54.000Z","dependencies_parsed_at":"2024-11-17T10:02:53.987Z","dependency_job_id":"27cff7a6-211d-4379-9704-c479587835f7","html_url":"https://github.com/phronmophobic/grease","commit_stats":{"total_commits":251,"total_committers":2,"mean_commits":125.5,"dds":0.003984063745019917,"last_synced_commit":"5df3eadbeee3ec0451ab0b76d4f7cf0ded39f082"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phronmophobic%2Fgrease","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phronmophobic%2Fgrease/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phronmophobic%2Fgrease/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phronmophobic%2Fgrease/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phronmophobic","download_url":"https://codeload.github.com/phronmophobic/grease/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247994122,"owners_count":21030050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","graalvm","graalvm-native-image","ios","membrane"],"created_at":"2024-10-06T01:07:02.149Z","updated_at":"2025-04-09T07:10:11.843Z","avatar_url":"https://github.com/phronmophobic.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Grease\n\nAn example of building a clojure library for iOS with graalvm native-image.\n\nBuilt with [membrane](https://github.com/phronmophobic/membrane).\n\n# Update - Nov 2024\n\nGrease is in active development and the docs are a bit out of date. For the latest info, check the [#graalvm-mobile](https://clojurians.slack.com/archives/C0260KHN0Q0) channel on the Clojurians Slack (join [here](http://clojurians.net/)).\n\n## Game of Life Example\n\nSee `examples/gol`\n\n![game-of-life](/game-of-life.gif?raw=true)\n\n## Media\n\nWatch the project in action on the [Apropos Clojure Podcast](https://apropos-site.vercel.app/episode/54).  \n[Show Notes](https://gist.github.com/ericnormand/aefbaace9b3731b26dd4dff770565271)\n\n## Prerequisites\n\n1. Download java's arm64 static libraries built for ios. They can be downloaded using `download-deps`\n\n```sh\n$ scripts/download-deps\n```\n\n2. Setup graalvm and make sure your clojure project is graalvm compatible. https://github.com/BrunoBonacci/graalvm-clojure. These examples were tested using https://github.com/gluonhq/graal/releases/tag/gluon-22.1.0.1-Final. Other versions may or may not work.\n\nMake sure `GRAALVM_HOME` is set and is on your path before starting.\n\n```\nexportJAVA_HOME=\u003cpath-to-graalvm\u003e/Contents/Home\nexport GRAALVM_HOME=\"$JAVA_HOME\"\nexport PATH=$JAVA_HOME/bin:$PATH\n```\n\n## Usage\n\n0. [prerequisites](#prerequisites)\n1. Compile your clojure project\n\n```sh\n\n$ ./scripts/compile-shared\n\n```\nThis can take a while. \n\n2. Open the xcode project in xcode/MobileTest/MobileTest.xcodeproj  \n3. Select \"Any iOS Device(arm64)\" or your connected device as the build target. (iOS Simulator not supported yet)\n4. Build and run\n\n\n\n## Membrane Example\n\nAn example project that uses [membrane](https://github.com/phronmophobic/membrane) for UI can be found under xcode/TestSkia/TestSkia.xcodeproj. It also starts a sci repl that can be used for interactive development. Simply connect to the repl and start hacking! To update the UI, just `reset!` the main view atom. Example scripts below.\n\n### Usage\n\n0. [prerequisites](#prerequisites)\n1. Compile `./scripts/compile-membrane`\n2. Open xcode/TestSkia/TestSkia.xcodeproj\n3. Build and run\n4. The console will print the IP addresses available. Connect to repl on your device using the IP address and port 23456.\n5. Hack away!\n\n### Example scripts\n\nHello World!\n\n```clojure\n(require '[membrane.ui :as ui])\n(require '[com.phronemophobic.grease.membrane :refer\n           [main-view]])\n\n(def red [1 0 0])\n\n(reset! main-view\n        (ui/translate 50 100\n                      (ui/with-color red\n                        (ui/label \"Hello World!\"\n                                  (ui/font nil 42)))))\n```\n\nSimple Counter\n\n```clojure\n(require '[membrane.ui :as ui])\n(require '[com.phronemophobic.grease.membrane :refer\n           [main-view]])\n\n\n(def my-count (atom 0))\n\n(defn counter-view []\n  (ui/translate 50 100\n                (ui/on\n                 :mouse-down\n                 (fn [pos]\n                   (swap! my-count inc)\n                   nil)\n                 (ui/label (str \"the count \"\n                                @my-count)\n                           (ui/font nil 42)))))\n\n\n(add-watch my-count ::update-view (fn [k ref old updated]\n                                    (reset! main-view (counter-view))))\n\n(reset! my-count 0)\n```\n\nBasic Drawing\n\n```clojure\n\n(require '[membrane.ui :as ui])\n(require '[com.phronemophobic.grease.membrane :refer\n           [main-view]])\n\n\n(def pixels (atom []))\n\n(defn view []\n  (ui/on\n   :mouse-down\n   (fn [pos]\n     (swap! pixels conj pos))\n   [(ui/rectangle 600 800)\n    (into []\n          (map (fn [[x y]]\n                 (ui/translate x y\n                               (ui/with-color [0 0 1 1]\n                                 (ui/rectangle 10 10)))))\n          @pixels\n     )])\n  )\n\n(add-watch pixels ::update-view (fn [k ref old updated]\n                                  (reset! main-view (view))))\n\n(reset! pixels [])\n```\n\n### Example projects\n\nFound in `examples/` directory.\n\n[examples/ants](examples/ants) - Classic ant sim  \n[examples/gol](examples/gol) - Game of Life  \n[examples/objc](examples/objc) - Objective-c interop  \n[t3tr0s-bare](https://github.com/phronmophobic/t3tr0s-bare) - Tetris  \n[snake](https://github.com/phronmophobic/programming-clojure) - Snake  \n\n\n\n\n## Notes\n\nThe key ingredients for creating binaries for iOS using native-image are:\n- static jdk libraries build for iOS\n- static native image libraries built for ios (see ./lib/ios-arm64)\n- various configs (see ./conf/).\n\nIn addition to gluon, there have also been some other forks that have tried to make building the static jdk and native libs easier. See https://graalvm.slack.com/archives/CN9KSFB40/p1714544531823089 on the graalvm slack.\n\n\n## License\n\nCopyright © 2024 Adrian\n\nDistributed under the GPLv2 License. See LICENSE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphronmophobic%2Fgrease","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphronmophobic%2Fgrease","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphronmophobic%2Fgrease/lists"}