slim用都道府県プルダウン

HTMLのselect要素とoption要素を使うアレです。

option value="" --
option value="北海道" 北海道
option value="青森県" 青森県
option value="岩手県" 岩手県
option value="宮城県" 宮城県
option value="秋田県" 秋田県
option value="山形県" 山形県
option value="福島県" 福島県
option value="茨城県" 茨城県
option value="栃木県" 栃木県
option value="群馬県" 群馬県
option value="埼玉県" 埼玉県
option value="千葉県" 千葉県
option value="東京都" 東京都
option value="神奈川県" 神奈川県
option value="新潟県" 新潟県
option value="富山県" 富山県
option value="石川県" 石川県
option value="福井県" 福井県
option value="山梨県" 山梨県
option value="長野県" 長野県
option value="岐阜県" 岐阜県
option value="静岡県" 静岡県
option value="愛知県" 愛知県
option value="三重県" 三重県
option value="滋賀県" 滋賀県
option value="京都府" 京都府
option value="大阪府" 大阪府
option value="兵庫県" 兵庫県
option value="奈良県" 奈良県
option value="和歌山県" 和歌山県
option value="鳥取県" 鳥取県
option value="島根県" 島根県
option value="岡山県" 岡山県
option value="広島県" 広島県
option value="山口県" 山口県
option value="徳島県" 徳島県
option value="香川県" 香川県
option value="愛媛県" 愛媛県
option value="高知県" 高知県
option value="福岡県" 福岡県
option value="佐賀県" 佐賀県
option value="長崎県" 長崎県
option value="熊本県" 熊本県
option value="大分県" 大分県
option value="宮崎県" 宮崎県
option value="鹿児島県" 鹿児島県
option value="沖縄県" 沖縄県

Flutter ipaをApp Store Connectにアップロード

Build and release an iOS app | Flutter

を読んでいきます。

バンドルIDの作成とか、新規Appの追加などは、特に難しい内容はないはず。

ただ、ここに、

https://docs.flutter.dev/deployment/ios#create-an-application-record-on-app-store-connect

Since Flutter does not currently support tvOS, leave that checkbox unchecked. Click Create.

という記述があって、そりゃそうだなと思いながら、勢い余って、チェック入れないように気をつけました。

で下記が重要な設定で

https://docs.flutter.dev/deployment/ios#review-xcode-project-settings

Runner.xcworkspaceをXcodeで開いて編集します。

この辺りは、pubspec.yamlに書いてうまいことやってくれるわけではないようです。

続いて、Signing & Capabilitiesの部分ですが、Automatically manage signingにチェックが入ったままでいいそうです。

昔は、周りでかなり苦労した話をよく聞きますが、かなり簡単になってるようです。

ちなみに、Flutterではない別のプロジェクトでもここはチェックを入れたままにしています。

また、忘れそうな設定としては、Deployment Target を変更した場合は下記も一緒に変更するようです。

MinimumOSVersion

上記の設定を一通り行うと、下記のリンク先にあるようにflutter build ipaを実行することができるようになります。

https://docs.flutter.dev/deployment/ios#create-an-app-bundle

ここで、少し横道にそれますが、reverse engineerという単語が出てきますが、 デコンパイルという用語よりも一般的なんだなと思いました。

ここは、まだデモの段階ならいいと思いますが、商用リリース前にはもう一度見直さないといけないと思います。

次に下記を参考にして、ipaApp Store Connectにアップロードします。

https://docs.flutter.dev/deployment/ios#upload-the-app-bundle-to-app-store-connect

自分は、3番目の方法を選びました。

open build/ios/archive/Runner.xcarchive

で、Archiveの一覧が表示されると思います。そこでValidate AppDistribute Appを手順の通り行います。

ここで

Note: When you export your app at the end of Distribute App, Xcode will create a directory containing an IPA of your app and an ExportOptions.plist file. You can create new IPAs with the same options without launching Xcode by running flutter build ipa --export-options-plist=path/to/ExportOptions.plist. See xcodebuild -h for details about the keys in this property list.

という記述が見つかりますが、flutter build ipaの時点でExportOptions.plistが見つかるので、exportはもしかすると不要かもしれません。

Flutter はみ出した部分が、エラーなど発生せずに切り取られる

左から太陽

こんな感じで、左から太陽がのぞいてるようなwidgetを実現したい場合があると思います。

これは、OverflowBox + Stack + Positioned の組み合わせで実現しました。 CustomPaintでも実現できそうですが、コード量が多くなると思うので、やめました。

下記にコードを置いておきました

https://dartpad.dev/?id=784c003cc4d525d2dde8e51919d046a9

ITMS-90338: Non-public API usage - The app references non-public selectors in XXX: connectionState.

結論

GoogleCast.xcframeworkをEmbed & Signにすると解決しました。

cast_xcframework_embed_and_sign

過程

https://github.com/Carthage/Carthage#quick-start

