Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

url_launcher won't run on iOS emulator #16864

Closed
rickspencer3 opened this issue Apr 22, 2018 · 8 comments
Closed

url_launcher won't run on iOS emulator #16864

rickspencer3 opened this issue Apr 22, 2018 · 8 comments

Comments

@rickspencer3
Copy link

rickspencer3 commented Apr 22, 2018

Issue

When trying to run my app on the iOS emulator, I get the follow error:


    === BUILD TARGET url_launcher OF PROJECT Pods WITH CONFIGURATION Debug ===
    In file included from /Users/rick/development/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.0/ios/Classes/UrlLauncherPlugin.m:7:
    /Users/rick/development/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.0/ios/Classes/UrlLauncherPlugin.h:5:9: fatal error: 'Flutter/Flutter.h' file not found
    #import <Flutter/Flutter.h>
            ^~~~~~~~~~~~~~~~~~~

Steps to Reproduce

Add url_launcher to pubspec.yaml

dependencies:
  url_launcher: "^3.0.0"
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.0

Import the library and call it from code.

import 'package:url_launcher/url_launcher.dart';

Run it on an android emulator:

$ flutter devices
2 connected devices:

Android SDK built for x86 • emulator-5554                        • android-x86 • Android 8.1.0 (API 27) (emulator)
iPhone X                  • B928C14A-4F69-49A6-AC82-589227EFA4B5 • ios         • iOS 11.3 (simulator)
Ricks-MacBook:flutter_app rick$ flutter run -d emulator-5554 
Using hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...                                       1.6s
Resolving dependencies...                                    2.0s
Running 'gradlew assembleDebug'...                          24.9s
Built build/app/outputs/apk/debug/app-debug.apk (30.3MB).
Installing build/app/outputs/apk/app.apk...                  3.4s
I/FlutterActivityDelegate(32123): onResume setting current activity to this
Syncing files to device Android SDK built for x86...             
D/        (32123): HostConnection::get() New Host Connection established 0xec2a96c0, tid 32177
D/EGL_emulation(32123): eglMakeCurrent: 0xec3a8cc0: ver 3 0 (tinfo 0xd69ff550)
I/Choreographer(32123): Skipped 181 frames!  The application may be doing too much work on its main thread.
D/EGL_emulation(32123): eglMakeCurrent: 0xec404360: ver 3 0 (tinfo 0xec403f30)

🔥  To hot reload your app on the fly, press "r". To restart the app entirely, press "R".
An Observatory debugger and profiler on Android SDK built for x86 is available at: http://127.0.0.1:8101/
For a more detailed help message, press "h". To quit, press "q".

Try it in the emulator, it works fine.

Run it in the iOS emulator, it won't run:

$ flutter run -d B928C14A-4F69-49A6-AC82-589227EFA4B5
Launching lib/main.dart on iPhone X in debug mode...
Running Xcode clean...                                       2.6s
Starting Xcode build...                                          
Xcode build done                                             3.7s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **
    
Xcode's output:
↳
    === BUILD TARGET url_launcher OF PROJECT Pods WITH CONFIGURATION Debug ===
    In file included from /Users/rick/development/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.0/ios/Classes/UrlLauncherPlugin.m:7:
    /Users/rick/development/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.0/ios/Classes/UrlLauncherPlugin.h:5:9: fatal error: 'Flutter/Flutter.h' file not found
    #import <Flutter/Flutter.h>
            ^~~~~~~~~~~~~~~~~~~
    1 error generated.
Could not build the application for the simulator.
Error launching application on iPhone X.

Logs

Run your application with flutter run and attach all the log output:
buildlog.txt

Run flutter analyze and attach any output of that command also.

$ flutter analyze
Analyzing /Users/rick/AndroidStudioProjects/flutter_app...
  hint • Unused import: 'package:flutter/material.dart' at test/widget_test.dart:7:8 • unused_import
  hint • Unused import: 'package:flutter_app/main.dart' at test/widget_test.dart:10:8 • unused_import
2 issues found.
(Ran in 9.8s)

Flutter Doctor

Paste the output of running flutter doctor -v here.

