- 投稿日:2020-04-04T21:59:06+09:00
iosアプリ開発 初心者
はじめに
これからiosアプリを開発していくにあたって日々学んだことをアウトプットしていきます。
少しでも参考になれたらと思います。Mac
AndroidアプリはMacとWindowsどちらでも開発可能ですが、iPhone用のアプリを開発するにはMacが必要です。
これからアプリを開発していこうと考えている方はMacのPCを
買うことをおすすめします。Xode
XcodeはAppleが無料で提供しているiosアプリ開発では王道のツールです。
iPhone、iPad、Mac、Apple Watchのアプリを開発できます。※XcodeはMacでのみ動作しますが、最新バージョンのXcodeをインストールするためには、MacのOSも最新バージョンである必要があります。
Swift
SwiftはAppleが開発した新しいプログラミング言語で2014年から使わています。
対象としているOSは、MacOSとiOSで、PhoneやiPadなどの端末で使えるアプリ、パソコン向けのアプリを開発することができます。
これまではObjective-C使われていましたが、スピード・安定性・コスト・メンテナンス面から考えるとSwiftが優れています。
- 投稿日:2020-04-04T19:37:39+09:00
Mac初心者、買って1年のトラックパット異常に震える
今日は表題のトラブルがあったので共有します。
そう、トラックパッドが反応しなくなりました。新品で買ってちょうど1年ぐらいで、macBookProというハードでのトラブルは初めてだったので、すごく焦りました。トラックパッドをしっかり拭き掃除したら、直った。
結果、どうやって直したかというと、下記の記事を参考にしっかりトラックパッドを拭いて、再起動したら直りました。
見た目では見えにくい汚れがいっぱいついてたんです。TechRacho様[MacのMagic Trackpadの不具合を修正する方法]
https://techracho.bpsinc.jp/hachi8833/2018_05_02/55798PRAMクリアとかSMCリセットで改善する方法は他の色々なサイトさんで紹介されていたのですが、物理的な汚れを原因をとして挙げられていたのは、私が見た限りこちらの記事だけでした。
同じようなトラブルで今戦々恐々としてる方にこの記事が届いたら幸いです。
- 投稿日:2020-04-04T18:37:21+09:00
新しいmacを買ったら最初にやること
この記事は何?
最近新しいmacを買ったので備忘録を兼ねて自分なりの最低限の設定を記事にした。
ほんとの最初に入れるソフト
名前 これはなに? Google Chrome webブラウザ Alfred アプリランチャー。このためにmacを使ってるといっても過言ではない Google 日本語入力 IME.ことりえ使いづらい Karabiner-Elements US配列だと言語切替が辛いのでこれで⌘に割り当てる 黒い画面
iTerm2をインストール
https://www.iterm2.com/
標準のターミナルよりも使いやすさ/カスタマイズ性ともに優秀HomeBrewをインストール
これがないと何も始まらない
https://brew.sh/index_ja標準シェルをfishにする
fish
is 便利・わかりやすい・かわいいbrew install fish which fish | sudo tee -a /etc/shells chsh -s /usr/local/bin/fishこのあとiTerm2を再起動すれば標準シェルがfishになってる。
fisher man
fishのパッケージマネージャー
curl https://git.io/fisher --create-dirs -sLo ~/.config/fish/functions/fisher.fishテーマの変更
bobthefishがお気に入り
fisher add oh-my-fish/theme-bobthefishで導入完了
Hack Nerd Font のインストール
上のテーマでアイコンなどが文字化けすることがあるので、対応してるフォントを入れる
https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/Hack
フォントをインストールしたらiTerm2のフォント設定を変えるのを忘れずに。いろんなパッケージを入れる
brew install peco ghq emacs wget
なまえ これはなに? peco 標準入力をインクリメンタルサーチして出力してくれるすごい子 ghq gitリポジトリを管理するためのツール emacs catalinaからemacsが標準で入ってないので wget wget.なんで標準で入ってないんですかね fish config
fishは
~/.bash_profile
じゃなくて、~/.config/fish/config.fish
を読む~/.config/fish/config.fish## peco-history function fish_user_key_bindings bind \cr peco_select_history end ## alias alias g="cd (ghq root)/(ghq list | peco)" alias gs="git status"fisher add oh-my-fish/plugin-peco
peco-history
はctrl+Rでコマンド履歴をインクリメンタルサーチする設定
g
はghqで管理しているリポジトリをインクリメンタルサーチし、移動するためのエイリアスgit
git config --global user.email hoge@example.com git config --global user.name "Foo Bar" git config --global core.editor "emacs -nw" git config --global push.default simpleSSH
ssh-keygen -t rsa cat ~/.ssh/id_rsa.pub | pbcopy #クリップボードに公開鍵をコピーあとはGitHubに登録したり、サーバーに登録したりする。
GitHubの疎通確認
ssh -T git@github.com
サーバーに公開鍵を登録
公開鍵をサーバーの
~/.ssh/authorized_keys
に追記するローカルマシンに以下の設定をしておくと、
ssh myserver
だけで接続できるようになる。~/.ssh/configHost myserver HostName example.com IdentityFile ~/.ssh/id_rsa User fooDocker
https://docs.docker.com/docker-for-mac/install/
各言語設定
とりあえずanyenvを入れて **envの管理をする
brew install anyenv anyenv install --init以下を追記
~/.config/fish/config.fish## anyenv eval (anyenv init -| source)python
※僕はanacondaよりもpyenv派です
anyenv install pyenv exec $SHELL -l pyenv versions pyenv install --list # インストール可能なpythonバージョンの確認 pyenv install 3.6.9 pyenv global 3.6.9 && pyenv rehash pip install -U pipエディタ
emacs
すでにbrewでいれてある。
起動するとWarning (initialization): Unable to access user-emacs-directory
みたいなエラーメッセージが出てくるのでパーミッションを変更する。sudo chown -R $USER .emacs.d/VS code
https://code.visualstudio.com/
code
コマンドを使えるようにする⌘+Shfit+P >
Shell Command: Install 'code' command in PATH
を実行するとcodeコマンドが使えるようになる。
ターミナルから直接ファイルやプロジェクトを開くときに便利settings
⌘+Shfit+P > Open Settings (JSON)
以下を追記settings.json{ // ... "terminal.integrated.shell.osx": "/usr/local/bin/fish", "terminal.integrated.fontFamily": "Hack", "files.autoSave": "afterDelay" }Extensions
なまえ これはなに? Bracket Pair Colorizer 括弧をカラフルに装飾してくれるので、対応関係がわかりやすくなる GitLens git blameのすごいやつ。この行の過去編集した人を突き止められる indent-rainbow インデントをカラフルにしてくれるので、対応関係がわかりやすい。特にpythonistにはおすすめ Material Icon Theme ファイルアイコンを可愛くしてくれるやつ Path Intellisense ファイルパスを自動補完してくれる Prettier コードフォーマッター TODO Highlight vscodeは標準でアノテーションコメントをハイライトしてくれないので、その対処法 Trailing Spaces 文末の余計なSpaceをハイライトしてくれる ディスプレイの表示領域を拡張
Retinaディスプレイなのにmacだとその巨大な画面を活かせないので、Display Menuを使って拡張する。
- 投稿日:2020-04-04T09:27:21+09:00
MacでFlutterのプロジェクト作ってみた
概要
iOS/Androidのツール系アプリ作りたくなってFlutter使ってみようと思ったんですが、
今までまったく触ったことなかったんで、導入からプロジェクト作成までの備忘としてのまとめたものになります。全部ここ見ながら作ってます。
https://flutter.dev/docs/get-started/installそもそも上の公式の説明がとてもわかりやすいんで、結論いうとあんまりこの記事価値ない…(´・ω・`)
環境
- Mac OSX Catalina
- Xcode 11
- Flutter v1.12.13
- IntelliJ IDEA Ultimate Edition (version 2019.1.4)
- Android Studio 3.5でもできるっぽい
- VSCodeでもできるっぽい
- Vimでもできるっぽい
ゴール
- 簡単なプロジェクトを作ってiOSシミュレーターで動かし、少しコードをいじって反映されるの確認する
FlutterのSDKインストール
この通りやればいい感じ。
https://flutter.dev/docs/get-started/install/macosなお、ツールとして
bash
を使っているっぽいので、zsh
になってる場合はbash
に戻します。Macでzshからbashへ戻す方法(Catalina)
https://qiita.com/___inon_/items/c9a30e78196998f4160cその他、Flutterは以下に依存してるそうです。
- bash
- curl
- git 2.x
- mkdir
- rm
- unzip
- which
- zip
SDKを落として解答してきた後、
~/.bash_profile
に以下を追記PATH="<flutterのルートディレクトリ>/bin:${PATH}"その後、
source ~/.bash_profile
とやって変更を反映し、実際にflutter
と打ってパスが通っていることを確認。$ flutter Manage your Flutter app development. Common commands: flutter create <output directory> Create a new Flutter project in the specified directory. flutter run [options] Run your Flutter application on an attached device or in an emulator. ︙必要なものがあるかどうかの確認
flutter doctor
というコマンドを打つと、必要な依存ライブラリがインストールされているかどうか確認できる$ flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Mac OS X 10.14.5 18F132, locale ja-JP) [!] Android toolchain - develop for Android devices (Android SDK version 28.0.3) ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses [!] Xcode - develop for iOS and macOS (Xcode 10.3) ✗ Flutter requires a minimum Xcode version of 11.0.0. Download the latest version or update via the Mac App Store. [!] Android Studio (version 3.5) ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. [!] IntelliJ IDEA Ultimate Edition (version 2019.1.4) ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. [!] VS Code (version 1.43.2) ✗ Flutter extension not installed; install from https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [!] Connected device ! No devices available結構怒られてる(´・ω・`)
Xcodeかぁ…Catalinaに変えたくないんだけどなぁ。
まぁいずれやらないといけないんだし、この機にやろうかなぁ。
(またXVimインストールしなおしかぁ…)というわけでCatalinaにアップデートしてXcodeも11にして再度実行し、ひとつずつ解決していく。
書かれてることをやるだけだからかんたん。# Android側のissue解決 $ flutter doctor --android-licenses # iOS側のissue解決 $ sudo xcodebuild -license # なぜかCatalinaインストール後にCocoaPodsが使えなくなってたから再インストール $ sudo gem install cocoapodsいずれvimで開発できるようにしたいけど、ひとまずはIntelliJにプラグインをインストール。
再度doctorを実行。
$ flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Mac OS X 10.15.4 19E266, locale ja-JP) [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [✓] Xcode - develop for iOS and macOS (Xcode 11.4) [!] Android Studio (version 3.5) ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. [✓] IntelliJ IDEA Ultimate Edition (version 2019.1.4) [!] VS Code (version 1.43.2) ✗ Flutter extension not installed; install from https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [!] Connected device ! No devices availableとりあえずこれでいいや。
簡単なプロジェクト作成して動かす
結論は以下(特に何もひっかからなかった)
# プロジェクト作成 $ flutter create my_app # 動かしてみる $ cd my_app $ flutter run No supported devices connected. # なるほどねぇ。 # とりあえずiOSシミュレーターを起動してみる $ open -a Simulator # 再度実行 $ $ flutter run Launching lib/main.dart on iPhone 5s in debug mode... Running Xcode build... ├─Assembling Flutter resources... 10.3s Apr 4 09:13:05 ****-puro com.apple.CoreSimulator.SimDevice.1B269AD0-DBEB-4ED9-8941-25D8BB115D2F[17945] (com.apple.imfoundation.IMRemoteURLConnectionAgent): Unknown key for integer: _DirtyJetsamMemoryLimit Apr 4 09:13:06 ****-puro com.apple.CoreSimulator.SimDevice.1B269AD0-DBEB-4ED9-8941-25D8BB115D2F[17945] (com.apple.imfoundation.IMRemoteURLConnectionAgent): Unknown key for integer: _DirtyJetsamMemoryLimit └─Compiling, linking and signing... 54.9s Xcode build done. 73.7s PackageType = Developer; SimulatorRootPath = "/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 10.3.simruntime/Contents/Resources/RuntimeRoot"; SimulatorUserPath = "/Users/****/Library/Developer/CoreSimulator/Devices/1B269AD0-DBEB-4ED9-8941-25D8BB115D2F/data"; } CFBundleIdentifier = "com.example.myApp"; PackageType = Developer; SimulatorRootPath = "/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 10.3.simruntime/Contents/Resources/RuntimeRoot"; SimulatorUserPath = "/Users/****/Library/Developer/CoreSimulator/Devices/1B269AD0-DBEB-4ED9-8941-25D8BB115D2F/data"; }) arguments = ( "--enable-dart-profiling", "--enable-checked-mode", "--verify-entry-points", "--observatory-port=0" ); environment = { TERM = "xterm-256color"; }; } retryTimeout: 120.000000 (default write com.apple.CoreSimulatorBridge LaunchRetryTimeout <value>) bootTimeout: 300.000000 (default write com.apple.CoreSimulatorBridge BootRetryTimeout <value>) bootLeeway: 120.000000 (default write com.apple.CoreSimulatorBridge BootLeeway <value>) Note: Use 'xcrun simctl spawn booted defaults write <domain> <key> <value>' to modify defaults in the booted Simulator device. Simulator booted at: 2020-04-04 00:11:47 +0000 Current time: 2020-04-04 00:14:04 +0000 Within boot leeway: NO <<CGColorSpace 0x60000002b980> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; sRGB IEC61966-2.1)> width = 320, height = 568, bpc = 8, bpp = 32, row bytes = 1280 kCGImageAlphaNoneSkipFirst | kCGImageByteOrder32Little is mask? No, has mask? No, has matte? No, should interpolate? Yes with colorSpace=<CGColorSpace 0x60000002b980> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; sRGB IEC61966-2.1) Syncing files to device iPhone 5s... 7,093ms (!) ? To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R". An Observatory debugger and profiler on iPhone 5s is available at: http://127.0.0.1:52406/15rvDpukoRM=/ For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".動いた。
マテリアルデザインちょっと嫌だけど他に変えたりとかできるのかなぁ。編集してHotRestartをやってみる。
flutter create my_app
で既に作成されてるmy_app/lib/main.dart
をいじる。class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( // This is the theme of your application. // // Try running your application with "flutter run". You'll see the // application has a blue toolbar. Then, without quitting the app, try // changing the primarySwatch below to Colors.green and then invoke // "hot reload" (press "r" in the console where you ran "flutter run", // or simply save your changes to "hot reload" in a Flutter IDE). // Notice that the counter didn't reset back to zero; the application // is not restarted. primarySwatch: Colors.blue, ), home: MyHomePage(title: 'ふらったーでもぺーじ'), ); } }そして、ターミナルで
r
を押下。For a more detailed help message, press "h". To detach, press "d"; to quit, press "q". Initializing hot reload... Reloaded 1 of 478 libraries in 259ms.こいつは簡単だねぇ。
というわけで
ちょっと簡単なアプリ作っていってみようかと思います(`・ω・´)