物忘れの激しいエンジニアのメモ

スクレイピング、映像系、アプリ、webなど...

【Unity】 ArgumentOutOfRangeException: Year, Month, and Day parameters describe an un-representable DateTime.

背景

「明日の0時までのカウントダウンを表示する」というのをやりたかった。 問題のコードはこちらです。

        current = DateTime.Now;
        tomorrow = new DateTime(current.Year, current.Month, current.Day + 1);

tomorrowは時間を指定せず初期化すると0時0分0秒となるので、 DateTime.Nowtomorrowの差分が明日までの時間になりますね。

ところがある日、エラーが出ていることに気付きました...

ArgumentOutOfRangeException: Year, Month, and Day parameters describe an un-representable DateTime.

原因

エラーの通りDatetimeの初期化に使っている数値がOutOfRangeということですね...

エラーが出た日は9月30日。つまりtomorrowの初期化に9月31日(存在しない)を指定していたのですね...

(リリース前に気づけてよかった)

解決策

AddDays()を使いましょう!

        current = DateTime.Now;
        tomorrow = new DateTime(current.Year, current.Month, current.Day).AddDays(1);

まとめ

AddMonths()とかがわざわざあるのはこういう日時特有の計算が楽になるためです!

変なことせず素直にこういう関数を使っていきましょう!

(自戒を込めて)

ffmepg で No such filter: 'drawtext' エラー

背景

動画に文字をfade in / fade out でいれるのにdrawtextが使える!という情報を見て、コマンドを実行するとdrawtextが無いというエラー。

$ ffmpeg -i "input.mp4" -filter_complex "format=gbrp,drawtext=fontfile='your/font/file':fontsize='30':x=(w-tw)/2:y=(h-th)/1.2:text='title_text':fontcolor_expr=ffffff%{eif\\:clip(255*(1*between(t\,1+1.5\,6-1.5)+((t-1)/1.5)*between(t\,1\,1+1.5)+(-(t-6)/1.5)*between(t\,6-1.5\,6) )\,0\,255)\\:x\\:2},format=pix_fmts=yuv420p" -movflags +faststart -c:v libx264 -crf 20 "output.mp4"

...

[AVFilterGraph @ 0x466e4c0] No such filter: 'drawtext'

...

原因

使用しているffmpegがdrawtextに対応していないのが原因でした。

解決方法

drawtextを使用するにはfreetypeというライブラリが必要でした。

stackoverflow.com

しかし当方Macなのですが、brewffmpegをインストールするときのオプションが廃止されているようです。

$ brew install ffmpeg --with-freetype

Error: invalid option: --with-fdk-freetype

そしてオプションつけなくても全部入りでインストールされるようです!

qiita.com

なのでffmpegを再インストールしたら無事にdrawtextを使えるようになりました。

$ brew reinstall ffmpeg

まとめ

Macに入っていたffmepgのバージョンがdrawtextに対応していなかった。 ffmpegをインストールしなおしたら使えるようになりました。

$ brew reinstall ffmpeg

React Native iOS build エラー directory not found for option '-L-L/.../CocoaAsyncSocket'

内容

ExpoをejectしてiOSをビルドしようとしたら遭遇したエラー。

$ expo eject
$ cd ios
$ pod install
$ open ios/PROJECT_NAME.xcworkspace

# xcodeでビルド

環境

  • Expo 38.0.0

解決策

LIBRARY_SEARCH_PATHSにいくつか値が入っているのですが、${inherited}を一番下にすると解決しました!

ここここの2箇所あるのですが、自分の環境の場合は後者で${inherited}が一番上になっていました。

fastlane deliver でエラー Potential server error

現象

fastlaneios buildをアップロードしようとしたらエラー。

[] Activating languages en-US, ja... Potential server error received: 'Unexpected Error'. Retrying after 10 
seconds (remaining: 2)...                                                                                    
[] Activating languages en-US, ja... Potential server error received: 'Unexpected Error'. Retrying after 10 
seconds (remaining: 1)...                                                                                    
[] Activating languages en-US, ja...                    

...