If you are using Carthage for an application, select "Embed & Sign", otherwise "Do Not Embed".

と書いてあって、自分はCarthageに慣れてないので、勘違いしました。

GoogleCastのsdkは手動でダウンロードしたものです。

connectionStateはプロジェクト内をファイル検索するとGoogle Cast SDK内のGCKSession.hにconnectionStateというプロパティがあったため気づくのは早かったです。

Google Cast SDKのバージョンが古くて、android12, 13でクラッシュした話

https://developers.google.com/cast/docs/release-notes#november-16,-2021

アプリは定期的にメンテナンスしないと動かなくなる典型のような話。

サーバサイドであれば、自社でホスティングしてるなどの場合は、 10年でも20年でも生き続けられるが、アプリはそうはいきません。

今回は、

https://developers.google.com/android/guides/releases#december_13_2018

からのバージョンアップだったので、たった3年くらいで、アプリが動かなくなったということになります。

ただ、クラッシュが顕著になったのは、android12が普及し始めた、今年だったので、実質4年とかにはなります。

Riverpodが2.0で結構変わった

https://docs-v2.riverpod.dev/

@riverpodとか増えてる

まずは、Counterアプリを作ってみます。

横道にそれますが、dartにData Classってそろそろくるのか?

https://github.com/dart-lang/language/issues/1482

話を戻しますと、providerをgenerateしようとして、下記のコマンドを打ったところ下記のエラーが発生。

dart run build_runner watch                             
Could not find a file named "pubspec.yaml" in "/Users/t-watanabe/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-50.0.0".
#0      new Pubspec.load (package:pub/src/pubspec.dart:306:7)
#1      new Package.load (package:pub/src/package.dart:128:29)
#2      SystemCache.load (package:pub/src/system_cache.dart:105:20)
#3      Entrypoint._createPackageGraph (package:pub/src/entrypoint.dart:121:63)
#4      Entrypoint.packageGraph (package:pub/src/entrypoint.dart:116:54)
#5      getExecutableForCommand (package:pub/src/executable.dart:339:19)
#6      RunCommand.run (package:dartdev/src/commands/run.dart:250:32)
#7      CommandRunner.runCommand (package:args/command_runner.dart:209:27)
#8      DartdevRunner.runCommand (package:dartdev/dartdev.dart:231:30)
#9      CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:119:25)
#10     new Future.sync (dart:async/future.dart:302:31)
#11     CommandRunner.run (package:args/command_runner.dart:119:14)
#12     runDartdev (package:dartdev/dartdev.dart:66:29)
#13     main (file:///opt/s/w/ir/x/w/sdk/pkg/dartdev/bin/dartdev.dart:11:9)
#14     _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:293:32)
#15     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)

上はdart pub getで解決しました。masonあたりを試してた時になんかやっちゃったんだな。多分。

↓のエラーも出てるが、flutterのissueを見てもよくわからない。一旦放置。

Notifier

同じ会社の人に聞きましたが、StateNotifierはもうlegacyらしい。

https://pub.dev/documentation/riverpod/latest/riverpod/Notifier-class.html

https://github.com/bizz84/async_notifier_example_riverpod/blob/main/lib/notifiers/counter.dart

↑を参考にするとこんなんでいいらしい

/// Notifier example (with codegen)
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'counter.g.dart';

@riverpod
class Counter extends _$Counter {
  @override
  int build() {
    return 0;
  }

  void increment() {
    state++;
  }
}

これだけで、昔で言うところのStateNotifierProviderみたいなやつも生成される

↓のあたり。

https://github.com/bizz84/async_notifier_example_riverpod/blob/main/lib/notifiers/counter.g.dart#L35

呼び出すときはこんな感じですね

import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

import 'counter.dart';

class CounterView extends HookConsumerWidget {
  const CounterView({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final count = ref.watch(counterProvider);
    final notifier = ref.read(counterProvider.notifier);
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        body: Center(
          child: Text('$count'),
        ),
        floatingActionButton: FloatingActionButton(
          // The read method is a utility to read a provider without listening to it
          onPressed: () => notifier.increment(),
          child: const Icon(Icons.add),
        ),
      ),
    );
  }
}

(作業ログ)carthageを使ったちょっと古めのプロジェクトをビルドしてみる

一部伏せ字にしてます。

CocoaPodsでもいいと思いますが、carthageの方がちょっと速いということで頑張って使ってみることに。

早く、SwiftPM一択の世界になってほしい。

carthageをmacportsでインストール

SwifteriOSだけNo such module 'SwifteriOS'になる

carthage update --use-xcframeworks

xcodebuild: error: Failed to build workspace KeychainAccess with scheme KeychainAccess.
        Reason: The run destination Any watchOS Device is not valid for Archiving the scheme 'KeychainAccess'.
        Recovery suggestion: watchOS 9.1 is not installed. To use with Xcode, first download and install the platform

carthage update --use-xcframeworks --platform iOSでもダメ

cannot be opened because it is missing its project.pbxproj file.

