fluttercommunity / flutter_contacts

Contacts Service - A Flutter plugin to retrieve and manage contacts on Android and iOS devices. Maintainer: @lukasgit
https://pub.dev/packages/contacts_service
MIT License
153 stars 69 forks source link

contacts_service-Swift.h file not found #55

Closed weicht closed 5 years ago

weicht commented 5 years ago

I tried to no avail the solution offered here: https://github.com/fluttercommunity/flutter_contacts/issues/18

Rebuilt the flutter app with -i swift.

But am still getting the not found error: ######## Xcode's output: ↳ /Users/weicht/devel/flutter/.pub-cache/hosted/pub.dartlang.org/contacts_service-0.0.9/ios/Classes/ContactsServicePlugin.m:2:9: fatal error: 'contacts_service/contacts_service-Swift.h' file not found

import <contacts_service/contacts_service-Swift.h>

        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
/Users/weicht/devel/flutter/.pub-cache/hosted/pub.dartlang.org/contacts_service-0.0.9/ios/Classes/ContactsServicePlugin.m:2:9: fatal error: 'contacts_service/contacts_service-Swift.h' file not found
#import <contacts_service/contacts_service-Swift.h>
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

######

Flutter doctor -v output: ###### [✓] Flutter (Channel beta, v1.0.0, on Mac OS X 10.14 18A391, locale en-US) • Flutter version 1.0.0 at /Users/weicht/devel/flutter • Framework revision 5391447fae (7 weeks ago), 2018-11-29 19:41:26 -0800 • Engine revision 7375a0f414 • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3) • Android SDK at /Users/weicht/Library/Android/sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-28, build-tools 28.0.3 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06) • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 10.1, Build version 10B61 • ios-deploy 1.9.4 • CocoaPods version 1.5.3

[✓] Android Studio (version 3.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 30.0.1 • Dart plugin version 181.5656 • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] IntelliJ IDEA Ultimate Edition (version 2018.2.6) • IntelliJ at /Applications/IntelliJ IDEA.app • Flutter plugin version 31.1.3 • Dart plugin version 182.5124

[✓] Connected device (1 available) • Chris Weicht’s iPhone • c544c9050e97f5a0ea45e696f4fedc3485022bf0 • ios • iOS 12.1.2

• No issues found! ######

weicht commented 5 years ago

Trimmed down pubspec.yaml here: ##### name: demo_app description: Demonstrates how to use stuff.

dependencies: flutter: sdk: flutter

cupertino_icons: ^0.1.2

url_launcher: "^3.0.3" shared_preferences: "^0.4.3" flutter_secure_storage: "^3.1.2" contacts_service: "^0.0.9" permission_handler: "^2.1.0"

dev_dependencies: flutter_test: sdk: flutter

flutter: assets:

#####

weicht commented 5 years ago

And Podfile here: ##### `platform :ios, '12.0'

ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', { 'Debug' => :debug, 'Profile' => :release, 'Release' => :release, }

def parse_KV_file(file, separator='=') file_abs_path = File.expand_path(file) if !File.exists? file_abs_path return []; end pods_ary = [] skip_line_start_symbols = ["#", "/"] File.foreach(file_abs_path) { |line| next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } plugin = line.split(pattern=separator) if plugin.length == 2 podname = plugin[0].strip() path = plugin[1].strip() podpath = File.expand_path("#{path}", file_abs_path) pods_ary.push({:name => podname, :path => podpath}); else puts "Invalid plugin specification: #{line}" end } return pods_ary end

target 'Runner' do

use_frameworks!

system('rm -rf .symlinks') system('mkdir -p .symlinks/plugins')

generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig') if generated_xcode_build_settings.empty? puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first." end generated_xcode_build_settings.map { |p| if p[:name] == 'FLUTTER_FRAMEWORK_DIR' symlink = File.join('.symlinks', 'flutter') File.symlink(File.dirname(p[:path]), symlink) pod 'Flutter', :path => File.join(symlink, File.basename(p[:path])) end }

plugin_pods = parse_KV_file('../.flutter-plugins') plugin_pods.map { |p| symlink = File.join('.symlinks', 'plugins', p[:name]) File.symlink(p[:path], symlink) pod p[:name], :path => File.join(symlink, 'ios') } end

post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['ENABLE_BITCODE'] = 'NO'

workaround for https://github.com/CocoaPods/CocoaPods/issues/7463

  target.headers_build_phase.files.each do |file|
    file.settings = { 'ATTRIBUTES' => ['Public'] }
  end
end

end end` #####

jeroen-meijer commented 5 years ago

Perhaps related to flutter/flutter#16036?

weicht commented 5 years ago

I'm slowly going through each of those potential solutions now...

shouhuori commented 5 years ago

Same error.

ja2375 commented 5 years ago

This error happens to all flutter projects that import plugins that need Swift support. To fix it: Don't rebuild the project with swift support. Instead create a fresh new empty project with swift support. Then just copy over all your dart files, assets & pubspec. Nothing else but that.

That should fix this issue.

lukasgit commented 5 years ago

See @ja2375 instructions above. Closing this issue

rignaneseleo commented 5 years ago

I got the same problem but I fixed it deleting the ios folder (you might backup it) and running this in the root of the project: flutter create -i swift .

Qson8 commented 4 years ago

Same error.

import "FlutterAudioRecorderPlugin.h"

import <flutter_audio_recorder/flutter_audio_recorder-Swift.h>

@implementation FlutterAudioRecorderPlugin

'flutter_audio_recorder/flutter_audio_recorder-Swift.h' file not found

Zeeshan0201 commented 3 years ago

just recreate new project and paste lib,assets,ios plits files,menifest,ymal and all required file. then cd ios,pub install,pub update,flutter build ios. it will work and generate the build.