fluttercommunity / flutter_contacts

Contacts Service - A Flutter plugin to retrieve and manage contacts on Android and iOS devices. Maintainer: @lukasgit

Home Page:https://pub.dev/packages/contacts_service

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

contacts_service-Swift.h file not found

weicht opened this issue · comments

I tried to no avail the solution offered here: #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!
######

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:
- assets/alert-2.png
- assets/bubble-2.png
- assets/inbox-1.png
uses-material-design: true

#####

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 CocoaPods/CocoaPods#7463
target.headers_build_phase.files.each do |file|
file.settings = { 'ATTRIBUTES' => ['Public'] }
end
end
end
end`
#####

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

Same error.

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.

See @ja2375 instructions above. Closing this issue

commented

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 .

commented

Same error.

#import "FlutterAudioRecorderPlugin.h"
#import <flutter_audio_recorder/flutter_audio_recorder-Swift.h>

@implementation FlutterAudioRecorderPlugin

  • (void)registerWithRegistrar:(NSObject*)registrar {
    [SwiftFlutterAudioRecorderPlugin registerWithRegistrar:registrar];
    }
    @EnD

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

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.