authpass / biometric_storage

Flutter plugin to store data behind biometric authentication (ie. fingerprint)
https://pub.dev/packages/biometric_storage
MIT License
171 stars 101 forks source link

Build Error: Lexical or Preprocessor Issue (Xcode): 'biometric_storage/biometric_storage-Swift.h' file not found #92

Closed andrewc-besaathi closed 1 year ago

andrewc-besaathi commented 1 year ago

Dear all,

Please can. you help resolve this build issue which is causing us a total headache and we don't know whom else to turn to.

Until the last couple of weeks, we have been using biometric_storage 4.1.1 in our code perfectly fine - never an issue and builds perfectly every time. In fact flutter build appbundle and flutter build apk still work fine.

But now, we are getting this build error every time we attempt to build or run the iPhone app or archive: Lexical or Preprocessor Issue (Xcode):'biometric_storage/biometric_storage-Swift.h' file not found.

We found issue #48 which has this same error, but there was no clear resolution described and I don't know enough about Xcode (being a flutter dev who uses VS code 99% of the time!) to know what to correct. There seem to be plenty of other similar 'lexical' issues, so I have tried fixes from other reading around this type of issue - most seem to be around the cocoa pods setup.

1. Going to the ios folder in the flutter project and executing a. pod deintegrate b. pod install c. pod update d. pod repo update e. cd .. f. flutter clean && flutter pub get g. flutter build ipa

2. Going into Xcode and updating the deployment target to iOS 13 for everything I can see to check if a later iOS is needed.

3. Editing the pod file to set a minimum target of iOS 13 as well.

4. Trying to make head or tail of 'are headers generated correctly' comments in issue 48 and not really getting it!

Even tried playing with the classifies a bit to import the SwiftBiometricSecurityPlugin in different ways just in case the import was not quite right, but that clearly wasn't the case.

5. Updating to 4.1.3 and downgrading to 4.1.0 - neither any joy.

6. Removing / Adding use_frameworks! from the runner setup in podfile

7. Created a new user on my machine and redeployed everything from scratch to have a completely clean setup - no joy here either

8. Here is my flutter doctor output - all good here:

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.3.10, on macOS 13.0.1 22A400 darwin-x64, locale en-GB) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1) [✓] Xcode - develop for iOS and macOS (Xcode 14.2) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.3) [✓] VS Code (version 1.74.2) [✓] Connected device (2 available) [✓] HTTP Host Availability

• No issues found!

We are shortly trying to go live, but I don't have a usable iOS build and this is a big deal for the team - can you help at all?

Many thanks,

Andrew

hpoul commented 1 year ago
  1. Created a new user on my machine and redeployed everything from scratch to have a completely clean setup - no joy here either

thats weird.. that should fix most caching problems.. have you tried it with a new project altogether? you can also try it with the example project in this repo... did your project ever compile successfully for iOS with biometric_storage before? is your project swift or objective c?

git clone https://github.com/authpass/biometric_storage.git
cd biometric_storage/example
flutter pub get
flutter run -d iphone

you might be getting a few migration messages, because it's a somewhat old project.. but it works for me..

Screenshot 2023-01-05 at 20 06 45
andrewc-besaathi commented 1 year ago

Thanks for the quick reply!

Yes the project compiled successfully for several months with the biometric storage included - it is just recently the ios build failed - android app bundles / apks are totally fine.

We are building with flutter (dart) and compiling to native ios and android builds.

I will test the build as you have suggested and come back to you on that.

Kind regards,

Andrew

andrewc-besaathi commented 1 year ago

Okay, I have successfully built the example app and all runs fine. Maybe it is another issue that is causing this. Really appreciate the rapid help, still at a loss, but will keep plugging away.

andrewc-besaathi commented 1 year ago

The example build works fine... this is really unusual.

andrewc-besaathi commented 1 year ago

I know, is there any way of copying the example 'pod' build over to our project, as that is obviously working? Or because ios calls pod install each time, that will be kind of moot?

hpoul commented 1 year ago

Just delete the whole Pods directory and run pod install should recreate everything.. but I'd think pod deintegrate, which you already tried, should do that anyway.. Maybe this is not the root error.. have you made sure there aren't any other compile errors shown in xcode? Try to start xcode, clean and run a full new build and check all errors and warnings..

andrewc-besaathi commented 1 year ago

Thank you. After a bit more tinkering, I found a solution.

The fix was to:

  1. delete to ios folder, completely
  2. run flutter create -i swift . in the folder
  3. delete the macos, windows and linux folders that gets created (not building for these platforms)
  4. delete the new test/WidgetTest that gets created (as it tried to run a different app)
  5. open the ios/Runner.xcworkspace in Xcode
  6. Run the 'suggested updates' in Xcode to fix the versioning of various components (new baseline IOS v12.0)
  7. flutter build ipa - and then build the app (successfully)

A better way to do the flutter create would be this: flutter create -i swift . --project-name=my-project-name - and use the name in pubspec.yaml.

I think with code merges over time something corrupted something and it just needed a clean start.

Really appreciated your help - it got me to the next stage!

Have a great new year.