Skip to content

Instantly share code, notes, and snippets.

View kishikawakatsumi's full-sized avatar
🏠
Working from home

Kishikawa Katsumi kishikawakatsumi

🏠
Working from home
View GitHub Profile
@kishikawakatsumi
kishikawakatsumi / gist:1d2359eb95c7ace3c3da8d73889e9dcc
Last active July 11, 2025 03:43
[FB18768055]Tool calling is not called.
I am trying tool calling in FoundationModels with the following code. When given the prompt “Schedule a meeting for next Wednesday at 10 a.m.”, tool calling is not called, and an unexpected response is returned. The response is "Please provide the name of the calendar where the event should be created.".
When the prompt is “Add a meeting to the schedule for next Wednesday at 10:00 a.m.”, the tool is called (although the parameters are incorrect).
import Cocoa
import FoundationModels
import EventKit
@main
@kishikawakatsumi
kishikawakatsumi / gist:c07e5ecc2d0811cd8b530d0fb7e2bd01
Last active July 11, 2025 03:11
[FB18767141] The argument (date) passed to tool calling is incorrect.
I am trying tool calling with the following code. When I give the prompt “Add a meeting to the schedule for next Wednesday at 10:00 a.m.”, the CalendarTool is called, but the date argument passed is incorrect. Since I am expecting next Wednesday, the expected behavior is for it to return “Jul 15th, 2025,” but it returns “2024-10-23T10:00:00.”
Also attach the actual project.
```swift
import Cocoa
import FoundationModels
import EventKit
@main
@kishikawakatsumi
kishikawakatsumi / FB17986874
Created June 12, 2025 16:25
When the deployment target is iOS 16, NWConnection init crashes on the simulator.
When the following code is executed in a project with the deployment target set to iOS 16, the `init` function of `NWConnection` crashes.
This issue only occurs on the iOS 26 simulator. There is no problem on the device.
```swift
import UIKit
import Network
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
@kishikawakatsumi
kishikawakatsumi / DisableFloatingTabBar.swift
Created February 9, 2025 02:25
Revert the floating style tab bar introduced in iOS 18 back to its pre-IOS 17 appearance.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UserDefaults.standard.register(defaults: [
"UseFloatingTabBar": false,
])
return true
}
@kishikawakatsumi
kishikawakatsumi / gist:079f800561869c386e7702048b7580e1
Last active January 16, 2025 12:40
applelocalization.com に対するデータ追加更新の手順
** 概要
applelocalization-toolsでシステムの言語ファイルを読み取り、applelocalization-dataのデータを作る。
追加したデータを表示できるようにWebフロントエンド(エンドポイントやドロップダウンメニューを追加する)を修正する。
*** 手順 1〜11
- github.com/kishikawakatsumi/applelocalization-tools
- システムに含まれる言語ファイルを読み取りDBの1レコード単位に整形したJSONファイルを作る
- JSONファイルからDBにインポートできるデータを作る。
import Foundation
/// Calculates the `n`th Fibonacci number
///
/// This function returns `0` for all negative numbers.
func fib(_ n: Int) -> Int {
guard n > 0 else {
return 0
}
@kishikawakatsumi
kishikawakatsumi / gist:d8d6543eceaeeeaf36394f29897d9a2e
Created August 18, 2023 00:50
「モバイル・エコシステムに関する競争評価 最終報告」に対する意見募集
政府が民間の自由な経済活動への介入は原則として慎重であるべきです。報告書で述べられているApp Storeの問題点は政府が規制や介入をしなければならないほどの解決困難であったり多数の被害者が発生しているようなものではありません。
1.OSやブラウザ等の仕様変更等について
大規模なソフトウェア製品における本質的な問題です。規制を設けたところで解決する問題ではありません。
報告書ではAppleが必要な情報を適切に提供していないという指摘があるが、これは正しくなく、過去と比較して現在の情報公開の状況は大きく改善されています。
ベータ版についての情報についても、10年前はWWDCの情報は参加者のみがアクセスできましたが、現在はデベロッパーアカウントがあればすべて閲覧可能になっています。デベロッパーアカウントも有料のデベロッパープログラムは必要なく、Apple IDがあればよいので、事実上すべての人間に情報は開示されています。
ベータ版が安定するまでに長い時間がかかり対応する時間が限られているという指摘については先に述べたとおりソフトウェアの本質的な問題です。モバイルデバイスのOSははるかに複雑になっておりむしろ毎年新機能や改善が行われているということは驚愕すべきことです。
@kishikawakatsumi
kishikawakatsumi / FB12646222
Created July 17, 2023 09:34
[SwiftData] Compiler cannot reject models containing types that cannot be saved.
SwiftData raises a runtime error when attempting to save a property of CGFloat type, but the compiler cannot validate it.
Models with properties of type CGFloat, such as the example below, cannot be saved in SwiftData. It will cause a run-time error.
I believe that the compiler should reject such incorrect models. However, such models cannot be made an error at compile-time, so the following documentation statement that SwiftData can safely describe the model layer is highly questionable.
> Using modern language features like macros, SwiftData enables you to write code that is fast, efficient, and safe, enabling you to describe the entire model layer (or object graph) for your app.
```swift
@Model
@kishikawakatsumi
kishikawakatsumi / FB12645750
Created July 17, 2023 08:34
Writing the correct code when persisting models containing associations is very difficult
If the incorrect code is written when attempting to persist a model containing associations, either run-time errors occur or only the associations are not saved (although they appear to be saved correctly).
The latter makes it very difficult to find the problem, as it appears to be working correctly without any errors.
Of the four code examples below, only the first one saves the data correctly, including the association.
All of the remaining three cases do not work correctly.
The important thing is to insert the association source object into the context first.
Otherwise, you will get either a run-time error or the unexpected behaviour that only the related objects are not saved.
```swift
@kishikawakatsumi
kishikawakatsumi / FB12645485
Created July 17, 2023 07:56
[SwiftData] Classes qualified with @model macro allow incomplete initializers
Classes qualified with @Model macro allow incomplete initializers
The compiler does not throw an error if a class with @Model, as in the following code, implements only an incomplete initializer (in this example, the properties are not initialized at all).
This would normally (if the plain class is not macro qualified) result in a compile error "Return from initializer without initializing all stored properties".
```swift
import SwiftData
@Model
final class Event {