-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
flutter plugin project build breaks: @import module not found for iOS #58463
Comments
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
IMHO, this is such a bad dev/DevOps experience on flutter part. Renaming on Android is another roller-coaster ride, having to edit multiple manifests and Gradle configs, and for a plugin project, you would have to edit source code!! See the package io.flutter.plugins;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import io.flutter.embedding.engine.FlutterEngine;
/**
* Generated file. Do not edit.
* This file is generated by the Flutter tool based on the
* plugins that support the Android platform.
*/
@Keep
public final class GeneratedPluginRegistrant {
public static void registerWith(@NonNull FlutterEngine flutterEngine) {
flutterEngine.getPlugins().add(new com.example.myplugin.MypluginPlugin());
}
} Due to so many separate config files, renaming or any project reorganization becomes such a risky act! |
I drew a hasty conclusion in my last post. Now I can fairly consistently reproduce this issue without any renaming or reorganization of the plugin project. This is a serious problem! Here are the things I did Create the plugin projectflutter create --template plugin myplugin Run iOS build and the example project in Android Studio 3.6.3This gets Runner and Pod project created in Xcode workspace. Complete iOS provisioningAfter this, the skeleton Runner project builds fine. Added ffi to plugin project's yaml and pub getThis is for C++ native code to build. Add custom native ffi C++ source code to Runner Xcode project... and configure build settings, build phases
Here I reserve all flutter generated settings, only append mine to those settings when fit. Here I also added a thirdparty Xcode project to the Runner's Xcode workspace. At this point, the thirdparty lib builds fine in Xcode. So is Runner. Build iOS in Android Studio again.This time, build breaks. Android Studio complains: 3 warnings generated.
1 warning generated.
ld: library not found for -lmythirdpartylib
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 Clean build Runner in XcodeAfter Cleaning then Building, this time the Runner project breaks: /path/to/myplugin/example/ios/Runner/GeneratedPluginRegistrant.m:10:9: Module 'myplugin' not found The scary part is: This error, as I reported at the top, seems irreversible, i.e., even if I A few days ago when first seeing it, I thought maybe my .gitignore was too aggressive and I may have some important project config files untracked. However, today I About configuring Xcode Runner projectI also had doubts whether or not I should configure the generated Xcode projects the way I did. But there was very few lines saying about the integration of thirdparty libs with FFI. I see very few options regarding working with lib dependencies. It turns out that editing Xcode project is still the most straightforward way. By the way, this is serious. I have a deadline coming with this project this week. Any tip will be appreciated. |
OK, culprits found! I made two mistakes during my Xcode trip, which I obviously dismissed as trivia: I opened Runner project directly for buildThe Runner depends on /path/to/myplugin/example/ios/Runner.xcworkspace This workspace is what Android Studio talks with. If I were to build the native code directly, I should definitely build from this workspace instead of the Runner project. Now I recall this must be a CocoaPods convention that I'm not familiar with. I disabled
|
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Steps to Reproduce
It's not a sure repro, but here it is
myplugin
;flutter clean
;/project_root/example
, runflutter clean
;flutter build -d <my_ios_udid>
.Expected results:
The app should run.
Actual results:
If I just open the Runner Xcode project, I will end up with the same error.
I haven't renamed or moved anything so I have no clue where this came from. I double checked no changes through my git history.
I don't quite remember what happened except for a few flutter clean and flutter run -d ops. I probably did these in both the plugin example folder and the plugin root folder.
Please help!
The text was updated successfully, but these errors were encountered: