Flutter:命令 PhaseScriptExecution 失败且没有错误

时间:2021-07-19 09:13:16

标签: ios xcode firebase flutter

我有一个正在生产的 Flutter 应用程序,我们正在尝试从 Flutter 1.x 迁移到 2.x。在此过程中,我们遇到了在 ios 中构建的奇怪错误。我们能够通过更新依赖项来修复其中的很大一部分,但我们仍然遇到这个奇怪的问题。最糟糕的是,它似乎只是警告,所以我们有点迷失了。完整的日志可以在 here:

找到
    Failed to build iOS app
    Error output from Xcode build:
    ↳
        ** BUILD FAILED **
    
    
    Xcode's output:
    ↳
        ../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_local_notifications-6.0.0/ios/Classes/FlutterLocalNotificationsPlugin.m:13:5: warning: 'UILocalNotification' is deprecated: first deprecated in iOS 10.0 - Use UserNotifications Framework's UNNotificationRequest [-Wdeprecated-declarations]
            UILocalNotification *_launchNotification;
            ^
        In module 'UIKit' imported from ../app/app/ios/Pods/Target Support Files/flutter_local_notifications/flutter_local_notifications-prefix.pch:2:
        /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/System/Library/Frameworks/UIKit.framework/Headers/UILocalNotification.h:18:12: note: 'UILocalNotification' has been explicitly marked deprecated here
        @interface UILocalNotification : NSObject<NSCopying, NSCoding>
                   ^
        ../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_local_notifications-6.0.0/ios/Classes/FlutterLocalNotificationsPlugin.m:293:4: warning: 'UILocalNotification' is deprecated: first deprecated in iOS 10.0 - Use UserNotifications Framework's UNNotificationRequest [-Wdeprecated-declarations]
        - (UILocalNotification *)buildStandardUILocalNotification:(NSDictionary *)arguments {
           ^
        In module 'UIKit' imported from ../app/app/ios/Pods/Target Support Files/flutter_local_notifications/flutter_local_notifications-prefix.pch:2:
        /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/System/Library/Frameworks/UIKit.framework/Headers/UILocalNotification.h:18:12: note: 'UILocalNotification' has been explicitly marked deprecated here
        @interface UILocalNotification : NSObject<NSCopying, NSCoding>
                   ^
        ../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_local_notifications-6.0.0/ios/Classes/FlutterLocalNotificationsPlugin.m:752:30: warning: 'UILocalNotification' is deprecated: first deprecated in iOS 10.0 - Use UserNotifications Framework's UNNotificationRequest [-Wdeprecated-declarations]
        didReceiveLocalNotification:(UILocalNotification*)notification {
                                     ^
        In module 'UIKit' imported from ../app/app/ios/Pods/Target Support Files/flutter_local_notifications/flutter_local_notifications-prefix.pch:2:
        /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/System/Library/Frameworks/UIKit.framework/Headers/UILocalNotification.h:18:12: note: 'UILocalNotification' has been explicitly marked deprecated here
        @interface UILocalNotification : NSObject<NSCopying, NSCoding>
                   ^
        ../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_local_notifications-6.0.0/ios/Classes/FlutterLocalNotificationsPlugin.m:182:64: warning: 'scheduledLocalNotifications' is deprecated: first deprecated in iOS 10.0 - Use UserNotifications Framework's -[UNUserNotificationCenter getPendingNotificationRequestsWithCompletionHandler:] [-Wdeprecated-declarations]
            NSArray *notifications = [UIApplication sharedApplication].scheduledLocalNotifications;
                                                                       ^
        In module 'UIKit' imported from ../app/app/ios/Pods/Target Support Files/flutter_local_notifications/flutter_local_notifications-prefix.pch:2:
        /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:242:68: note: 'scheduledLocalNotifications' has been explicitly marked deprecated here
        @property(nullable,nonatomic,copy) NSArray<UILocalNotification *> *scheduledLocalNotifications API_DEPRECATED("Use UserNotifications Framework's -[UNUserNotificationCenter getPendingNotificationRequestsWithCompletionHandler:]", ios
 ....
        ../app/app/ios/Pods/FirebaseStorage/FirebaseStorage/Sources/FIRStorageDownloadTask.m:171:23: warning: 'waitForCompletionWithTimeout:' is deprecated: Use XCTestExpectation instead [-Wdeprecated-declarations]
            [weakSelf.fetcher waitForCompletionWithTimeout:0.001];
                              ^
        In module 'GTMSessionFetcher' imported from ../app/app/ios/Pods/FirebaseStorage/FirebaseStorage/Sources/FIRStorageTask_Private.h:29:
        ../app/app/ios/Pods/GTMSessionFetcher/Source/GTMSessionFetcher.h:1164:5: note: 'waitForCompletionWithTimeout:' has been explicitly marked deprecated here
            __deprecated_msg("Use XCTestExpectation instead");
            ^
        In module 'Foundation' imported from ../app/app/ios/Pods/FirebaseStorage/FirebaseStorage/Sources/Public/FirebaseStorage/FIRStorageDownloadTask.h:17:
        In module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:
        In module 'Darwin' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16:
        /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/usr/include/sys/cdefs.h:200:48: note: expanded from macro '__deprecated_msg'
                #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
                                                              ^
        1 warning generated.
        ../app/app/ios/Pods/FirebaseDynamicLinks/FirebaseDynamicLinks/Sources/FIRDLJavaScriptExecutor.m:158:12: warning: unused function 'processIsTranslated' [-Wunused-function]
        static int processIsTranslated() {
                   ^
        1 warning generated.
    
        Command PhaseScriptExecution failed with a nonzero exit code
        note: Using new build system
        note: Building targets in parallel
        note: Planning build
        note: Analyzing workspace
        note: Constructing build description
        note: Build preparation complete

Podfile 如下:

# Uncomment this line to define a global platform for your project
platform :ios, '10.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
    installer.pods_project.targets.each do |target|
       flutter_additional_ios_build_settings(target)
       target.build_configurations.each do |config|
            config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
       end
    end
  end

我们现在有点受不了了。对可能发生的事情有任何想法吗?有人遇到过同样的错误吗?

更新:2021-07-19 - 1

更深入地看,我进入 xcode_backend.sh 失败,运行退出代码为 1 的 flutter 命令。命令如下:

flutter assemble --no-version-check --output=<path>/app/app/build/ios/Debug-dev-iphoneos/ \
-dTargetPlatform=ios \
-dTargetFile=<path>/app/app/lib/main_dev.dart \
-dBuildMode=debug \
-dIosArchs=arm64 \
-dSdkRoot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk \
-dSplitDebugInfo= \
-dTreeShakeIcons=false \
-dTrackWidgetCreation=true \
-dDartObfuscation=false \
-dEnableBitcode= \
-dCodesignIdentity=xxxx \
--ExtraGenSnapshotOptions= \
--DartDefines=xx,xx \
--ExtraFrontEndOptions= \
debug_ios_bundle_flutter_assets

1 个答案:

答案 0 :(得分:0)

我找到了解决此问题的方法。 Flutter 2.0 在 ios 方面有一些突破性的变化,从这个意义上说,默认的调试功能真的很糟糕。确保在构建期间 (here) 在 xcode_backend.sh 中启用了详细信息。

更具体地说明我的错误,flutter assemble 返回了这个错误:

Target debug_ios_bundle_flutter_assets failed: FileSystemException: Cannot open file, path = '<path>/app/app/ios/Flutter/AppFrameworkInfo.plist' (OS Error: No such file or directory, errno = 2)

只需添加 AppFrameworkInfo.plist 即可:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>CFBundleDevelopmentRegion</key>
  <string>en</string>
  <key>CFBundleExecutable</key>
  <string>App</string>
  <key>CFBundleIdentifier</key>
  <string>io.flutter.flutter.app</string>
  <key>CFBundleInfoDictionaryVersion</key>
  <string>6.0</string>
  <key>CFBundleName</key>
  <string>App</string>
  <key>CFBundlePackageType</key>
  <string>FMWK</string>
  <key>CFBundleShortVersionString</key>
  <string>1.0</string>
  <key>CFBundleSignature</key>
  <string>????</string>
  <key>CFBundleVersion</key>
  <string>1.0</string>
  <key>MinimumOSVersion</key>
  <string>8.0</string>
</dict>
</plist>

无论如何,推荐的方法是删除您的 ios 文件夹(或在迁移期间将其移动到 ios.old)并在运行 flutter create -i swift 时重新创建它。