miguelpruivo/flutter_file_picker

FileUtils.h can't be parsed

Closed this issue · 8 comments

App is started via: flutter run and its terminated with following exception:

Could not build the precompiled application for the device.
Parse Issue (Xcode): Expected identifier /Users/jharzenetter/.pub-cache/hosted/pub.dev/file_picker-6.2.0/ios/Classes/FileUtils.h:18:2

Error launching application

Platform

  • Android
  • iOS
  • Web
  • Desktop

Platform OS version
OS: macOS Sonoma 14.3.1
Target: iOS 17.3.1

Details to reproduce the issue
flutter run with App referring to this Plugin

Error Log
output of flutter run -v

[  +15 ms] Failed to build iOS app
[        ] Could not build the precompiled application for the device.
[   +2 ms] Parse Issue (Xcode): Expected identifier
           /Users/jharzenetter/.pub-cache/hosted/pub.dev/file_picker-6.2.0/ios/Classes/FileUtils.h:18:2
           
[        ] Error launching application on iPhone von Johannes.
[   +2 ms] "flutter run" took 16.225ms.
[   +3 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:815:9)
           <asynchronous suspension>
           #2      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1389:27)
           <asynchronous suspension>
           #3      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
           <asynchronous suspension>
           #4      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
           <asynchronous suspension>
           #5      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:355:9)
           <asynchronous suspension>
           #6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
           <asynchronous suspension>
           #7      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:295:5)
           <asynchronous suspension>
           #8      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:119:9)
           <asynchronous suspension>
           #9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
           <asynchronous suspension>
           #10     main (package:flutter_tools/executable.dart:90:3)
           <asynchronous suspension>

Flutter Version details
[✓] Flutter (Channel stable, 3.19.2, on macOS 14.3.1 23D60 darwin-arm64, locale de-DE)
• Flutter version 3.19.2 on channel stable at /Users/jharzenetter/Development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7482962148 (8 days ago), 2024-02-27 16:51:22 -0500
• Engine revision 04817c99c9
• Dart version 3.3.0
• DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/jharzenetter/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15A507
• CocoaPods version 1.15.2

[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 2023.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] Connected device (2 available)
• iPhone von Johannes (mobile) • 00008101-00114DCA21E3001E • ios • iOS 17.3.1 21D61
• macOS (desktop) • macos • darwin-arm64 • macOS 14.3.1 23D60 darwin-arm64
! Device R5CW81D0N9X is not authorized.
You might need to check your device for an authorization dialog.

[✓] Network resources
• All expected network resources are available.

This issue is stale because it has been open for 7 days with no activity.

Have you managed to fix it?

I haven't tried because i dont understand anything from Header Files

Closing as this might have been a temporary issue — will re-open if it gains relevance.

@miguelpruivo
I cant help but the issue still exists on my side... Even with Version 8.0.0

If anyone has an idea how to fix this (looks like its only happening for me) otherwise the issue would have risen by far more people.

I tried cleaning the pub cache, rebuild everything but it seems like nothing helps.

file_Picker-Version ^8.0.0
Flutter-Doctor-Output:

✓] Flutter (Channel stable, 3.19.5, on macOS 14.4.1 23E224 darwin-arm64, locale de-DE)
    • Flutter version 3.19.5 on channel stable at /Users/jharzenetter/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 300451adae (3 weeks ago), 2024-03-27 21:54:07 -0500
    • Engine revision e76c956498
    • Dart version 3.3.3
    • DevTools version 2.31.1


[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/jharzenetter/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.


[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.15.2


[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google
    Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.


[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)


[✓] Connected device (2 available)
    • iPhone von Johannes (mobile)  • iOS 17.3.1 21D61
    • macOS (desktop)              • macos                     • darwin-arm64 • macOS 14.4.1 23E224 darwin-arm64


[✓] Network resources
    • All expected network resources are available.

Content of FileUtils.h from my pub-cache

//
//  FileUtils.h
//  Pods
//
//  Created by Miguel Ruivo on 05/12/2018.
//
#import <MobileCoreServices/MobileCoreServices.h>
#import <Photos/Photos.h>

#ifdef DEBUG
#define Log(fmt, ...)            NSLog((@"\n\n***** " fmt @"\n* %s [Line %d]\n\n\n"), ##__VA_ARGS__, __PRETTY_FUNCTION__, __LINE__)
#else
#define Log(fmt, ...)
#endif

typedef NS_ENUM(NSInteger, MediaType) {
  VIDEO,
  IMAGE,
  MEDIA
};

@interface FileUtils : NSObject
+ (BOOL) clearTemporaryFiles;
+ (NSArray<NSString*>*) resolveType:(NSString*)type withAllowedExtensions:(NSArray<NSString*>*)allowedExtensions;
+ (MediaType) resolveMediaType:(NSString*)type;
+ (NSArray<NSDictionary*>*) resolveFileInfo:(NSArray<NSURL *> *)urls withData:(BOOL)loadData;
+ (NSURL*) exportMusicAsset:(NSString*)url withName: (NSString*)name;
@end

Verbose Error-Message from building

[  +18 ms] Failed to build iOS app
[  +45 ms] Parse Issue (Xcode): Expected identifier
           /Users/jharzenetter/.pub-cache/hosted/pub.dev/file_picker-8.0.0+1/ios/Classes/FileUtils.h:18:2
           
[   +2 ms] "flutter ipa" took 24.993ms.
[   +4 ms] Encountered error while archiving for device.
[        ] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      _BuildIOSSubCommand.runCommand (package:flutter_tools/src/commands/build_ios.dart:680:7)
           <asynchronous suspension>
           #2      BuildIOSArchiveCommand.runCommand (package:flutter_tools/src/commands/build_ios.dart:425:50)
           <asynchronous suspension>
           #3      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1389:27)
           <asynchronous suspension>
           #4      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
           <asynchronous suspension>
           #5      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
           <asynchronous suspension>
           #6      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:355:9)
           <asynchronous suspension>
           #7      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
           <asynchronous suspension>
           #8      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:295:5)
           <asynchronous suspension>
           #9      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:119:9)
           <asynchronous suspension>
           #10     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
           <asynchronous suspension>
           #11     main (package:flutter_tools/executable.dart:90:3)
           <asynchronous suspension>

@miguelpruivo ive managed to locate the source: it's the enumType MEDIA. I dont know why or how but if i change the name of the last enumtype everything works fine. I dont really know which sideeffects this has but this works for me now. (I guess there aren't that many bc it compiles)

Maybe its something with an other library which causes this error but i could not find anything