Flutter plugin project build breaks: @import module not found for iOS
Asked Answered
D

2

1

I'm developing a Flutter plugin that was running until a minute ago.

I haven't changed my Flutter project or the generated Xcode workspace at all. But all of a sudden the iOS Runner build breaks:

/path/to/myplugin/example/ios/Runner/GeneratedPluginRegistrant.m:10:9:
    fatal error: module 'nativeguest' not found
    @import myplugin;
     ~~~~~~~^~~~~~~~~~~
    1 error generated.

I haven't renamed or moved anything so I have no clue where this came from. I double checked there are no changes through my Git history.

I don't quite remember what happened except a few flutter clean and flutter run -d <udid> ops. I probably did these in both the plugin example folder and the plugin root folder.

My Flutter global setup is perfectly fine

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, 1.19.0-1.0.pre, on Mac OS X 10.15.4 19E287, locale en-CN)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
[✓] Android Studio (version 3.6)
[✓] VS Code (version 1.45.1)
[✓] Connected device (2 available)

• No issues found!
Deplete answered 2/6, 2020 at 3:17 Comment(0)
D
0

This turned out to be a Bundle ID issue. I renamed the bundle on flutter side in the .yaml, but the new name didn't reflect back to the Xcode project.

One must manually rename the following metadata entries of the generated Xcode Runner project

  • Runner > Runner > Info.plist: Bundle name
  • `Runner > Main Editor: Signing & Capabilities > Bundle Identifier

IMHO, this is such a bad dev experience on Flutter's part. Renaming on Android is another roller-coaster ride, having to edit multiple manifests and Gradle configs.

Due to so many separate config files, renaming or reorganizing a project becomes such a risky act!

Deplete answered 2/6, 2020 at 6:35 Comment(0)
P
2

In my case, I was opening ios/Runner.xcodeproj instead of ios/Runner.xcworkspace

But if you still facing the issue

You can refer this like https://github.com/flutter/flutter/issues/43986

it has various other solution proposed by different developers.

Papeete answered 21/3, 2023 at 8:20 Comment(0)
D
0

This turned out to be a Bundle ID issue. I renamed the bundle on flutter side in the .yaml, but the new name didn't reflect back to the Xcode project.

One must manually rename the following metadata entries of the generated Xcode Runner project

  • Runner > Runner > Info.plist: Bundle name
  • `Runner > Main Editor: Signing & Capabilities > Bundle Identifier

IMHO, this is such a bad dev experience on Flutter's part. Renaming on Android is another roller-coaster ride, having to edit multiple manifests and Gradle configs.

Due to so many separate config files, renaming or reorganizing a project becomes such a risky act!

Deplete answered 2/6, 2020 at 6:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.