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

Build failed on iOS (SWIFT_VERSION) #19

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hi,

the example works fine. But when I tried to compile my own project, the following error occurred:

    Error output from Xcode build:
    ↳
        ** BUILD FAILED **

    Xcode's output:
    ↳
        === BUILD TARGET contacts_service OF PROJECT Pods WITH CONFIGURATION Debug ===
        The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor.
Could not build the precompiled application for the device.

I figured out, that the solution/ workaround is to change the configuration in "ios/Runner.xcodeproj/project.pbxproj": from VERSIONING_SYSTEM = "apple-generic"; to

SWIFT_SWIFT3_OBJC_INFERENCE=On;
SWIFT_VERSION=4.0;

Is there a dependency compiled in an earlier swift version that could be updated?

Best, Marcus

mavimo commented 6 years ago

@germanmarcus suggested workaround (set SWIFT_SWIFT3_OBJC_INFERENCE and SWIFT_VERSION) do not work for me, reported error:

Launching lib/main.dart on iPhone X in debug mode...
Running pod install...                                       0.6s
CocoaPods' output:
↳
      Preparing

    Analyzing dependencies

    Inspecting targets to integrate
    [!] There may only be up to 1 unique SWIFT_VERSION per target. Found target(s) with multiple Swift versions:
    Runner: Swift
    Runner: Swift 4.0

    /usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer/target_inspector.rb:248:in `compute_swift_version_from_targets'
    /usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer/target_inspector.rb:50:in `compute_results'
    /usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:921:in `block (3 levels) in inspect_targets_to_integrate'
    /usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:919:in `each'
    /usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:919:in `block (2 levels) in inspect_targets_to_integrate'
    /usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:917:in `each'
    /usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:917:in `block in inspect_targets_to_integrate'
    /usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/user_interface.rb:64:in `section'
    /usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:912:in `inspect_targets_to_integrate'
    /usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:78:in `analyze'
    /usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:243:in `analyze'
    /usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:154:in `block in resolve_dependencies'
    /usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/user_interface.rb:64:in `section'
    /usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:153:in `resolve_dependencies'
    /usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:116:in `install!'
    /usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/command/install.rb:41:in `run'
    /usr/local/Cellar/cocoapods/1.5.3/libexec/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
    /usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/command.rb:52:in `run'
    /usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/bin/pod:55:in `<top (required)>'
    /usr/local/Cellar/cocoapods/1.5.3/libexec/bin/pod:22:in `load'
    /usr/local/Cellar/cocoapods/1.5.3/libexec/bin/pod:22:in `<main>'
Error output from CocoaPods:
↳
    [!] Automatically assigning platform `ios` with version `8.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
Error running pod install
Error launching application on iPhone X.

do you find a solution?

clovisnicolas commented 6 years ago

Could you update to 0.0.7 and tell me if you still have the issue ?

blaneyneil commented 6 years ago

using 0.0.7 i get this from the import in ContactsServicePlugin.m:

fatal error: 'contacts_service/contacts_service-Swift.h' file not found

i'm completely unfamiliar with swift though, so i tried to somehow import SwiftContactsServicePlugin.swift instead. to no avail. i'm not sure if that file is missing, or should just be renamed.

mavimo commented 6 years ago

@blaneyneil seems a "non issue", do you bootstrap the flutter project using swift? Since this plugin use swift you need to use -i flutter flag when do you create a project. No solution to add swift support on already running project, the suggested solution is to:

I tested it and work like a charm (see other issue), eg (supposing your project is awesome_project):

$ ls .
awesome_project
$ mkdir test
$ cd test
$ flutter create -i swift awesome_project
$ cd ..
$ mv awesome_project/ios awesome_project/ios_bak
$ mv test/awesome_project/ios awesome_project/ios
$ rm -rf test
$ cd awesome_project
$ flutter packages get

than edit the ios/Runner/Info.plist to include permission and rebuild your flutter project.

idurvesh commented 5 years ago

Do what Mavimo suggested or you can simply remove ios folder and run this command $ flutter create -i swift .

This will rebuild the project with swift integration