flutter_native_ads icon indicating copy to clipboard operation
flutter_native_ads copied to clipboard

IOS:fatal error: 'native_ads/native_ads-Swift.h'

Open sunjianan9900 opened this issue 6 years ago • 15 comments

/Documents/programs/SDK/flutter/.pub-cache/hosted/pub.flutter-io.cn/native_ads-0.0.3/ios/Classes/NativeAdsPlugin.m:2:9: fatal error: 'native_ads/native_ads-Swift.h' file not found #import <native_ads/native_ads-Swift.h> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated.

sunjianan9900 avatar Sep 05 '19 14:09 sunjianan9900

Hmm I'll check it. 👀

sakebook avatar Sep 05 '19 15:09 sakebook

@sunjianan9900 Try flutter pub get

sakebook avatar Sep 05 '19 15:09 sakebook

@sunjianan9900 Try flutter pub get

Hi I've tried and it's not working...

wesguirra avatar Sep 12 '19 07:09 wesguirra

Please try it this

https://stackoverflow.com/questions/55399209/update-flutter-dependencies-in-pub-cache

And flutter clean

sakebook avatar Sep 12 '19 07:09 sakebook

Please try it this

https://stackoverflow.com/questions/55399209/update-flutter-dependencies-in-pub-cache

And flutter clean

Still no lucky,

  • I deleted the dependency folder in /usr/local/share/flutter/.pub-cache/hosted/pub.dartlang.org/native_ads-0.1.0;
  • remove native_ads from pubspec.yaml;
  • run flutter packages get;
  • add native_ads to pubspec.yaml;
  • run flutter packages get;
  • run flutter clean.

getting the same error:

/usr/local/share/flutter/.pub-cache/hosted/pub.dartlang.org/native_ads-0.1.0/ios/Classes/NativeAdsPlugin.m:2:9: fatal error: 'native_ads/native_ads-Swift.h' file not found
    #import <native_ads/native_ads-Swift.h>

wesguirra avatar Sep 13 '19 00:09 wesguirra

Thank you trying.

I found similar error.

Please try this.

https://github.com/flutter/flutter/issues/22821#issuecomment-427950364

sakebook avatar Sep 13 '19 01:09 sakebook

I'm having the same problem. Is anyone found a solution?

itielMaimon avatar Sep 27 '19 17:09 itielMaimon

The second line in this file imports a non existing file. Please fix it.

itielMaimon avatar Sep 27 '19 17:09 itielMaimon

@itielMaimon

Have you tried this?

https://github.com/sakebook/flutter_native_ads/issues/14#issuecomment-531066055

sakebook avatar Sep 30 '19 10:09 sakebook

@sakebook

Yes, I tried it but it didn't help.

My guess, it has something to do with the fact that it uses Swift, so some configuration needs to be done.

Hope to find a solution.

itielMaimon avatar Oct 01 '19 16:10 itielMaimon

@itielMaimon

Hmm, I think Xcode problem.

Please try remove DerivedData.

https://stackoverflow.com/questions/38016143/how-can-i-delete-derived-data-in-xcode-8

And remove Flutter packages cache.

https://github.com/flutter/flutter/issues/24733

sakebook avatar Oct 02 '19 14:10 sakebook

@sakebook No, it didn't work..

Maybe something to do with linking in the project.pbxproj file?

itielMaimon avatar Oct 02 '19 16:10 itielMaimon

After some research I found a solution. The bug was related to Swift being used in this package without proper integration in Xcode.

Here's what you need to do based on this answer:

  1. Open ios/YourAppName.xcodeproj in Xcode.
  2. Right-click on Your App Name in the Project Navigator on the left, and click New File…
  3. Create a single empty Swift file to the project (make sure that Your App Name target is selected when adding).
  4. when Xcode asks, press Create Bridging Header, and do not remove the Swift file then. re-run your build.

Hope you find it useful.

itielMaimon avatar Oct 12 '19 18:10 itielMaimon

Thank you research!

I will try it.

sakebook avatar Oct 13 '19 15:10 sakebook

I have problems with .h file missing after upgrade xcode 11 because it not support plugin write in Swift. This solve my problems

  1. Backup ios folder to another and delete it
  2. flutter create -i swift .
  3. Copy your old infolist
  4. pod install And try run it again

MuMiMaNz avatar Oct 25 '19 17:10 MuMiMaNz