.cursor/skills/swift-integration-patterns/SKILL.md
--- name: swift-integration-patterns description: Guides Swift integration patterns: platform channels, method channels, async callbacks, native iOS features. Use when implementing iOS-specific features, native platform channels, or Swift code integration. --- # Swift Integration Patterns ## Core Purpose Swift integration enables Flutter apps to use iOS-specific features via platform channels. ## Method Channel Pattern ### Swift Side ```swift import Flutter import UIKit public class SwiftM
npx skillsauth add avra-cadavra/avrai .cursor/skills/swift-integration-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Swift integration enables Flutter apps to use iOS-specific features via platform channels.
import Flutter
import UIKit
public class SwiftMethodChannelHandler: NSObject, FlutterPlugin {
public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(
name: "com.avrai.app/methods",
binaryMessenger: registrar.messenger()
)
let instance = SwiftMethodChannelHandler()
registrar.addMethodCallDelegate(instance, channel: channel)
}
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method {
case "getPlatformVersion":
result("iOS " + UIDevice.current.systemVersion)
case "performNativeOperation":
performNativeOperation(arguments: call.arguments, result: result)
default:
result(FlutterMethodNotImplemented)
}
}
private func performNativeOperation(arguments: Any?, result: @escaping FlutterResult) {
// Perform native iOS operation
// Call result handler when complete
result("Operation completed")
}
}
import 'package:flutter/services.dart';
class PlatformChannelService {
static const MethodChannel _channel = MethodChannel('com.avrai.app/methods');
Future<String> getPlatformVersion() async {
try {
final String version = await _channel.invokeMethod('getPlatformVersion');
return version;
} on PlatformException catch (e) {
developer.log('Platform version error: ${e.message}');
return 'Unknown';
}
}
Future<String> performNativeOperation(Map<String, dynamic> params) async {
try {
final String result = await _channel.invokeMethod(
'performNativeOperation',
params,
);
return result;
} on PlatformException catch (e) {
developer.log('Operation error: ${e.message}');
rethrow;
}
}
}
public class SwiftEventChannelHandler: NSObject, FlutterStreamHandler {
private var eventSink: FlutterEventSink?
public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterEventChannel(
name: "com.avrai.app/events",
binaryMessenger: registrar.messenger()
)
let handler = SwiftEventChannelHandler()
channel.setStreamHandler(handler)
}
public func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? {
self.eventSink = events
startListening()
return nil
}
public func onCancel(withArguments arguments: Any?) -> FlutterError? {
eventSink = nil
stopListening()
return nil
}
private func startListening() {
// Start native iOS listener
// Send events via eventSink
eventSink?("Event data")
}
}
import 'package:flutter/services.dart';
class EventChannelService {
static const EventChannel _channel = EventChannel('com.avrai.app/events');
Stream<String> get events {
return _channel.receiveBroadcastStream().cast<String>();
}
}
// Handle async operations
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method {
case "asyncOperation":
performAsyncOperation(result: result)
default:
result(FlutterMethodNotImplemented)
}
}
private func performAsyncOperation(result: @escaping FlutterResult) {
DispatchQueue.global().async {
// Perform async work
let resultData = performWork()
DispatchQueue.main.async {
// Return result on main thread
result(resultData)
}
}
}
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
do {
let resultData = try performOperation()
result(resultData)
} catch let error {
result(FlutterError(
code: "OPERATION_ERROR",
message: error.localizedDescription,
details: nil
))
}
}
ios/Runner/AppDelegate.swift - iOS app delegatedevelopment
--- name: world-model-development description: Guides world model development patterns: state/action encoders, ONNX inference, feature extraction pipeline, latency budgets. Use when implementing world model components, state encoders, action encoders, feature extractors, or ONNX models. Core skill for Phases 3-6. --- # World Model Development Patterns ## Core Principle All world model components follow LeCun's autonomous machine intelligence framework. State observations flow through a percep
tools
Implements base workflow controller patterns for multi-step processes. Use when creating complex workflows that require orchestration of multiple steps with error handling and rollback.
testing
--- name: widget-test-patterns description: Guides widget test patterns: BLoC testing, user interactions, state changes, material app setup. Use when writing widget tests, testing UI components, or validating widget behavior. --- # Widget Test Patterns ## Core Pattern Widget tests verify UI behavior: user interactions, state changes, and visual display. ## Basic Widget Test Setup ```dart testWidgets('widget displays correctly', (WidgetTester tester) async { // Arrange: Create widget awa
testing
--- name: test-template-generation description: Generates test templates: unit, widget, integration, service tests following project patterns. Use when creating new tests or ensuring tests follow project standards. --- # Test Template Generation ## Available Templates Test templates are located in `test/templates/`: - `unit_test_template.dart` - `widget_test_template.dart` - `integration_test_template.dart` - `service_test_template.dart` ## Unit Test Template ```dart /// SPOTS Component Uni