LoginSignup
0
0

More than 1 year has passed since last update.

【Flutter】Swift Compiler Error (Xcode): Cannot find 'GeneratedPluginRegistrant' in scopeを解決する

Last updated at Posted at 2022-06-28

flutter build iosで謎のエラーが出るようになってしまった・・・

$ flutter build ios          


(中略)

Failed to build iOS app
Error output from Xcode build:
↳
    2022-06-28 17:54:50.481 xcodebuild[72631:2386405] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in
    com.apple.dt.IDEWatchSupportCore
    2022-06-28 17:54:50.481 xcodebuild[72631:2386405] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension
    Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
    ** BUILD FAILED **


Xcode's output:
↳
    Writing result bundle at path:
    	/var/folders/jp/36fbdpc50c10dxrdtz8rfbmm0000gn/T/flutter_tools.3cgI0T/flutter_ios_build_temp_dirNBCp9k/temporary_xcresult_bundle

    /Users/atomu/Desktop/GitHub/project/ios/Runner/AppDelegate.swift:17:5: error: cannot find 'GeneratedPluginRegistrant' in scope
        GeneratedPluginRegistrant.register(with: self)
        ^~~~~~~~~~~~~~~~~~~~~~~~~
    remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
    Command CompileSwiftSources failed with a nonzero exit code
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order
    /Users/atomu/Desktop/GitHub/project/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.5.99. (in target
    'MTBBarcodeScanner' from project 'Pods')
    /Users/atomu/Desktop/GitHub/project/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.5.99. (in target
    'CardIO' from project 'Pods')
    /Users/atomu/Desktop/GitHub/project/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.5.99. (in target
    'DeployGateSDK-framework' from project 'Pods')

    Result bundle written to path:
    	/var/folders/jp/36fbdpc50c10dxrdtz8rfbmm0000gn/T/flutter_tools.3cgI0T/flutter_ios_build_temp_dirNBCp9k/temporary_xcresult_bundle


Uncategorized (Xcode): Command CompileSwiftSources failed with a nonzero exit code


Swift Compiler Error (Xcode): Cannot find 'GeneratedPluginRegistrant' in scope
/Users/atomu/Desktop/GitHub/project/ios/Runner/AppDelegate.swift:16:4


Encountered error while building for device.

AppDelegate.swift
import UIKit
import Flutter
import GoogleMaps

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    // deploygate
    DeployGateSDK
      .sharedInstance()
      .launchApplication(withAuthor: "my-group", key: "01234567890123456789")

    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

どうやらGeneratedPluginRegistrantが見つからないらしい。なにそれ。。。

環境

$ flutter --version

Flutter 3.0.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 676cefaaff (6 days ago) • 2022-06-22 11:34:49 -0700
Engine • revision ffe7b86a1e
Tools • Dart 2.17.5 • DevTools 2.12.2

対応案その1

どうせキャッシュとかのせいだろうといつものおまじないみたいなコマンドを投入

$ flutter clean
$ rm -Rf ios/Pods
$ rm -Rf ios/.symlinks
$ rm -Rf ios/Flutter/Flutter.framework
$ rm -Rf ios/Flutter/Flutter.podspec
$ rm ios/Podfile

特に状況は変わりませんでした。。。

対応案その2

上記を参考に同じことを実践。
が、全然違うエラーが出てしまった。。。

結局

その後色々試行錯誤していたのですが、結局問題はios/Runner/Runner-Bridging-Header.hにありました。

ios/Runner/Runner-Bridging-Header.h
// ↓↓ 勘違いでコメントアウトしてた。。。
// #import "GeneratedPluginRegistrant.h"
#import <DeployGateSDK/DeployGateSDK.h>

DeployGateを使う時の設定変更をしていた際に誤ってios/Runner/Runner-Bridging-Header.h#import "GeneratedPluginRegistrant.h"をコメントアウトしてしまっていました。
import文コメントアウトしたんだからそりゃ見つけられないよね。。。

このコメントアウトを解除して動かしたところすんなり動きました。よかった。

さいごに

ドキュメントを適当にコピペするのはやめましょう

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0