Flutter-geolocator: Compile error on iOS

Created on 15 Jan 2019  ·  3Comments  ·  Source: Baseflow/flutter-geolocator

🐛 Bug Report

There are various warnings causing build failure when adding geolocator: ^2.1.1 to the project and targeting iOS.

Failed to build iOS app
Error output from Xcode build:

* BUILD FAILED *

Xcode's output:

/Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-2.1.2/ios/Classes/PermissionManager.swift:50:59: error: 'openSettingsURLString' has been renamed to 'UIApplicationOpenSettingsURLString'
guard let url = URL(string: UIApplication.openSettingsURLString),
^~~~~
UIApplicationOpenSettingsURLString
UIKit.UIApplication:64:22: note: 'openSettingsURLString' was introduced in Swift 4.2
public class let openSettingsURLString: String
^
/Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-2.1.2/ios/Classes/PermissionManager.swift:55:45: error: argument labels '(rawValue:)' do not match any available overloads
let optionsKeyDictionary = [UIApplication.OpenExternalURLOptionsKey(rawValue: "universalLinksOnly"): NSNumber(value: true)]
^ ~~~~~~~~
/Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-2.1.2/ios/Classes/PermissionManager.swift:55:45: note: overloads for 'UIApplication.OpenExternalURLOptionsKey' exist with these partially matching parameter lists: (coder: NSCoder), (stringLiteral: StaticString), (format: NSString, CVarArg...), (string: NSString), (utf8String: UnsafePointer), (UTF8String: UnsafePointer), (string: String), (contentsOfFile: String), (contentsOf: URL), (contentsOfURL: URL), (cString: UnsafePointer), (CString: UnsafePointer)
let optionsKeyDictionary = [UIApplication.OpenExternalURLOptionsKey(rawValue: "universalLinksOnly"): NSNumber(value: true)]
^
/Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-2.1.2/ios/Classes/PermissionManager.swift:59:91: error: 'openSettingsURLString' has been renamed to 'UIApplicationOpenSettingsURLString'
let success = UIApplication.shared.openURL(URL.init(string: UIApplication.openSettingsURLString)!)
^~~~~
UIApplicationOpenSettingsURLString
UIKit.UIApplication:64:22: note: 'openSettingsURLString' was introduced in Swift 4.2
public class let openSettingsURLString: String
^
/Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-2.1.2/ios/Classes/PermissionManager.swift:99:54: error: closure tuple parameter '(key: String, value: Any)' does not support destructuring
return Dictionary(uniqueKeysWithValues: input.map { key, value in (UIApplication.OpenExternalURLOptionsKey(rawValue: key), value)})
^~~~
(arg) -> <#Result#> let (key, value) = arg; return
/Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:27:31: warning: 'SFSafariViewController' is only available on iOS 9.0 or newer [-Wunguarded-availability]
- (void)safariViewController:(SFSafariViewController )controller
^
In module 'SafariServices' imported from /Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:5:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h:27:12: note: 'SFSafariViewController' has been explicitly marked partial here
@interface SFSafariViewController : UIViewController
^
/Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:27:1: note: annotate 'safariViewController:didCompleteInitialLoad:' with an availability attribute to silence this warning
- (void)safariViewController:(SFSafariViewController *)controller
^
/Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:43:40: warning: 'SFSafariViewController' is only available on iOS 9.0 or newer [-Wunguarded-availability]
- (void)safariViewControllerDidFinish:(SFSafariViewController *)controller {
^
In module 'SafariServices' imported from /Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:5:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h:27:12: note: 'SFSafariViewController' has been explicitly marked partial here
@interface SFSafariViewController : UIViewController
^
/Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:43:1: note: annotate 'safariViewControllerDidFinish:' with an availability attribute to silence this warning
- (void)safariViewControllerDidFinish:(SFSafariViewController *)controller {
^
API_AVAILABLE(ios(9.0))
/Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:29:31: warning: comparison between pointer and integer ('NSInteger' (aka 'long') and 'void *')
if (_previousStatusBarStyle != nil) {
~
~~~~ ^ ~
/Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:111:45: warning: comparison between pointer and integer ('NSInteger' (aka 'long') and 'void *')
if (self->_previousStatusBarStyle != nil) {
~
~~~~~~ ^ ~
/Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:108:18: warning: 'openURL:options:completionHandler:' is only available on iOS 10.0 or newer [-Wunguarded-availability]
[application openURL:url
^
~~
In module 'UIKit' imported from /Volumes/PROJECTS/nomadradar-app/repo/nomadradar/ios/Pods/Target Support Files/url_launcher/url_launcher-prefix.pch:2:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:135:1: note: 'openURL:options:completionHandler:' has been explicitly marked partial here
- (void)openURL:(NSURL
)url options:(NSDictionary *)options completionHandler:(void (^ __nullable)(BOOL success))completion NS_AVAILABLE_IOS(10_0) NS_EXTENSION_UNAVAILABLE_IOS("");
^
/Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:108:18: note: enclose 'openURL:options:completionHandler:' in an @available check to silence this warning
[application openURL:url
^
~~
/Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:140:3: warning: 'SFSafariViewController' is only available on iOS 9.0 or newer [-Wunguarded-availability]
SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url];
^
~~~~~
In module 'SafariServices' imported from /Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:5:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h:27:12: note: 'SFSafariViewController' has been explicitly marked partial here
@interface SFSafariViewController : UIViewController
^
/Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:140:3: note: enclose 'SFSafariViewController' in an @available check to silence this warning
SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url];
^
~~~~~
/Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:140:38: warning: 'SFSafariViewController' is only available on iOS 9.0 or newer [-Wunguarded-availability]
SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url];
^
~~~~~~~
In module 'SafariServices' imported from /Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:5:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h:27:12: note: 'SFSafariViewController' has been explicitly marked partial here
@interface SFSafariViewController : UIViewController
^
/Users/dirkeisold/programming/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:140:38: note: enclose 'SFSafariViewController' in an @available check to silence this warning
SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url];

Expected behavior

No errors.

Reproduction steps

Configuration

Version: ^2.1.1

[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.13.6 17G4015, locale de-DE)
• Flutter version 1.0.0 at /Users/dirkeisold/programming/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/dirkeisold/programming/android-sdk-macosx
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = /Users/dirkeisold/programming/android-sdk-macosx
• Java binary at: /Applications/Android Studio 3.2.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 2.0.0
• CocoaPods version 1.5.3

Most helpful comment

@deisold, @tommaso1, the reason you are getting this issue is probably because you are still compiling against an older SWIFT version (I believe the current default is 4.1). You can simply change this by updating your Podfile using the following instructions.

In your Podfile make sure you add the line use_frameworks! (best is to add this line directly below the target Runner do like so:

target 'Runner' do
  use_frameworks!

Also in your Podfile make sure you add the line config.build_settings['SWIFT_VERSION'] = '4.2' to the post_installer block. After adding this line the post_installer block should look like this:

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'] = '4.2'
    end
  end
end

All 3 comments

+1

try flutter cleanflutter clean

@deisold, @tommaso1, the reason you are getting this issue is probably because you are still compiling against an older SWIFT version (I believe the current default is 4.1). You can simply change this by updating your Podfile using the following instructions.

In your Podfile make sure you add the line use_frameworks! (best is to add this line directly below the target Runner do like so:

target 'Runner' do
  use_frameworks!

Also in your Podfile make sure you add the line config.build_settings['SWIFT_VERSION'] = '4.2' to the post_installer block. After adding this line the post_installer block should look like this:

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'] = '4.2'
    end
  end
end
Was this page helpful?
0 / 5 - 0 ratings

Related issues

prasant10050 picture prasant10050  ·  6Comments

lqmminh picture lqmminh  ·  6Comments

shrishti08 picture shrishti08  ·  3Comments

samo92 picture samo92  ·  6Comments

joesnarky picture joesnarky  ·  3Comments