12

I am using shared_preferences dependency in Flutter.

Building Xcode (Product->archive - for Generic target) fails with

module 'shared_preferences' not found

Build in Xcode fails

I tried flutter clean, flutter pub cache repair, tried moving Flutter lib/ into new project (flutter create .) and I building using older Xcode version (11.4.1)..currently I have 12.0 beta 3.

What is weird is that running in Emulator from my IDE (IntelliJ) works just fine with no errors.

IDE Emulator dart main runs OK

These are my dependencies (pubspec.yaml)

dependencies:
  flutter:
    sdk: flutter
  http: ^0.12.2
  intl: any
  flutter_spinkit: ^4.1.2
  redux: any
  flutter_redux: any
  redux_thunk: any
  shared_preferences: 0.5.1+2
Xquick
  • 637
  • 1
  • 8
  • 20
  • 2
    Did you do run `flutter build ios` to create a release build? See: https://flutter.dev/docs/deployment/ios#create-a-build-archive – Er1 Jul 29 '20 at 14:41
  • Yes I did, but thank you for that doc link, I read it before but now I noticed that I was opening Project.xcodeproj instead of Project.xcworkspace in Xcode. Builds just fine now. – Xquick Jul 29 '20 at 14:50

9 Answers9

20

In my case problem was that I was opening Xcode project from Project.xcodeproj instead of Project.xcworkspace.

Xquick
  • 637
  • 1
  • 8
  • 20
2

I had to change the scheme in the following manner:

Product -> Scheme -> Edit Scheme

enter image description here

E.Bradford
  • 783
  • 7
  • 21
2

Searching on Stack Overflow I found this Flutter module not found in Xcode Which links to this https://github.com/flutter/flutter/issues/54599#issuecomment-644336055

This solved it for me!

enter image description here

0

if you are using project scheme mode as debug then change your scheme to release from debug.

product -> scheme -> debug to release.

and again try to archive project.

mfkocak
  • 87
  • 4
0

I had this issue aswell with flutter upgrading xcode and flutter 2.12.

to fix this:

  1. inside ios folder, delete all folders and files, keep the ios folder in your flutter project.
  2. within the flutter project execute > flutter create .
  3. open the ios/Runner.xworkspace with xcode
  4. within xcode, there will be a yellow alert icon top right, click that and fix the suggested issues.
  5. build with xcode
0

I deleted the ios folder, then i ran in the project path:

flutter create .
flutter build ios
0
  1. Delete podfile.lock & pods folder & derived data
  2. 'pod install' again
  3. Clean & build

That should solve the issue

Heshan Sandeepa
  • 3,388
  • 2
  • 35
  • 45
0

To anyone who is coming here in 2022 with a Mac M1

Please try

  1. flutter clean
  2. cd ios/
  3. arch -x86_64 pod install

that fixed the problem for me

mmdush
  • 19
  • 8
-1

You can try with this command

pod deintegrate && pod setup && pod install

Jasmin Sojitra
  • 1,090
  • 10
  • 24