fluttercommunity / plus_plugins

Flutter Community Plus Plugins
BSD 3-Clause "New" or "Revised" License
1.62k stars 989 forks source link

flutter build ios fatal error module connectivity_plus not found #337

Closed william-levi closed 3 years ago

william-levi commented 3 years ago

System info

Issue occurs on: iOS Plugin name: connectivity plus Plugin version: 1.0.4 Flutter doctor output:

paste it here...

Steps to Reproduce

  1. ...
  2. ...
  3. ...

Logs

mhadaily commented 3 years ago

@william-levi can you please provide more information, it's very hard to reproduce without having proper information.

mhadaily commented 3 years ago

I have tested and there was no issue building our sample app, however, there was an issue with Android which is fixed in version 1.0.5 and it seems apps can build for both android and ios now. please try and let us know if you still have any issue, otherwise, please close this issue.

arslandevcrew commented 3 years ago

facing same issue with version 1.0.5(latest). I have clean flutter project multiple times. usedrm ios/Podfile && flutter build ios flutter clean but its not working

Auramel commented 3 years ago

I have the same problem. Macbook pro m1.

flutter build ios

Running pod install...                                             494ms
Running Xcode build...
 └─Compiling, linking and signing...                        163ms
Xcode build done.                                            5,0s
Failed to build iOS app
Error output from Xcode build:
↳
    objc[19034]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x1fef2ac10) and
    /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1146cc2b8). One of the two will be used. Which one is undefined.
    objc[19034]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x1fef2ac60) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice
    (0x1146cc308). One of the two will be used. Which one is undefined.
    ** BUILD FAILED **

Xcode's output:
↳
    /Users/auramel/projects/flutter/online_check_mobile/ios/Runner/GeneratedPluginRegistrant.m:10:9: fatal error: module 'connectivity_plus' not found
    @import connectivity_plus;
     ~~~~~~~^~~~~~~~~~~~~~~~~
    1 error generated.
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Analyzing workspace
    note: Constructing build description
    note: Build preparation complete

flutter doctor -v

[✓] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-arm, locale ru-RU)
    • Flutter version 2.2.3 at /opt/homebrew/Caskroom/flutter/2.2.3/flutter
    • Framework revision f4abaa0735 (3 weeks ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/auramel/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5.1, Build version 12E507
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

[✓] VS Code (version 1.58.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.24.0

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.114
fryette commented 3 years ago

Same issue after migrating to latest beta channel

william-levi commented 3 years ago

Guys check your Podfile. I solve it by recreating the ios folder rm -rf ios flutter create .

this will recreate a new ios folder with a new Podfile

fryette commented 3 years ago

@william-levi would be nice if you can share what exactly changed after recreating the ios folder Sometimes it's really hard to recreate it

william-levi commented 3 years ago

can you guys share your podfile ?

fryette commented 3 years ago

@william-levi

# Uncomment this line to define a global platform for your project
# platform :ios, '9.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)

    # Fix 'Undefined symbols for architecture arm64'
    # https://github.com/flutter/flutter/issues/64502#issuecomment-759165857
    target.build_configurations.each do |build_configuration|
      build_configuration.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64 i386'
      build_configuration.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
    end
  end
end
william-levi commented 3 years ago

Did you try flutter clean already ? based on the Podfile.. i think we have just the same ``# Uncomment this line to define a global platform for your project platform :ios, '10.1'

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['IPHONEOS_DEPLOYMENT_TARGET'] = '10.1' end end end``

also what command did you use when building the ios ?

try this steps close xcode flutter clean flutter build ios then open project again in xcode

fryette commented 3 years ago

Sure used flutter clean and everything. But after regenerating the ios folder, did you notice any key changes?

william-levi commented 3 years ago

try uncommenting this platform :ios, '10.1' platform :ios, '9.0'

william-levi commented 3 years ago

can you show me also the logs after flutter build ios ?

fryette commented 3 years ago

@william-levi, unfortunately no, already switched back to 2.2.3(previously tried latest beta)

But has pretty same to


Xcode's output:
↳
    /Users/auramel/projects/flutter/online_check_mobile/ios/Runner/GeneratedPluginRegistrant.m:10:9: fatal error: module 'connectivity_plus' not found
    @import connectivity_plus;
     ~~~~~~~^~~~~~~~~~~~~~~~~
    1 error generated.
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Analyzing workspace
    note: Constructing build description
    note: Build preparation complete
fryette commented 3 years ago

@william-levi


Launching lib/main.dart on iPhone SE (2nd generation) in debug mode...
lib/main.dart:1
Xcode build done.                                           160.4s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **
Xcode's output:
↳
    /PATH/ios/Runner/GeneratedPluginRegistrant.m:12:9: fatal error: module 'connectivity_plus' not found
    @import connectivity_plus;
     ~~~~~~~^~~~~~~~~~~~~~~~~
    1 error generated.
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Analyzing workspace
    note: Constructing build description
    note: Build preparation complete
Could not build the application for the simulator.
Error launching application on iPhone SE (2nd generation).
Exited (sigterm)
fryette commented 3 years ago

Fixed by opening .xcworkspace from XCode

william-levi commented 3 years ago

nice buddy ! :)

but i already mention that in my previous comment to reopen project with xcode. next time read thoroughly with the comments and instructions Goodluck :)

