I'm trying to include miniaudio
in an existing C plugin to a Flutter project with FFI. I'm getting dozens of errors like this when trying to compile for iOS:
Parse Issue (Xcode): Expected identifier or '(' /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:600:0
Semantic Issue (Xcode): Unknown type name 'NSString' /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:602:8
The C plugin works in the project without miniaudio
, and a test of miniaudio
works for macOS command line.
The errors are similar to those in this issue, where I think the answer talks about needing to compile as Obj-C: Getting errors in classes like NSObject.h,NSObjCRuntime.h while running tests in xcode
I'm relatively new to Flutter, and this is my first project with FFI, so I'm not familiar with editing Runner.xcodeproj
, etc.
Thanks for any help!
UPDATE:
I tried renaming /[path]/[plugin name]/ios/Classes/[plugin name].c
to [...].m
(as suggested in posts about similar issues), and I get:
Error (Xcode): Build input file cannot be found: '/[path]/[plugin name]/ios/Classes/[plugin name].c'. Did you forget to declare this file as an output of a script phase or custom build rule which produces it?
But there are apparently no references to that file anywhere in the plugin project or in the project that includes it -- only s.source_files = 'Classes/**/*'
in /[path]/[plugin name]/ios/[plugin name].podspec
. Could it be cached somewhere from a previous build? Something else?
Thanks again!
UPDATE 2:
Progress: I started a new Flutter FFI plugin project, renamed /[path]/[plugin name]/ios/Classes/[plugin name].c
to [...].m
, and it works! That is, it works if the file is renamed before the project is built for the first time.
So, I think there must be a file created as part of the build process, which contains the old file name, that is relied on for rebuilds. I'm hoping someone can advise on this. Is this correct, where is this file, can I just trash it...?
(I'm adding the Cocoapods
tag to this post.)
Success! flutter clean
cleared whatever intermediate file(s) had the old file name. It also broke dependencies, which I restored with flutter pub get
. So if it helps someone else, doing this after changing the file extension (see above) to .m
worked for me.