そもそも、carthage.shじゃないとダメなのか。面倒。
※この後気づきますが、carthage.shは、現在不要になっています。

CocoaPodsを使用するように変更

[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `XXX` to `Target Support Files/Pods-XXX/Pods-XXX.debug.xcconfig` or include the `Target Support Files/Pods-XXX/Pods-XXX.debug.xcconfig` in your build configuration (`XXX/Configurations/Includes/Config.debug.xcconfig`).

[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `XXX` to `Target Support Files/Pods-XXX/Pods-XXX.adhoc.xcconfig` or include the `Target Support Files/Pods-XXX/Pods-XXX.adhoc.xcconfig` in your build configuration (`XXX/Configurations/Includes/Config.adhoc.xcconfig`).

[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `XXX` to `Target Support Files/Pods-XXX/Pods-XXX.release.xcconfig` or include the `Target Support Files/Pods-XXX/Pods-XXX.release.xcconfig` in your build configuration (`XXX/Configurations/Includes/Config.release.xcconfig`).

[!] The `XXX [Adhoc]` target overrides the `OTHER_SWIFT_FLAGS` build setting defined in `Pods/Target Support Files/Pods-XXX/Pods-XXX.adhoc.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] Your project does not explicitly specify the CocoaPods master specs repo. Since CDN is now used as the default, you may safely remove it from your repos directory via `pod repo remove master`. To suppress this warning please add `warn_for_unused_master_specs_repo => false` to your Podfile.

ここでうげっとなる。

techlife.cookpad.com

carthage update --use-xcframeworks --platform iOS これがファイナルアンサーか?

Writing error result bundle to /var/folders/yg/sdmzgphn5pb9vlh_8ny1z59m0000gn/T/ResultBundle_2022-13-12_14-39-0002.xcresult
xcodebuild: error: Unable to read project 'NukeDemo.xcodeproj' from folder '/Users/t-watanabe/work/XXX/XXX/Carthage/Checkouts/Nuke/Demo'.
    Reason: Project /Users/t-watanabe/work/XXX/XXX/Carthage/Checkouts/Nuke/Demo/NukeDemo.xcodeproj cannot be opened because it is missing its project.pbxproj file.

rm -rf Carthage

今度はうまく行ったようす

Frameworks and Librariesがどこにあるかわからない

ちゃんとターゲットを選択しないとダメなやつだ

"Embed & Sign"にチェックを入れる

ios - Cannot import Firebase in Swift app - Stack Overflow

import Firebaseじゃなくなったのか

Type of expression is ambiguous without more context Nukeのバージョンをあげすぎたので書き方が変わりすぎたので、一旦戻す。11系から9系に

framework not found firebaseCoreDiagnostics が出た。該当のフレームワークが赤字になってたので削除した。 一緒に、赤字になってるのは全て削除

Building for iOS Simulator, but linking in dylib built for iOS, file '/Users/t-watanabe/work/XXX/XXX/GoogleCastSDK-ios-4.5.0_dynamic/GoogleCast.framework/GoogleCast' for architecture arm64

いつものやつだ、

https://qiita.com/littleossa/items/ff75b19e0ac6713941f8

/usr/local/bin/carthage: No such file or directory Command PhaseScriptExecution

https://github.com/Carthage/Carthage/issues/3110

シンボリックリンク貼るのか。

which carthage
/opt/local/bin/carthage

sudo ln -s /opt/local/bin/carthage /usr/local/bin/carthage
Showing Recent Issues
Failed to read file or folder at /Users/t-watanabe/work/XXX/XXX/Carthage/Build/iOS/SVProgressHUD.framework: Error Domain=NSCocoaErrorDomain Code=259 "Cannot retrive binary file from bundle at file:///Users/t-watanabe/work/XXX/XXX/Carthage/Build/iOS/SVProgressHUD.framework/" UserInfo={NSLocalizedDescription=Cannot retrive binary file from bundle at file:///Users/t-watanabe/work/XXX/XXX/Carthage/Build/iOS/SVProgressHUD.framework/, NSLocalizedRecoverySuggestion=Does the bundle contain an Info.plist?}
Showing Recent Issues
Failed to read file or folder at /Users/t-watanabe/work/XXX/XXX/Carthage/Build/iOS/SVProgressHUD.framework: Error Domain=NSCocoaErrorDomain Code=259 "Cannot retrive binary file from bundle at file:///Users/t-watanabe/work/XXX/XXX/Carthage/Build/iOS/SVProgressHUD.framework/" UserInfo={NSLocalizedDescription=Cannot retrive binary file from bundle at file:///Users/t-watanabe/work/XXX/XXX/Carthage/Build/iOS/SVProgressHUD.framework/, NSLocalizedRecoverySuggestion=Does the bundle contain an Info.plist?}

carthage bootstrap --use-xcframeworks --platform iOS 違うか。

Build Phasesからcarthageを葬ってみた。起動するようになった