mhadaily commented 3 years ago

If this issue is resolved, can you please close it?

teddysbeach commented 3 years ago

facing same issue with version 1.0.5(latest). I have clean flutter project multiple times. usedrm ios/Podfile && flutter build ios flutter clean but its not working

It worked for me! Thanks

rhymelph commented 2 years ago

I have the same issues!!!!!!!

masterwok commented 2 years ago

@fryette I've tried opening Runner.xcworkspace in XCode but i'm not picking up any changes in git diff. How exactly did you resolve this issue? Any help would be greatly appreciated!

@william-levi @mhadaily I think this issue should be reopened as it's still occurring in 2.2.0

Not sure if it's relevant but I'm also on an M1 mac.

Podfile:

# Uncomment this line to define a global platform for your project
platform :ios, '11.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)
#  end
#end
post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)

    # Fix 'Undefined symbols for architecture arm64'
    # https://github.com/flutter/flutter/issues/64502#issuecomment-759165857
    target.build_configurations.each do |build_configuration|
      build_configuration.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64 i386'
      build_configuration.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
    end
  end
end

Build Output:

 jt@Jonathans-MacBook-Pro  ~/projects/cm-flutter-new   main ±  flutter build ios --no-codesign
Warning: Building for device with codesigning disabled. You will have to manually codesign before deploying to device.
Building com.coinmeinc.coinme for device (ios-release)...
Running Xcode build...                                                  
 └─Compiling, linking and signing...                      2,129ms
Xcode build done.                                            7.6s
Failed to build iOS app
Error output from Xcode build:
↳
    objc[76538]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x2216eab90) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1080982c8). One of the two will be used. Which one is undefined.
    objc[76538]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x2216eabe0) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x108098318). One of the two will be used. Which one is undefined.
    ** BUILD FAILED **

Xcode's output:
↳
    /Users/jt/projects/cm-flutter-new/ios/Runner/AppDelegate.swift:131:62: warning: treating a forced downcast to 'UINavigationControllerDelegate' as optional will never produce 'nil'
            miSnapVC.navigationController?.delegate = controller as! UINavigationControllerDelegate;
                                                                 ^
    /Users/jt/projects/cm-flutter-new/ios/Runner/AppDelegate.swift:131:64: note: use 'as?' to perform a conditional downcast to 'UINavigationControllerDelegate'
            miSnapVC.navigationController?.delegate = controller as! UINavigationControllerDelegate;
                                                                   ^
                                                                   ?
    /Users/jt/projects/cm-flutter-new/ios/Runner/AppDelegate.swift:131:51: note: add parentheses around the cast to silence this warning
            miSnapVC.navigationController?.delegate = controller as! UINavigationControllerDelegate;
                                                      ^
                                                      (                                            )
    remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
    remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
    /Users/jt/projects/cm-flutter-new/ios/Runner/AppDelegate.swift:131:62: warning: treating a forced downcast to 'UINavigationControllerDelegate' as optional will never produce 'nil'
            miSnapVC.navigationController?.delegate = controller as! UINavigationControllerDelegate;
                                                                 ^
    /Users/jt/projects/cm-flutter-new/ios/Runner/AppDelegate.swift:131:64: note: use 'as?' to perform a conditional downcast to 'UINavigationControllerDelegate'
            miSnapVC.navigationController?.delegate = controller as! UINavigationControllerDelegate;
                                                                   ^
                                                                   ?
    /Users/jt/projects/cm-flutter-new/ios/Runner/AppDelegate.swift:131:51: note: add parentheses around the cast to silence this warning
            miSnapVC.navigationController?.delegate = controller as! UINavigationControllerDelegate;
                                                      ^
                                                      (                                            )
    /Users/jt/projects/cm-flutter-new/ios/Runner/GeneratedPluginRegistrant.m:12:9: fatal error: module 'connectivity_plus' not found
    @import connectivity_plus;
     ~~~~~~~^~~~~~~~~~~~~~~~~
    1 error generated.
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order