\e[31m[!] The request could not be completed because: (Spaceship::Tunes::PotentialServerError)

...

原因

いつの間にかhttps://appstoreconnect.apple.com/ の見た目が変わっていて、バックエンドも変わったっぽい! fastlaneの中の人が対応してくれているみたいです。

github.com

対策

2020/7/1 18:00現在で2.150.0.rc7が出ているので、これをインストールします。(githubにrcのインストール方法も書いてあって、rubyに馴染みがない人にもわかりやすくて親切ですね!)

gem install fastlane --pre

or

gem install fastlane -v 2.150.0.rc7

みなさんがこれをみている頃には正式にアップデートが来ているかもしれないので、その場合は普通にアップデートしましょう。

gem install fastlane

Expo (React Native) でios buildしようとしたらエラー (authentication with apple developer portal failed!)

エラーの内容

expoでios buildしようとしたら発生したエラー。

$ expo build:ios
Checking if there is a build in progress...

Please enter your Apple Developer Program account credentials. These credentials are needed to manage
certificates, keys and provisioning profiles in your Apple Developer account.
The password is only used to authenticate with Apple and never stored.
? Apple ID: MY_APPLE_ID
? Password (for MY_APPLE_ID): [hidden]
Trying to authenticate with Apple Developer Portal...
Authentication with Apple Developer Portal failed!
Reason: Unknown reason, raw: "SSL_connect returned=1 errno=0 state=error: certificate verify failed"
Error: Reason: Unknown reason, raw: "SSL_connect returned=1 errno=0 state=error: certificate verify failed"
    at runAction (/expo-cli@3.11.5/src/appleApi/fastlane.ts:28:17)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at Object.authenticate (/expo-cli@3.11.5/src/appleApi/authenticate.ts:46:40)
    at IOSBuilder.getAppleCtx (/expo-cli@3.11.5/src/commands/build/ios/IOSBuilder.js:47:23)
    at IOSBuilder.produceMissingCredentials (/expo-cli@3.11.5/src/commands/build/ios/IOSBuilder.js:123:22)
    at IOSBuilder.prepareCredentials (/expo-cli@3.11.5/src/commands/build/ios/IOSBuilder.js:65:7)
    at IOSBuilder.run (/expo-cli@3.11.5/src/commands/build/ios/IOSBuilder.js:19:7)
    at IOSBuilder.command (/expo-cli@3.11.5/src/commands/build/BaseBuilder.js:55:7)
    at Command.<anonymous> (/expo-cli@3.11.5/src/exp.ts:81:7)

原因

bundle identifier(App Store内で使われるアプリのID)が同じで、slug(expo内で使われるアプリのID)が違うアプリが2つあることが原因のようでした。

app.json

{
  "expo": {
    ...
    "slug": "EXPO_APPLICATION_ID",         <- HERE
    ...
    "ios": {
      "bundleIdentifier": "APP_STORE_ID",  <- HERE
      ....
    }
  }
}

前に違うディレクトリで同様のアプリを作っており、今回最初から作り直したのですが、その2つのアプリのslugが違っていました。

解決策

前のslugに修正したところ、無事にビルドできました。

試してみて効果がなかったこと

  • rm -rf node_modules; yarn
  • PCの再起動

試してないので効果があるかも

動作環境

$ expo diagnostics

  Expo CLI 3.11.5 environment info:
    System:
      OS: macOS 10.14.3
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 12.10.0 - /usr/local/bin/node
      Yarn: 1.21.1 - /usr/local/bin/yarn
      npm: 6.13.6 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    IDEs:
      Android Studio: 3.4 AI-183.6156.11.34.5692245
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      @types/react: ~16.9.0 => 16.9.17 
      @types/react-native: ~0.60.23 => 0.60.27 
      expo: ~36.0.0 => 36.0.2 
      react: ~16.9.0 => 16.9.0 
      react-native: https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz => 0.61.4 
      react-navigation: ^4.0.10 => 4.0.10 
    npmGlobalPackages:
      expo-cli: 3.11.5

React Nativeのrender()内でコメントアウトする

{/* */}で囲えばOK

import React from 'react';
import {
  Text,
  View,
} from 'react-native';

export default Sample extends React.Components {
  render() {
    return (
      <View>
        <Text>サンプル</Text>

        {/*  <Text>コメントアウトしたいところ</Text>  */}

      </View>
    )
  }
}

Wifi / コンセント(電源)の情報が公式サイトに載っているかまとめ

Wifiとコンセントに関する正確な情報が欲しかったので調べた時のリスト

随時更新予定

cafe

店名 コンセント wifi
ドトール o o
ルノアール o o
UCCグループ o o
珈琲館 o o
イタリアントマト o o
JR東日本フードビジネス o o
コメダ珈琲 ?(コメント欄にあるかも) o
スターバックス x o
タリーズ x o
プロント x o
cafe de crie x o
シアトルズベストコーヒー x o
サンマルク x x
シャノアール x x

fast food

店名 コンセント wifi
モスバーガー o o
バーガーキング o o
ケンタッキー x o
ロッテリア x o
マクドナルド x o
フレッシュネスバーガー x o
ヴィ・ド・フランス x x
サブウェイ x x

family restaurant

店名 コンセント wifi
デニーズ x o
びっくりドンキー x x
サイゼリヤ ? ?
ガスト ? ?

convinience store

店名 コンセント wifi
セブンイレブン x o
ファミリーマート ? ?
ローソン ? ?