aws-amplify / amplify-flutter

A declarative library with an easy-to-use interface for building Flutter applications on AWS.
https://docs.amplify.aws
Apache License 2.0
1.32k stars 248 forks source link

Swift Compiler Error (XCode) breaking build #2050

Closed aardrop closed 2 years ago

aardrop commented 2 years ago

Description

Something in the swift files is causing XCode to throw this error:

Swift Compiler Error (Xcode): 'let' property 'convert' may not be initialized directly; use "self.init(...)" or "self = ..." instead
/<App Directory>/ios/Pods/Amplify/Amplify/Categories/DataStore/Model/Temporal/SpecBasedDateConverting.swift:22:13

I've cleaned everything and re-installed and updated pods many times at the point and nothing seems to work. Does anyone have any idea how to fix this?

Categories

Steps to Reproduce

MacOS: 12.5.1 XCode: 13.4.1 Flutter: 3.0.5 Amplify: 0.6.6

Screenshots

No response

Platforms

Android Device/Emulator API Level

No response

Environment

[✓] Flutter (Channel stable, 3.0.5, on macOS 12.5.1 21G83 darwin-arm, locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.70.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

! Doctor found issues in 1 category.

Dependencies

dependencies:
- amplify_analytics_pinpoint 0.6.6 [amplify_analytics_pinpoint_android amplify_analytics_pinpoint_ios amplify_core aws_common flutter meta]
- amplify_api 0.6.6 [amplify_api_android amplify_api_ios amplify_core amplify_flutter aws_common collection flutter meta plugin_platform_interface]
- amplify_auth_cognito 0.6.6 [amplify_auth_cognito_android amplify_auth_cognito_ios amplify_core aws_common collection flutter meta plugin_platform_interface]
- amplify_flutter 0.6.6 [amplify_core amplify_datastore_plugin_interface amplify_flutter_android amplify_flutter_ios aws_common collection flutter meta plugin_platform_interface]
- amplify_storage_s3 0.6.6 [amplify_storage_s3_android amplify_storage_s3_ios amplify_core aws_common flutter meta plugin_platform_interface]
- animated_text_kit 4.2.2 [flutter characters]
- auto_route 4.0.0 [flutter path collection meta universal_html]
- background_fetch 1.1.0 [flutter]
- carousel_slider 4.1.1 [flutter]
- cloud_firestore 1.0.7 [cloud_firestore_platform_interface cloud_firestore_web firebase_core firebase_core_platform_interface flutter meta]
- connectivity_plus 2.3.6+1 [flutter connectivity_plus_platform_interface connectivity_plus_linux connectivity_plus_macos connectivity_plus_web connectivity_plus_windows]
- dartz 0.10.1
- firebase_core 1.21.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_messaging 9.1.4 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutter_background_geolocation 4.7.1 [flutter collection background_fetch]
- flutter_font_icons 2.2.5 [flutter]
- flutter_keyboard_size 1.0.0+4 [flutter provider]
- flutter_keyboard_visibility 5.3.0 [meta flutter_keyboard_visibility_platform_interface flutter_keyboard_visibility_web flutter]
- flutter_riverpod 1.0.4 [collection flutter meta riverpod state_notifier]
- flutter_spinkit 5.1.0 [flutter]
- flutter_svg 1.1.4 [flutter meta path_drawing vector_math xml]
- freezed 2.1.0+1 [analyzer build build_config collection meta source_gen freezed_annotation json_annotation]
- freezed_annotation 2.1.0 [collection json_annotation meta]
- get_it 7.2.0 [async collection]
- hive 2.2.3 [meta crypto]
- hive_flutter 1.1.0 [flutter hive path_provider path]
- http 0.13.5 [async http_parser meta path]
- image_cropper 2.0.3 [flutter image_cropper_platform_interface image_cropper_for_web]
- image_picker 0.8.5+3 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_platform_interface]
- injectable 1.5.3 [get_it]
- intl 0.17.0 [clock path]
- intl_phone_number_input 0.7.0+2 [flutter meta libphonenumber_plugin equatable collection]
- json_annotation 4.6.0 [meta]
- kt_dart 0.9.1 [meta]
- location 4.4.0 [flutter location_platform_interface location_web]
- lottie 1.4.1 [archive flutter path vector_math]
- mapbox_gl 0.14.0 [flutter mapbox_gl_platform_interface mapbox_gl_web]
- modal_bottom_sheet 2.1.0 [flutter]
- objectbox 1.6.0 [collection flat_buffers ffi meta path]
- objectbox_flutter_libs 1.6.0 [objectbox path_provider]
- provider 6.0.3 [collection flutter nested]
- shared_preferences 2.0.15 [flutter shared_preferences_android shared_preferences_ios shared_preferences_linux shared_preferences_macos shared_preferences_platform_interface shared_preferences_web shared_preferences_windows]
- sliding_up_panel 2.0.0+1 [flutter]
- sticky_grouped_list 2.1.0 [flutter scrollable_positioned_list]
- syncfusion_flutter_charts 19.4.56 [flutter intl vector_math syncfusion_flutter_core]
- url_launcher 6.1.5 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows]
- uuid 3.0.6 [crypto]

