1. 创建iOS工程
这里命名为ios_demo
2. 创建flutter模块
# flutter_module为你的flutter模块名称
flutter create -t module flutter_module
3. 使用pod集成
在你的iOS工程所在目录中运行命令
pod init
修改podfile文件如下
# platform :ios, '9.0'
flutter_application_path = '../flutter_module'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
target 'ios_demo' do
frameworks
use_frameworks!
install_all_flutter_pods(flutter_application_path)
end
运行命令
pod install
over, 大功告成...个屁!!!
问题:
报错Command PhaseScriptExecution failed with a nonzero exit code
。 每个人遇到的错误可能不一样吧,我这里主要是由于flutter_module
中一个home_page.dart
文件中有一行import 'dart:html';
......
错误日志如下:
......
sent 590309570 bytes received 976 bytes 131180121.33 bytes/sec
total size is 590234407 speedup is 1.00
♦ /usr/local/flutter/bin/flutter --verbose assemble --no-version-check --output=/Users/daniel/Library/Developer/Xcode/DerivedData/fgDemo-ctgucodwhntinfakmmyffunqmapo/Build/Products/Release-iphoneos/ -dTargetPlatform=ios -dTargetFile=/Users/daniel/Desktop/flu_demo/flutter_boost_demo/flutter_module/lib/main.dart -dBuildMode=release -dIosArchs=arm64 armv7 -dSdkRoot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.0.sdk -dSplitDebugInfo= -dTreeShakeIcons=false -dTrackWidgetCreation=true -dDartObfuscation=false -dEnableBitcode= --ExtraGenSnapshotOptions= --DartDefines=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ== --ExtraFrontEndOptions= -dCodesignIdentity=65105A839D1728BE03EABBEC7EC4682E5AF9E797 release_ios_bundle_flutter_assets
[ +164 ms] executing: sysctl hw.optional.arm64
[ +30 ms] Exit code 1 from: sysctl hw.optional.arm64
[ ] sysctl: unknown oid 'hw.optional.arm64'
[ +7 ms] executing: [/usr/local/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[ +8 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[ ] cd41fdd495f6944ecd3506c21e94c6567b073278
[ +1 ms] executing: [/usr/local/flutter/] git tag --points-at cd41fdd495f6944ecd3506c21e94c6567b073278
[ +35 ms] Exit code 0 from: git tag --points-at cd41fdd495f6944ecd3506c21e94c6567b073278
[ ] 3.0.2
[ +12 ms] executing: [/usr/local/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[ +12 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[ ] origin/stable
[ ] executing: [/usr/local/flutter/] git ls-remote --get-url origin
[ +9 ms] Exit code 0 from: git ls-remote --get-url origin
[ ] https://github.com/flutter/flutter.git
[ +102 ms] executing: [/usr/local/flutter/] git rev-parse --abbrev-ref HEAD
[ +8 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[ ] stable
[ +7 ms] executing: sw_vers -productName
[ +27 ms] Exit code 0 from: sw_vers -productName
[ ] macOS
[ ] executing: sw_vers -productVersion
[ +17 ms] Exit code 0 from: sw_vers -productVersion
[ ] 12.0.1
[ ] executing: sw_vers -buildVersion
[ +16 ms] Exit code 0 from: sw_vers -buildVersion
[ ] 21A559
[ ] executing: uname -m
[ +7 ms] Exit code 0 from: uname -m
[ ] x86_64
[ +72 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ +3 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +130 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[ ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[ ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ +3 ms] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[ ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'PubDependencies' is not required, skipping update.
[ +65 ms] Initializing file store
[ +1 ms] Done initializing file store
[ +180 ms] Skipping target: release_unpack_ios
[ +2 ms] Skipping target: gen_localizations
[ +4 ms] Skipping target: gen_dart_plugin_registrant
[ +2 ms] kernel_snapshot: Starting due to {InvalidatedReasonKind.inputChanged: The following inputs have updated contents: /usr/local/flutter/packages/flutter_tools/lib/src/build_system/targets/common.dart}
[ +15 ms] /usr/local/flutter/bin/cache/dart-sdk/bin/dart --disable-dart-dev /usr/local/flutter/bin/cache/dart-sdk/bin/snapshots/frontend_server.dart.snapshot --sdk-root /usr/local/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk_product/ --target=flutter --no-print-incremental-dependencies -DFLUTTER_WEB_AUTO_DETECT=true -Ddart.vm.profile=false -Ddart.vm.product=true --aot --tfa --packages /Users/daniel/Desktop/flu_demo/flutter_boost_demo/flutter_module/.dart_tool/package_config.json --output-dill /Users/daniel/Desktop/flu_demo/flutter_boost_demo/flutter_module/.dart_tool/flutter_build/7e97fb4c1e3c14d6450d8ac1e70bf271/app.dill --depfile /Users/daniel/Desktop/flu_demo/flutter_boost_demo/flutter_module/.dart_tool/flutter_build/7e97fb4c1e3c14d6450d8ac1e70bf271/kernel_snapshot.d package:flutter_module/main.dart
[ +82 ms] Persisting file store
[ +3 ms] Done persisting file store
[ +18 ms] "flutter assemble" took 12,661ms.
[ +171 ms] ensureAnalyticsSent: 170ms
[ +1 ms] Running shutdown hooks
[ ] Shutdown hooks complete
[ ] exiting with code 1
[ +18 ms] Invalid depfile: /Users/daniel/Desktop/flu_demo/flutter_boost_demo/flutter_module/.dart_tool/flutter_build/7e97fb4c1e3c14d6450d8ac1e70bf271/kernel_snapshot.d
[ +2 ms] Invalid depfile: /Users/daniel/Desktop/flu_demo/flutter_boost_demo/flutter_module/.dart_tool/flutter_build/7e97fb4c1e3c14d6450d8ac1e70bf271/kernel_snapshot.d
[ +709 ms] lib/home_page.dart:1:8: Error: Not found: 'dart:html'
[ ] import 'dart:html';
[ ] ^
[+4545 ms] /usr/local/flutter/.pub-cache/git/flutter_boost-947104a1055f3136203ddd4ef68bc2b728436738/lib/src/boost_flutter_binding.dart:30:26: Warning: Operand of null-aware operation '!' has type 'SchedulerBinding' which excludes null.
[ ] - 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('/usr/local/flutter/packages/flutter/lib/src/scheduler/binding.dart').
[ ] if (SchedulerBinding.instance!.lifecycleState == state) {
[ ] ^
[ +12 ms] /usr/local/flutter/.pub-cache/git/flutter_boost-947104a1055f3136203ddd4ef68bc2b728436738/lib/src/flutter_boost_app.dart:99:20: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
[ ] - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/usr/local/flutter/packages/flutter/lib/src/widgets/binding.dart').
[ ] WidgetsBinding.instance!.addPostFrameCallback((_) {
[ ] ^
[ ] /usr/local/flutter/.pub-cache/git/flutter_boost-947104a1055f3136203ddd4ef68bc2b728436738/lib/src/flutter_boost_app.dart:173:53: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
[ ] - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/usr/local/flutter/packages/flutter/lib/src/widgets/binding.dart').
[ ] _activePointers.toList().forEach(WidgetsBinding.instance!.cancelPointer);
[ ] ^
[ +14 ms] /usr/local/flutter/.pub-cache/git/flutter_boost-947104a1055f3136203ddd4ef68bc2b728436738/lib/src/page_visibility.dart:124:20: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
[ ] - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/usr/local/flutter/packages/flutter/lib/src/widgets/binding.dart').
[ ] WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
[ ] ^
[+1295 ms] /usr/local/flutter/.pub-cache/git/flutter_boost-947104a1055f3136203ddd4ef68bc2b728436738/lib/src/container_overlay.dart:107:28: Warning: Operand of null-aware operation '!' has type 'SchedulerBinding' which excludes null.
[ ] - 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('/usr/local/flutter/packages/flutter/lib/src/scheduler/binding.dart').
[ ] SchedulerBinding.instance!.scheduleWarmUpFrame();
[ ] ^
[+5509 ms] Unhandled exception:
FileSystemException(uri=org-dartlang-untranslatable-uri:dart%3Ahtml; message=StandardFileSystem only supports file:* and data:* URIs)
#0 StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:34:7)
#1 asFileUri (package:vm/kernel_front_end.dart:652:37)
#2 writeDepfile (package:vm/kernel_front_end.dart:792:21)
<asynchronous suspension>
#3 FrontendCompiler.compile (file:///opt/s/w/ir/cache/builder/sdk/pkg/frontend_server/lib/frontend_server.dart:615:9)
<asynchronous suspension>
#4 starter (file:///opt/s/w/ir/cache/builder/sdk/pkg/frontend_server/lib/frontend_server.dart:1433:12)
<asynchronous suspension>
#5 main (file:///opt/s/w/ir/cache/builder/sdk/pkg/frontend_server/bin/frontend_server_starter.dart:10:14)
<asynchronous suspension>
[ +2 ms] Target kernel_snapshot failed: Exception
#0 KernelSnapshot.build (package:flutter_tools/src/build_system/targets/common.dart:241:7)
<asynchronous suspension>
#1 _BuildInstance._invokeInternal (package:flutter_tools/src/build_system/build_system.dart:839:9)
<asynchronous suspension>
#2 Future.wait.<anonymous closure> (dart:async/future.dart:521:21)
<asynchronous suspension>
#3 _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:777:32)
<asynchronous suspension>
#4 Future.wait.<anonymous closure> (dart:async/future.dart:521:21)
<asynchronous suspension>
#5 _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:777:32)
<asynchronous suspension>
#6 FlutterBuildSystem.build (package:flutter_tools/src/build_system/build_system.dart:606:16)
<asynchronous suspension>
#7 AssembleCommand.runCommand (package:flutter_tools/src/commands/assemble.dart:320:32)
<asynchronous suspension>
#8 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1183:27)
<asynchronous suspension>
#9 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#10 CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#11 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9)
<asynchronous suspension>
#12 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#13 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
<asynchronous suspension>
#14 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
<asynchronous suspension>
#15 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#16 main (package:flutter_tools/executable.dart:94:3)
<asynchronous suspension>
[ +5 ms]
#0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1 AssembleCommand.runCommand (package:flutter_tools/src/commands/assemble.dart:337:7)
<asynchronous suspension>
#2 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1183:27)
<asynchronous suspension>
#3 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#4 CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#5 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9)
<asynchronous suspension>
#6 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#7 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
<asynchronous suspension>
#8 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
<asynchronous suspension>
#9 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#10 main (package:flutter_tools/executable.dart:94:3)
<asynchronous suspension>
Failed to package /Users/daniel/Desktop/flu_demo/flutter_boost_demo/flutter_module.
Command PhaseScriptExecution failed with a nonzero exit code
期间我修改过Run script for install builds only
,Edit Scheme -> Build Configuration
,Workspace Settings -> Build System
。然后就报其他错误。
其他:
集成完毕,需要修改flutter_module
的main.dart
,同时也需要在iOS工程中做一些处理,这里参考官方文档就可以:
https://github.com/alibaba/flutter_boost/blob/master/docs/install.md
网友评论