roughike / flutter_facebook_login

A Flutter plugin for allowing users to authenticate with native Android & iOS Facebook login SDKs.
BSD 2-Clause "Simplified" License
403 stars 331 forks source link

fatal error: 'BridgeAPI/FBSDKBridgeAPIProtocol.h' file not found #20

Open g123k opened 6 years ago

g123k commented 6 years ago

Hello,

I have a strange problem with the library and the iOS build. Every time I try to build the Flutter app, I have this error:

In file included from /Users/g123k/IdeaProjects/untitled/ios/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAccessToken.m:21:
    In file included from /Users/g123k/IdeaProjects/untitled/ios/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/Network/FBSDKGraphRequestPiggybackManager.h:19:
    /Users/g123k/IdeaProjects/untitled/ios/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/FBSDKCoreKit+Internal.h:24:9: fatal error: 'BridgeAPI/FBSDKBridgeAPIProtocol.h' file not found
    #import "BridgeAPI/FBSDKBridgeAPIProtocol.h"
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    4 warnings and 1 error generated.

How to reproduce the bug:

  1. Create a new Flutter app with Objective C for the iOS build
  2. Add the following dependency in the pubspec.yaml : flutter_facebook_login: "^1.1.1"
  3. Run the app

I have tried to change the Podfile, but the error is still the same:

# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

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!

  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  # referring to absolute paths on developers' machines.
  system('rm -rf Pods/.symlinks')
  system('mkdir -p Pods/.symlinks/plugins')

  # Flutter Pods
  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('Pods', '.symlinks', 'flutter')
      File.symlink(File.dirname(p[:path]), symlink)
      pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
    end
  }

  # Plugin Pods
  plugin_pods = parse_KV_file('../.flutter-plugins')
  plugin_pods.map { |p|
    symlink = File.join('Pods', '.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'
      config.build_settings['SWIFT_VERSION'] = '3.2'
    end
    # workaround for https://github.com/CocoaPods/CocoaPods/issues/7463
    target.headers_build_phase.files.each do |file|
      file.settings = { 'ATTRIBUTES' => ['Public'] }
    end
  end
end
roughike commented 6 years ago

Thanks for reporting.

Could you:

  1. paste the output from flutter doctor here
  2. see what's the output from pod install command run from the ios folder?

I couldn't debug this on a fresh project on the latest Flutter beta since the pod install command failed due to some CocoaPods error.

g123k commented 6 years ago

Thanks for your answer.

The flutter doctor output:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.2.8, on Mac OS X 10.13.4 17E199, locale en-FR)
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.3)
[✓] Android Studio
[✓] Android Studio (version 3.1)
[✓] IntelliJ IDEA Community Edition (version 2018.1)
[✓] VS Code (version 1.21.1)
[✓] Connected devices (1 available)

• No issues found!

And the pod install result:

Downloading dependencies
Installing Bolts (1.9.0)
Installing FBSDKCoreKit (4.32.0)
Installing FBSDKLoginKit (4.32.0)
Installing Flutter (1.0.0)
Installing flutter_facebook_login (0.0.1)
Generating Pods project
Integrating client project
Pod installation complete! There are 2 dependencies from the Podfile and 5 total pods installed.
roughike commented 6 years ago

Hmm.

I'll look into resolving this when I have the time, can't promise anything currently. Hopefully, you can develop on Android for a while.

roughike commented 6 years ago

One thing: are you sure that you're adding this in your dependencies block, and NOT dev_dependencies?

g123k commented 6 years ago

Yes the dependency is in the dependencies block

g123k commented 6 years ago

After digging a little bit, if I use the Podfile from the example/ios folder, the app will compile again. However it means that with the latest beta of Flutter your package should not build, because the Podfile has changed a little bit.

roughike commented 6 years ago

That's really useful information, thanks a lot!

I'll try to:

  1. Fix the problem, hopefully by just updating the Podfile or something similar
  2. Incorporate a "will it build with latest Flutter version" test for Android & iOS with Travis

Still no ETA when I'm able to fix it, hopefully soon.

Samaritan1011001 commented 6 years ago

Having the same issue. I tried looking into the Podfile but I couldn't do anything because of my lack of knowledge about it. So, it would be really helpful if you could look into this sooner, @roughike? Thank you for the amazing plugin.

roughike commented 6 years ago

Not able to reproduce on a fresh project created with Flutter v0.2.8 and flutter_facebook_login version v1.1.1. @g123k @Samaritan1011001 are you able to repro with a fresh new project created with v0.2.8 of Flutter?

Ajit121 commented 6 years ago

Having the same issue :'(

roughike commented 6 years ago

@Ajit121 When did you create your project? Does it use Swift or ObjC for iOS code?

Ajit121 commented 6 years ago

Created one day ago and used swift. Its working fine for android (Kotlin) but unable to build in ios because of this error.

Ajit121 commented 6 years ago

Oh! this issue is happening for flutter project for using swift only.. Working fine for the project using Objective C. Please fix this issue ASAP.

roughike commented 6 years ago

This has been an issue with Swift projects before, and IIRC, it's not particularly related to this plugin, but more of a Flutter issue.

I can help you debug once I get home. Meanwhile, could you run "flutter --version" and paste the output here?

freewheelnat commented 6 years ago

I had the same issue, so I thought I would detail the steps that worked for me in case someone else lands on this issue too.

Background: My project is a Swift project created quite a few months ago, with a change added to Podfile to deal with Swift plugin issue (so firebase plugin could work). Flutter on dev channel, v0.5.4

Steps that worked for me:

  1. Upgrade cocoa to 1.5 (command line)
  2. Run pod setup (command line)
  3. Delete Pod folder and Podfile.lock file (project was open in XCode when I did this but I did this using IntellijIDEA)
  4. flutter clean (command line)
  5. Edit my Podfile file so it matches the latest from flutter for Swift project https://github.com/flutter/flutter/blob/master/packages/flutter_tools/templates/cocoapods/Podfile-swift (project was open in XCode when I did this but I did this using IntellijIDEA)
  6. flutter run (command line)
  7. Error message about Bolts/BFURL.h not found in Bolts/BFURL_Internal.h
  8. Quit XCode
  9. flutter run (command line)

It worked! I have no idea why step 9 worked when step 6 didn't, except maybe for step 8 (building for iOS is a bit of a mystery to me, I'm an Android developer)

candamotek commented 6 years ago

I can confirm the above works, at least with y setup and xCode 9.3. + Pod 1.5.3. Basically, just do 'pod clean' followed by changing your Podfile to match https://github.com/flutter/flutter/blob/master/packages/flutter_tools/templates/cocoapods/Podfile-swift and then re-build using xCode. No need to make any manual changes to Podfile