Device

iPhone simulator or on device

OS

MacOS: 12.5.1, iOS 15.2 and 15.5

Deployment Method

Custom Pipeline

CLI Version

No response

Additional Context

No response

Amplify Config

{ "auth": { "plugins": { "awsCognitoAuthPlugin": { "UserAgent": "aws-amplify-cli/0.1.0", "Version": "0.1.0", "IdentityManager": { "Default": {} }, "CredentialsProvider": { "CognitoIdentity": { "Default": { "PoolId": "", "Region": "" } } }, "CognitoUserPool": { "Default": { "PoolId": "", "AppClientId": "", "AppClientSecret": "", "Region": "" } }, "Auth": { "Default": { "authenticationFlowType": "USER_SRP_AUTH" } }, "PinpointAnalytics": { "Default": { "AppId": "", "Region": "" } }, "PinpointTargeting": { "Default": { "Region": "" } }, "S3TransferUtility": { "Default": { "Bucket": "", "Region": "" } } } } }, "analytics": { "plugins": { "awsPinpointAnalyticsPlugin": { "pinpointAnalytics": { "appId": "", "region": "" }, "pinpointTargeting": { "region": "" } } } }, "storage": { "plugins": { "awsS3StoragePlugin": { "bucket": "", "region": "", "defaultAccessLevel": "guest" } } }, "api": { "plugins": { "awsAPIPlugin": { "outway": { "endpointType": "REST", "endpoint": "", "region": "", "authorizationType": "*****" } } } } }

HuiSF commented 2 years ago

Hello @arkeri this issue seems to be related to https://github.com/aws-amplify/amplify-ios/issues/2001

Can you paste the content of the Podfile under the ios directory of your Flutter project?

aardrop commented 2 years ago

Here is the contents of my podfile:

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

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

use_frameworks!

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
      config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
      config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
      config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
    end
  end
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end
end
aardrop commented 2 years ago

Hello @arkeri this issue seems to be related to aws-amplify/amplify-ios#2001

Can you paste the content of the Podfile under the ios directory of your Flutter project?

Following the discussion here, it allows us to run builds by changing ['BUILD_LIBRARY_FOR_DISTRIBUTION'] to 'NO', but it seems to be messing with our deployment pipeline. Is there a reason this is necessary, considering that for us, until yesterday Amplify didn't require this change?

fjnoyp commented 2 years ago

Hi @arkeri did the build suddenly break or did you update xcode/amplify flutter dependencies beforehand?

I believe the reasons for that requirement are contained within the linked amplify ios issue:

image

aardrop commented 2 years ago

@fjnoyp, No, for the past two months we had not had this issue at all with the same most recent version of flutter and the same version of amplify. My hypothesis is that a stable version of Amplify or a dependency of amplify was stored in DerivedData for a while after this issue first started so when that cleared it caused this issue to come to light from the new code but for us, it arrived out of nowhere.

Jordan-Nelson commented 2 years ago

Hi @arkeri - It is possible that something changed that is causing this to no longer be supported, but I don't believe it ever was intended to be supported in the first place. Is there a specific reason that you have set this in your Podfile? If there is a good use case for this, we can bring it to the Amplify-iOS team to be considered. Otherwise, the recommended fix is to remove this from the Podfile.

Jordan-Nelson commented 2 years ago

Hi @arkeri - I am going to close this out since there is a recommended fix for this. If you believe there is a good use case to support this, please open a new request. Thanks.