$ flutter doctor -v
[✓] Flutter (Channel beta, v0.2.8, on Mac OS X 10.13.4 17E199, locale en-US)
    • Flutter version 0.2.8 at /Users/rick/development/flutter
    • Framework revision b397406561 (3 weeks ago), 2018-04-02 13:53:20 -0700
    • Engine revision c903c217a1
    • Dart version 2.0.0-dev.43.0.flutter-52afcba357

[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    • Android SDK at /Users/rick/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-27, build-tools 27.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-1024-b01)
    • All Android licenses accepted.

[!] iOS toolchain - develop for iOS devices (Xcode 9.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 9.3, Build version 9E145
    ✗ ideviceinstaller is not installed; this is used to discover connected iOS devices.
      To install, run:
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
    • ios-deploy 1.9.2
    • CocoaPods version 1.5.0

[✓] Android Studio (version 3.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

[✓] Connected devices (2 available)
    • Android SDK built for x86 • emulator-5554                        • android-x86 • Android 8.1.0 (API 27) (emulator)
    • iPhone X                  • B928C14A-4F69-49A6-AC82-589227EFA4B5 • ios         • iOS 11.3 (simulator)

! Doctor found issues in 1 category.

Any help would be appreciated.

Note that I have installed the missing components that flutter doctor was complaining about for completeness, and the issue still stands.

@rickspencer3
Copy link
Author

rickspencer3 commented Apr 22, 2018

Podfile:

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

  # Plugin Pods
  plugin_pods = parse_KV_file('../.flutter-plugins')
  plugin_pods.map { |p|
    symlink = File.join('Pods', '.symlinks', 'plugins', File.basename(p[:path]))
    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'
    end
  end
end

@rickspencer3
Copy link
Author

I solved this by downgrading cocoapods to version 1.4, deleting the Pods folder, then building again.

@qbsho
Copy link

qbsho commented Jul 22, 2018

Any other solution as to downgrade.
use pod version: 1.5.3

@zoechi
Copy link
Contributor

zoechi commented Aug 28, 2018

Similar to #17899

@Sirrr
Copy link

Sirrr commented Feb 13, 2019

Update

Created #27893

Dears, I am struggling with this issue. Please help.

url_launcher: ^5.0.1
cocoapods: 1.6.0

Launching lib/main.dart on iPhone X in debug mode...

Warning: CocoaPods not installed. Skipping pod install.
  CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your plugin usage on the Dart side.
  Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS.
  For more info, see https://flutter.io/platform-plugins
To install:
  brew install cocoapods
  pod setup

Starting Xcode build...
Xcode build done.                                            5.0s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **


Xcode's output:
↳
    === BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
    Debug.xcconfig line 1: Unable to find included file "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
    Debug.xcconfig line 1: Unable to find included file "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
    === BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
    /Users/siraj/dev/AndroidStudioProjects/delete/ios/Runner/GeneratedPluginRegistrant.m:6:9: fatal error: 'url_launcher/UrlLauncherPlugin.h' file not found
    #import <url_launcher/UrlLauncherPlugin.h>
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.

Could not build the application for the simulator.
Error launching application on iPhone X.

Flutter doctor

[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14 18A391, locale en-AZ)
    • Flutter version 1.0.0 at /Applications/flutter
    • Framework revision 5391447fae (3 months 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/siraj/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-1248-b01)
    • 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.6.0

[✓] Android Studio (version 3.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 32.0.1
    • Dart plugin version 182.5215
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[!] IntelliJ IDEA Ultimate Edition (version 2017.2.5)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.io/intellij-setup/#installing-the-plugins

[✓] VS Code (version 1.30.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 2.22.3

[✓] Connected device (1 available)
    • iPhone X • A8EB16AF-4992-4C41-ADC2-7A637B0ABFA2 • ios • iOS 12.1 (simulator)

@zoechi
Copy link
Contributor

zoechi commented Feb 14, 2019

@Sirrr please try #16049 (comment)

@Sirrr
Copy link

Sirrr commented Feb 14, 2019

Thanks again @zoechi. The answer is below:

#27893 (comment)

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants