tauriを使ってXCodeでiPhoneをエミュレーションする

どうも、やっぱりRustが好きなナナオです。 前回、せっかくHackintosh化に成功したので、XCodeでなんかエミュレートしたいんですよね。 Lenovo ThinkPad X270にHackintoshでSequoiaを入れた | にあえん ということで今回はtauriを使ってみようと思います。 プロジェクトの作成 tauriのプロジェクトの作成は公式ドキュメントに従ってやっていきましょう。 Create a Project | Tauri とりあえずプロジェクト作成に必要なツールをダウンロードしていきましょう。 cargo install create-tauri-app --locked tauri cliというのもインストールしておきましょう。 Command Line Interface | Tauri cargo install tauri-cli --version "^2.0.0" --locked これで準備ができました。 プロジェクトを作成していきます。 cargo create-tauri-app 出来上がったsrc-tauriディレクトリ内で以下のコマンドを実行します。 cargo tauri dev とりあえずデスクトップアプリの起動には成功しました! iPhoneでエミュレートしてみる iOSで起動するには、同ディレクトリ内で以下のコマンドを実行する必要があります。 cargo tauri ios init しかし残念ながらエラーが出てしまいました。。 Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`). Info package `cocoapods` present: false Installing `cocoapods`... Error: Cask 'cocoapods' is not installed. `sudo` is required to install cocoapods using gem Error failed to install Apple dependencies: Failed to install `cocoapods`: No such file or directory (os error 2): No such file or directory (os error 2) cocoapodsというツールがインストールされていなかったようです。 ...

2024年12月22日 · にあえん

Lenovo ThinkPad X270にHackintoshでSequoiaを入れた

どうも、ナナオです。 最近は色々あってブログ更新ができていなかったんですが、それでもなんかPCは触っていたいな〜ってことで、ジャンクPCを漁ってHackintoshを入れてました。 ということで今回はその備忘録です。 準備(別にHackintoshとは関係ない) タイトルにもありますが、今回購入したジャンクPCはこちらです。 X270ちゃん! Lenovo ThinkPad X270です。 最初に買ってずっと使っていたジャンクPCがThinkPad X201で結構思い出深いところもあるんですが、やっぱりThinkPadはいじりやすいんですよね。 あとこれにした理由としては、メモリがDDR4に対応し始めたのがXシリーズだとこのモデルからというのもあります。 ということで、まず購入した最初の状態だとメモリが4GBだったので、32GBのものに変えました。(メーカー推奨じゃないので自己責任だよ!) ���i.com - SPD SDDR432S32G30 [SODIMM PC4-25600 32GB] ���i���r 次にHDDがついてないものを買ったので、適当な1TBのSSDを購入しました。 あと、キーボードが日本語配列だったのが気に入らなかったので英字配列のものに入れ替えました。 Amazon | Generic ラップトップ キーボード/US レイアウト ブラック ポイント英語/ 0C02291 に適用 x240 x240S x250 x260 x270 | Generic | パソコン用キーボード 通販 キーボードの変更方法は以下のブログを参考にしました。ありがとうございます! ThinkPad X270のキーボード交換をしてみた。 - 三日坊主の備忘録 ということで完成形はこちらです。 キーボード&メモリ換装後のX270 所々ひび割れてるのはジャンクあるあるですね。 キーもメモリも変えて気持ちよくなったところで、Hackintoshしていきましょう!! Sonomaを入れる インストールメディアの作り方などは検索すれば解説記事がいくらでも出てくると思うので、ここでは完成形のEFIを置いておきます。 GitHub - satodaiki/X270-Hackintosh-Sonoma BIOSの設定はこちらを参照しました。 GitHub - nicktimur/Lenovo-X270-Hackintosh-OpenCore-Sonoma BIOSの設定 こちらはIntelのM.2カードを利用していてもWi-Fiが普通に使えます! Sequoiaにアップグレード アップグレード作業はSonomaがインストールできた後に設定画面からしました。 ...

2024年12月17日 · にあえん

GoでgRPCをササッと実装してみる 1

こんにちは。ナナオです。 今回は触ろうと思って触ってなかったgRPCに入門してみようと思います。 gRPCとは? gRPCとは、GoogleがRPCを実現するために作った技術のことです。 詳細については以下のサイトがかなり細かく説明してくれています。 https://zenn.dev/hsaki/books/golang-grpc-starting gRPCサーバーを動かす まずはgRPCのリクエストとレスポンスを定義するためのprotoファイルを作成します。 適当なディレクトリを作成して、Goモジュールとして初期化しておきましょう。 mkdir go_grpc_playground && cd go_grpc_playground go mod init go_grpc_playground 次に、protoファイルを作成します。 (参考にしてるサイトをパクってるだけですが。。) // protoのバージョンの宣言 syntax = "proto3"; // protoファイルから自動生成させるGoのコードの置き先 option go_package = "pkg/grpc"; // packageの宣言 package myapp; // サービスの定義 service GreetingService { // サービスが持つメソッドの定義 rpc Hello (HelloRequest) returns (HelloResponse); } // 型の定義 message HelloRequest { string name = 1; } message HelloResponse { string message = 1; } 次にこのprotoファイルからgoファイルを作成するためのモジュールをインストールします。 brewがあれば以下のコマンドで一発インストールできます。 brew install protobuf インストールするとprotocというコマンドが使用可能になります。 続けて、必要なモジュールを依存関係に追加しておきます。 go get -u google.golang.org/grpc go get -u google.golang.org/grpc/cmd/protoc-gen-go-grpc さて、今のディレクトリはこうなっています。 ...

2024年11月17日 · にあえん

Rustで標準入力受け取りたいとき

こんにちは。ナナオです。 AtCoderでRustが使えるので使いたいなーと思ったんですが、標準入力どう受け取ればいいんだ?ってなったので備忘録。 Rustで標準入力受け取るコード こんな感じにしました。 use std::io::{self, Read}; fn main() { let input = read_stdin(); print!("{}", input); } /// 標準入力を受け取る関数 fn read_stdin() -> String { let mut buf = String::new(); io::stdin().read_to_string(&mut buf).expect("Failed to read stdin."); buf.to_string() } これで大抵の競プロは乗り切れるはず。。

2024年11月10日 · にあえん

C++の入門 conanに少し触れる

こんにちは。ナナオです。 最近AtCoderなどでコーディングをしているのですが、やはり主流な言語はC++のようで、大体のひとがC++を使っています。 ということで、僕も今更ながらC++に入門してみようと思います。 環境構築 とりあえずパッケージ管理に何を使おうか調べたところ、vcpkgとconanの2つが使えるということですが、クロスプラットフォームであることからconanにしようと思います。 C/C++用パッケージマネージャのconanを使ってみた #Conan - Qiita pipからインストールできるようですが、pyenvを使っている都合でpythonのバージョン切り替えをしたら使えないみたいなことがあると面倒くさいのでbrewからインストールします。 brew install conan インストールが完了すると、conanコマンドが使用可能になります。 ❯ conan --version Conan version 2.9.2 チュートリアルにしたがって、まずはconanでパッケージを作成してみます。 Create your first Conan package — conan 2.24.0 documentation 新しくディレクトリを作成して、そこでconanコマンドを実行します。 mkdir cpp_playground && cd cpp_playground conan new cmake_lib -d name=cpp_playground -d version=1.0 また、conan自体にプロファイルを設定してあげる必要があるようなので、それも合わせてしておきます。 Besides the conanfile.txt, we need a Conan profile to build our project. Conan profiles allow users to define a configuration set for things like the compiler, build configuration, architecture, shared or static libraries, etc. Conan, by default, will not try to detect a profile automatically, so we need to create one. To let Conan try to guess the profile, based on the current operating system and installed tools, please run: conanfile.txtの他に、プロジェクトをビルドするにはConanプロファイルが必要だ。 Conanプロファイルは、コンパイラ、ビルド・コンフィギュレーション、アーキテクチャ、共有ライブラリやスタティック・ライブラリなどのコンフィギュレーション・セットを定義することができる。 Conanはデフォルトではプロファイルを自動検出しようとしないので、プロファイルを作成する必要があります。 そのため、プロファイルを作成する必要があります。現在のオペレーティング・システムとインストールされているツールに基づいて、コナンにプロファイルを推測させるには、以下を実行してください: ...

2024年11月10日 · にあえん

hasuraに入門してみた

こんにちは。ナナオです。 今回はPostgresサーバーから、そのままGraphQLとして運用することが可能なHasuraをイジってみたいと思います。 準備 とりあえずディレクトリを作っておきます。 mkdir hasura_playground ちゃっと検証したいので、とりあえずスキーマは以前触ったsqldefを使います。 【以前の記事はこちら】 マイグレーションの基盤とするSQLファイルを作成します。 touch schema.sql テーブルはUserとそれに紐づくPostテーブルを作る感じにしましょう。 CREATE EXTENSION "uuid-ossp"; CREATE TABLE public.user ( id uuid NOT NULL DEFAULT uuid_generate_v4(), name varchar(255), age integer ); CREATE TABLE public.post ( id uuid NOT NULL DEFAULT uuid_generate_v4(), title varchar(255), content text, user_id uuid ); dockerでPostgresを起動するためのdocker-compose.yamlファイルも実装しておきます。 version: '3' services: db: image: postgres:15 container_name: postgres ports: - 5432:5432 environment: - POSTGRES_PASSWORD=example これを起動します。 docker compose up -d あとは以下のコマンドで先程のテーブル定義を適用すればよいです。 psqldef --password=example -h localhost -p 5432 -U postgres postgres < schema.sql あとは適当にデータを追加しておきましょう。 ...

2024年11月3日 · にあえん

maturinをワークスペースで運用してみる

どうも、ナナオです。 最近PythonからRustを呼び出す実装をすることがありまして、pyo3にお世話になることがありました。 pyo3のビルドにはmaturinというCLIを使うのですが、これをRustのワークスペース機能と併用できるのかどうか気になったので、検証してみたいと思います。 準備 とりあえず適当にpyo3を使用したライブラリを作ります。 ryeを使っていれば以下のコマンドでmaturinをビルダーに指定したプロジェクトを作成できます。 rye init maturin-workspace-playground --build-system maturin maturinをインストールしていなかったので、以下のコマンドでインストールしておきます。 rye install maturin 作ったプロジェクトに移動して、ワークスペースのメンバーになるプロジェクトを作成しておきます。 cd maturin-workspace-playground mkdir rust && cd rust cargo init --lib app cargo init --lib python-api 作成したプロジェクトをワークスペースのメンバーになるように設定をしていきます。 ルートディレクトリのCargo.tomlを以下のように編集します。 [workspace.package] name = "maturin-workspace-playground" version = "0.1.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [workspace] members = ["rust/python-api", "rust/app"] rust/appのCargo.tomlは以下のように編集します。 [package] name = "app" version.workspace = true edition.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] rust/python-apiのCargo.tomlは以下のように編集します。 ...

2024年8月26日 · にあえん

Gitに代わる新たなバージョン管理ツール「jujutsu」を使ってみる

お久しぶりです。ナナオです。 今回は今注目を集めているコードのバージョン管理ツール「jujutsu」を触ってみて、実際Gitと何が違うのか?を検証してみようと思います。 ちなみに、私は普段git-flowを使用したブランチ運用をしており、主に使用しているコマンドはこれくらいです。 init add branch commit checkout (swith) remote stash merge status インストール Windowsを使用している場合、cargoを使用してインストールします。 cargo install --locked --bin jj jj-cli --features vendored-openssl インストールできました。 > jj --help Failed to spawn pager 'LESSCHARSET=utf-8 less -FRX': program not found Jujutsu (An experimental VCS) To get started, see the tutorial at https://github.com/martinvonz/jj/blob/main/docs/tutorial.md. Usage: jj.exe [OPTIONS] [COMMAND] Commands: abandon Abandon a revision backout Apply the reverse of a revision on top of another revision branch Manage branches cat Print contents of a file in a revision checkout Create a new, empty change and edit it in the working copy [aliases: co] chmod Sets or removes the executable bit for paths in the repo commit Update the description and create a new change on top [aliases: ci] config Manage config options describe Update the change description or other metadata diff Show changes in a revision diffedit Touch up the content changes in a revision with a diff editor duplicate Create a new change with the same content as an existing one edit Edit a commit in the working copy files List files in a revision git Commands for working with the underlying Git repo init Create a new repo in the given directory interdiff Compare the changes of two commits log Show commit history merge Merge work from multiple branches move Move changes from one revision into another new Create a new, empty change and edit it in the working copy obslog Show how a change has evolved operation Commands for working with the operation log [aliases: op] rebase Move revisions to different parent(s) resolve Resolve a conflicted file with an external merge tool restore Restore paths from another revision show Show commit description and changes in a revision sparse Manage which paths from the working-copy commit are present in the working copy split Split a revision in two squash Move changes from a revision into its parent [aliases: amend] status Show high-level repo status [aliases: st] util Infrequently used commands such as for generating shell completions undo Undo an operation (shortcut for `jj op undo`) unsquash Move changes from a revision's parent into the revision [aliases: unamend] untrack Stop tracking specified paths in the working copy version Display version information workspace Commands for working with workspaces help Print this message or the help of the given subcommand(s) Options: -h, --help Print help (see a summary with '-h') -V, --version Print version Global Options: -R, --repository <REPOSITORY> Path to repository to operate on By default, Jujutsu searches for the closest .jj/ directory in an ancestor of the current working directory. --ignore-working-copy Don't snapshot the working copy, and don't update it By default, Jujutsu snapshots the working copy at the beginning of every command. The working copy is also updated at the end of the command, if the command modified the working-copy commit (`@`). If you want to avoid snapshotting the working and instead see a possibly stale working copy commit, you can use `--ignore-working-copy`. This may be useful e.g. in a command prompt, especially if you have another process that commits the working copy. Loading the repository is at a specific operation with `--at-operation` implies `--ignore-working-copy`. --at-operation <AT_OPERATION> Operation to load the repo at Operation to load the repo at. By default, Jujutsu loads the repo at the most recent operation. You can use `--at-op=<operation ID>` to see what the repo looked like at an earlier operation. For example `jj --at-op=<operation ID> st` will show you what `jj st` would have shown you when the given operation had just finished. Use `jj op log` to find the operation ID you want. Any unambiguous prefix of the operation ID is enough. When loading the repo at an earlier operation, the working copy will be ignored, as if `--ignore-working-copy` had been specified. It is possible to run mutating commands when loading the repo at an earlier operation. Doing that is equivalent to having run concurrent commands starting at the earlier operation. There's rarely a reason to do that, but it is possible. [default: @] [aliases: at-op] -v, --verbose Enable verbose logging --color <WHEN> When to colorize output (always, never, auto) --no-pager Disable the pager --config-toml <TOML> Additional configuration options jujutsuリポジトリの初期化 まずはリポジトリを作成してみましょう。 ...

2024年2月14日 · にあえん

haskellに入門してみる

いろんな言語が気になる時期。ナナオです。 今回はHaskellに入門してみようと思います。 (以前「すごいHaskell」は読んだことがあるのですが、読むだけでコード書いてなかったのでほぼ忘れてしまいました。。もったいない!!) Haskellのセットアップ まずはHaskellを使える環境を作っていきます。 Windows11の環境でやります。(WSLは使わないのでお気をつけて!) GHCupを使ってStackやGHCなどをまとめてインストールしちゃいましょう!! (僕は最初Stackだけインストールすればいいか~とやっていたら、VSCodeの拡張機能がGHCupを使う感じになっていたので詰みました) https://zenn.dev/mod_poppo/articles/haskell-setup-2023#ghc%E3%82%92%E4%BD%BF%E3%81%86 windowsの場合はかなり長いコマンドですが、以下でインストール可能です。 Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; try { Invoke-Command -ScriptBlock ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -ArgumentList $true } catch { Write-Error $_ } チュートリアルをやってみる とりあえずこのページのチュートリアルをやってみましょう。 10分で学ぶHaskell - HaskellWiki ghciは以下のように起動します。 stack ghci ghciでは:tと打つことで、変数や関数の型について知ることができます。 ghci> :t filter filter :: (a -> Bool) -> [a] -> [a] これはなんかいい機能ですね。 まずは関数定義からやっていきましょう。 適当なプロジェクトを作成します。 stack new haskell-playground これをVSCodeで開きます。 拡張機能もインストールしておきましょう。 Haskell Extension Pack - Visual Studio Marketplace では関数を定義してみましょう。 factorial 0 = 1 factorial n = n * factorial (n - 1) main = do print $ factorial 2 こんな感じでfactorial関数を定義しました。 ...

2024年1月17日 · にあえん

rubyに入門する

Rubyってどうなの?ナナオです。 今回はあまり触ってこなかったRubyに入門してみようと思います。 きっかけとしてはある会社と面談したときに面白そうな会社だな~~と思ったのですが、Rubyをメインで使っている会社だったからです。 私のRubyのレベルは若干しかできないくらいのレベルなので、基礎はできるようにしておこうと思い、今回備忘録もかねて入門してみようと思います。 Rubyのセットアップ まずはRubyのインストールを行っていきましょう。 バージョン管理はしっかりやっておきたいので、rbenvを使います。 私の開発環境はWindowsですが、anyenvを使いたかったのでWSL2で作業はしています。 また、すでにanyenvをダウンロード済みの環境ですが、anyenvのインストールは公式リポジトリを参照してください。 ではanyenvでrbenvをセットアップしていきます。 anyenv install rbenv これで問題なくrbenvはインストールできます。 あとは適当に安定版の3.2.2くらいをインストールします。 rbenv install 3.2.2 ただここでエラーが起きてしまいました。かなしいね。 ==> Downloading openssl-3.1.4.tar.gz... -> curl -q -fL -o openssl-3.1.4.tar.gz https://dqw8nmjcqpjn7.cloudfront.net/840af5366ab9b522bde525826be3ef0fb0af81c6a9ebd84caa600fea1731eee3 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 14.8M 100 14.8M 0 0 10.0M 0 0:00:01 0:00:01 --:--:-- 10.0M ==> Installing openssl-3.1.4... -> ./config "--prefix=$HOME/.anyenv/envs/rbenv/versions/3.2.2/openssl" "--openssldir=$HOME/.anyenv/envs/rbenv/versions/3.2.2/openssl/ssl" zlib-dynamic no-ssl3 shared -> make -j 24 BUILD FAILED (Ubuntu 22.04 on x86_64 using ruby-build 20231225-4-g33168b3) You can inspect the build directory at /tmp/ruby-build.20240115225829.19003.NXfhFA See the full build log at /tmp/ruby-build.20240115225829.19003.log ログを見てみると、zlibがインストールされていないのが原因だったようです。 ...

2024年1月15日 · にあえん