尝试在 flutter 中添加按钮点击振动,它适用于 Android。但在 iOS 中它无法编译并出现以下错误
GeneratedPluginRegistrant.m:6:9: fatal error: 'vibrate/VibratePlugin.h' file not found
我正在按照此处所述的确切步骤进行操作。
https://pub.dartlang.org/packages/vibrate#-installing-tab-
这是 Xcode 构建输出:
Launching lib/main.dart on ###'s iPhone in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: #####
Running pod install...
Running Xcode build...
Xcode build done. 13.1s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test your code with “Use of deprecated Swift 3 @objc inference” logging enabled, and then disable inference by changing the "Swift 3 @objc Inference" build setting to "Default" for the "Runner" target.
The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test your code with “Use of deprecated Swift 3 @objc inference” logging enabled, and then disable inference by changing the "Swift 3 @objc Inference" build setting to "Default" for the "Runner" target.
/Users/####/Flutter_Projects/project_####l/ios/Runner/GeneratedPluginRegistrant.m:6:9: fatal error: 'vibrate/VibratePlugin.h' file not found
#import <vibrate/VibratePlugin.h>
^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
无法为设备构建预编译的应用程序。
最佳答案
我在为 iOS 构建我的 flutter 应用程序时遇到了同样的问题,并找到了这个链接为我解决了这个问题。
https://github.com/benjamindean/flutter_vibration/issues/1
我认为答案是编辑你的 .../appname/ios/Podfile
转到以下部分:
target 'Runner' do
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')
# Flutter Pods
并添加“use_frameworks!”在“目标‘运行者’做”下像这样:
target 'Runner' do
use_frameworks!
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')
# Flutter Pods
关于ios - Flutter 包振动 0.0.4 在 iOS 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54530383/