1、现象
Running "flutter pub get" in ***... 475ms
Running pod install... 1,493ms
ld: warning: ignoring file /Users/lucky/Documents/Laboratory/Flutter/Sdk/flutter_macos_1.22.4-stable/bin/cache/artifacts/engine/darwin-x64-release/FlutterMacOS.framework/FlutterMacOS, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
"_FlutterMethodNotImplemented", referenced from:
url_launcher_macos.UrlLauncherPlugin.handle(_: __C.FlutterMethodCall, result: (Any?) -> ()) -> () in UrlLauncherPlugin.o
function signature specialization <Arg[1] = Dead, Arg[2] = Owned To Guaranteed> of function signature specialization <Arg[1] = [Closure Propagated : reabstraction thunk helper from @escaping @callee_unowned @convention(block) (@unowned Swift.Optional<Swift.AnyObject>) -> () to @escaping @callee_guaranteed (@in_guaranteed Swift.Optional<Any>) -> (), Argument Types : [@escaping @callee_unowned @convention(block) (@unowned Swift.AnyObject?) -> ()]> of url_launcher_macos.UrlLauncherPlugin.handle(_: __C.FlutterMethodCall, result: (Any?) -> ()) -> () in UrlLauncherPlugin.o
"_OBJC_CLASS_$_FlutterError", referenced from:
objc-class-ref in UrlLauncherPlugin.o
"_OBJC_CLASS_$_FlutterMethodChannel", referenced from:
objc-class-ref in UrlLauncherPlugin.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
** BUILD FAILED **
Building macOS application...
Build process failed
2、原因
Xcode Release方式打包的限制。
3、解决
打开XCODE,在Runner和Pods上都设置“ONLY_ACTIVE_ARCH=YES”(如下图所示)。
image.png
image.png
之后再使用命令“flutter build macos”打包编译成功!
网友评论