Encountered error while building for device.
william-levi commented 2 years ago

Guys check your Podfile. I solve it by recreating the ios folder rm -rf ios flutter create .

this will recreate a new ios folder with a new Podfile

try this @masterwok

WaheedHussainHaans commented 2 years ago

@william-levi did this but still not working

masterwok commented 2 years ago

Sorry, I thought I responded to this ticket.

@WaheedHussainHaans - I was able to resolve this issue without deleting the iOS directory.

What ended up working for me was opening the project in XCode. I can't remember exactly how/where I opened it but after a number of attempts, XCode presented a dialog recommending code changes. After applying the recommended code changes my project compiled.

@william-levi - thank you for your recommendation. Unfortunately, deleting the entire iOS directory isn't an option for me.

@mhadaily - do you think this ticket should be reopened?

paramaggarwal commented 2 years ago

This is the problem: https://github.com/fluttercommunity/plus_plugins/commit/7b2e11b13478af78cc9a4c9300e0772cd70812d2#r77734987

Nei1eveN commented 2 years ago

This is the problem: 7b2e11b#r77734987

I'm experiencing the same issue. Is there a way for us to have a workaround for the mean time?

AristideVB commented 2 years ago

Any solution to this issue ? Also experiencing the same issue

miquelbeltran commented 2 years ago

I think I missed this one, but overall the issue is on how the pods for plugins work.

The general advice is to do a flutter clean.

If that doesn't fix the issue, try to reinstall pods by deleting the Podfile.lock and the Pods folder in your ios folder. Followed by a pod install and follow instructions there.

If you are still facing issues: Delete the ios folder and recreate your project. But that should be the very last option.

Our CI builds all the example projects and runs them as integration tests for iOS, so there shouldn't be any compile issues at the moment.

AristideVB commented 2 years ago

I think I missed this one, but overall the issue is on how the pods for plugins work.

The general advice is to do a flutter clean.

If that doesn't fix the issue, try to reinstall pods by deleting the Podfile.lock and the Pods folder in your ios folder. Followed by a pod install and follow instructions there.

If you are still facing issues: Delete the ios folder and recreate your project. But that should be the very last option.

Our CI builds all the example projects and runs them as integration tests for iOS, so there shouldn't be any compile issues at the moment.

@miquelbeltran thanks for reaching out but none of your solutions worked out for me, build works running flutter build ios --release from terminal but not from Xcode

I get Module 'connectivity_plus' not found

I'm running on an M1 Mac

AristideVB commented 2 years ago

Describe the issue Module 'connectivityplus' not found on Xcode Build (M1 Mac)_

To Reproduce

  1. Create brand new Flutter iOS App project
  2. Add connectivity_plus: ^3.0.2 to pubspec.yaml
  3. Run flutter clean && flutter pub get
  4. Build project from Xcode on an iOS device (not Terminal !)

Expected behavior Build runs without failing from both the terminal & Xcode (it only succeeds from terminal)

device / execution context iOS - Flutter Channel stable, 3.3.7, on macOS 12.6 21G115 darwin-arm,

I also run into this issue running my Fastlane Script with Github actions...

@miquelbeltran

miquelbeltran commented 2 years ago

When you build your project from xcode, did you open your project using the Runner.xcworkspace or the Runner.xcodeproj?

AristideVB commented 2 years ago

@miquelbeltran Thanks for reaching out again

I always open it using Runner.xcworkspace

But somehow running flutter run --verbose & killing the app and running build again from XCode fixed the issue on the sample new Flutter project

Doing so didn't fix the issue for my real app thought...

miquelbeltran commented 2 years ago

Since this ticket is closed, I'd recommend you to open a new ticket with all the information you can provide and steps to reproduce the issue.

studiozocaro commented 1 year ago

Fixed by opening .xcworkspace from XCode

Vedsaga commented 1 year ago

These following solves the issue,

i have this issue and this sequence of steps have worked for us.

  1. delete the iOS folder
  2. flutter clean
  3. flutter pub get
  4. flutter create --platforms=ios .
  5. cd ios && pod install (very important step)
  6. build project from xcode