Skip to content

Fix compile error: use correct HapticEngine.play() and SoundEngine.play() methods#1

Open
madebyshaurya wants to merge 1 commit into
DAWNCR0W:mainfrom
madebyshaurya:main
Open

Fix compile error: use correct HapticEngine.play() and SoundEngine.play() methods#1
madebyshaurya wants to merge 1 commit into
DAWNCR0W:mainfrom
madebyshaurya:main

Conversation

@madebyshaurya

Copy link
Copy Markdown

Problem

View+MicroInteractions.swift calls methods that don't exist:

  • HapticEngine.shared.generateFeedback(for:)
  • SoundEngine.shared.playSound(for:)

This causes a compile error when integrating via SPM:

error: value of type 'HapticEngine' has no member 'generateFeedback'

Fix

The correct APIs (defined in HapticEngine.swift and SoundEngine.swift) are:

  • HapticEngine.shared.play(_ style: HapticStyle)
  • SoundEngine.shared.play(_ style: SoundStyle)

Added a playFeedback(for:) helper that extracts the haptic/sound styles from the interaction's feedbackType and calls the correct methods. Handles .combined feedback types recursively.

Testing

Verified the fix compiles successfully in an iOS 18.0+ project using SPM.

View+MicroInteractions.swift called HapticEngine.shared.generateFeedback(for:)
and SoundEngine.shared.playSound(for:), but these methods don't exist.

The correct APIs are HapticEngine.shared.play(_:) and SoundEngine.shared.play(_:).

This caused a compile error when integrating via SPM:
  error: value of type 'HapticEngine' has no member 'generateFeedback'

Fixed by extracting haptic/sound styles from the interaction's feedbackType
and calling the correct play() methods.
madebyshaurya added a commit to madebyshaurya/SpendSmart that referenced this pull request Mar 25, 2026
Fixed the library's compile error (HapticEngine.generateFeedback doesn't exist,
should be HapticEngine.play). Using our fork at madebyshaurya/SwiftMicroInteractions.
PR submitted to upstream: DAWNCR0W/SwiftMicroInteractions#1

Applied .microInteraction(.toggle) to batch mode toggle.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant