Flutter iOS build failing on BigSur, XCode 12 - ios

Flutter iOS build fails due to issues with headers.
I followed the simple steps mentioned on flutter.dev for launching an app on iOS simulator. I've had no problems working with flutter on Android/Web, but this is the first time I've tried running it on iOS.
Summary of error - (Complete Error: https://gist.github.com/mannprerak2/520f8a749431a50b8472783c71d67dda)
...
#import "Headers/CoreMedia.h"
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreMedia.framework/Headers/CoreMedia.h:15:10: note: in file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreMedia.framework/Headers/CoreMedia.h:15:
#include <CoreMedia/CMFormatDescription.h>
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreMedia.framework/Headers/CMFormatDescription.h:26:10: error: could not build module 'CoreAudio'
#include <CoreAudio/CoreAudioTypes.h>
^
/Users/prerakmann/development/test_ios/ios/Runner/Runner-Bridging-Header.h:1:9: note: in file included from /Users/prerakmann/development/test_ios/ios/Runner/Runner-Bridging-Header.h:1:
#import "GeneratedPluginRegistrant.h"
^
/Users/prerakmann/development/test_ios/ios/Runner/GeneratedPluginRegistrant.h:8:9: error: could not build module 'Flutter'
#import <Flutter/Flutter.h>
^
192 errors generated.
<unknown>:0: error: failed to emit precompiled header '/Users/prerakmann/Library/Developer/Xcode/DerivedData/Runner-ahrcvwuwhqnepxdcpfsagztcuwrr/Build/Intermediates.noindex/PrecompiledHeaders/Runner-Bridging-Header-swift_1QEOMJ6SUMBGB-clang_3BG5Q8JCTPBV5.pch' for bridging header '/Users/prerakmann/development/test_ios/ios/Runner/Runner-Bridging-Header.h'
384 errors generated.
<unknown>:0: error: generate-pch command failed with exit code 1 (use -v to see invocation)
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
...
System: Macbook Pro 13 (2020), BigSur 11.2.1, Xcode 12.4
Flutter: Tried on the latest stable and beta channel.
Simulator: Tried on iOS 8, iOS 12.
Steps to reproduce: Create a new flutter app, run it.

Turns out this was happening due to CPATH being defined like this.
╰─$ echo $CPATH
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
A temporary fix is to set CPATH= in current terminal window, run flutter clean, and then run the app.

Related

React Native (Expo) - error: generate-pch command failed with exit code 1

Building a React Native Expo app (prebuild on iOS, not using Expo Go) and running into this esoteric error that I can't seem to find elsewhere on the internet.
I'll post it here for the next unlucky React Native dev, and perhaps I'll find a solution and post that too.
expo run:ios output:
⚠️ (../../Library/Developer/Xcode/DerivedData/MyProject-epxolwjjgmimbdefugnlecrdysuv/Build/Intermediates.noindex/PrecompiledHeaders/MyProject-Bridging-Header-2vyenlvwppgam.dia:1:1)
Command PrecompileSwiftBridgingHeader failed with a nonzero exit code
^ Could not read serialized diagnostics file: error(in target 'MyProject' from project 'MyProject')
❌ error: generate-pch command failed with exit code 1 (use -v to see invocation)
› 1 error(s), and 1 warning(s)
Failed to build iOS project. "xcodebuild" exited with error code 65.
Xcode build output:
<unknown>:0: error: error opening input file '/Users/jh/Code/MyProject/ios/MyProject/MyProject-Bridging-Header.h' (No such file or directory)
<unknown>:0: error: cannot open file '/Users/jh/Library/Developer/Xcode/DerivedData/MyProject-epxolwjjgmimbdefugnlecrdysuv/Build/Intermediates.noindex/PrecompiledHeaders/MyProject-Bridging-Header-e8n926ydzbc0.dia' for diagnostics emission (No such file or directory)
/Users/jh/Library/Developer/Xcode/DerivedData/MyProject-epxolwjjgmimbdefugnlecrdysuv/Build/Intermediates.noindex/PrecompiledHeaders/MyProject-Bridging-Header-e8n926ydzbc0.dia:1:1: warning: Could not read serialized diagnostics file: error("Failed to open diagnostics file") (in target 'MyProject' from project 'MyProject')
Command PrecompileSwiftBridgingHeader failed with a nonzero exit code
Expo SDK version 44. I'm on a 2022 Mac Studio M1.
Okay, found the solution!
I had used npx react-native-rename to rename my project, but it didn't rename the Swift bridging header.
It's located in ios/MyProject/<oldname>-Bridging-Header.h.
renamed: ios/MyProject/OldName-Bridging-Header.h -> ios/MyProject/MyProject-Bridging-Header.h
While I was doing this, I also discovered that several of my bundle identifiers hadn't been moved over either. Do a codebase search for com.yourorganization.youroldbundlename to find & replace those too.
The locations I had to update:
./ios/MyProject.xcodeproj/project.pbxproj
./ios/MyProject/Info.plist
./app.json

Unable to run Flutter App on iOS when using Firebase. Android seems to be working but iOS throws multiple errors

So I followed the instructions on adding Firebase to Flutter and although things work on Android, I am unable to build on the ios emulator. I get some xcode errors. I have tried deleting both ios/Pods directory and the Podfile.lock file, then using the flutter clean command. But I still get these errors. I have tried doing research but nothing I have found has helped. Here are the errors i get when I try to test on the iOS emulator.
Thank you in advance for the help.
Errors From Flutter Run:
Launching lib/main.dart on iPhone 12 Pro Max in debug mode...
Running pod install...
Running Xcode build...
Xcode build done. 130.2s
Failed to build iOS app
Error output from Xcode build:
↳
2021-03-26 18:45:52.768 xcodebuild[15465:79135] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTiOSFrameworks/DVTiOSFrameworks-17705/DTDeviceKitBase/DTDKRemoteDeviceData.m:371
Details: (null) deviceType from 00008101-001945163408001E was NULL when -platform called.
Object: <DTDKMobileDeviceToken: 0x7f963f7d3f80>
Method: -platform
Thread: <NSThread: 0x7f963b713cc0>{number = 3, name = (null)}
Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
2021-03-26 18:45:52.947 xcodebuild[15465:79134] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTiOSFrameworks/DVTiOSFrameworks-17705/DTDeviceKitBase/DTDKRemoteDeviceData.m:371
Details: (null) deviceType from 00008101-001945163408001E was NULL when -platform called.
Object: <DTDKMobileDeviceToken: 0x7f963f7d3f80>
Method: -platform
Thread: <NSThread: 0x7f963f725360>{number = 7, name = (null)}
Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
** BUILD FAILED **
Xcode's output:
↳
While building module 'firebase_core' imported from /Users/dev/development/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-1.0.1/ios/Classes/FLTFirebaseAuthPlugin.m:5:
In file included from <module-includes>:1:
In file included from /Users/dev/AndroidStudioProjects/aul/ios/Pods/Target Support Files/firebase_core/firebase_core-umbrella.h:13:
In file included from /Users/dev/development/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.0.2/ios/Classes/FLTFirebaseCorePlugin.h:11:
/Users/dev/development/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.0.2/ios/Classes/FLTFirebasePlugin.h:9:9: error: include of non-modular header inside framework module 'firebase_core.FLTFirebasePlugin': '/Users/dev/AndroidStudioProjects/aul/ios/Pods/Headers/Public/FirebaseCore/FirebaseCore.h' [-Werror,-Wnon-modular-include-in-framework-module]
#import <FirebaseCore/FirebaseCore.h>
^
1 error generated.
/Users/dev/development/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-1.0.1/ios/Classes/FLTFirebaseAuthPlugin.m:5:9: fatal error: could not build module 'firebase_core'
#import <firebase_core/FLTFirebasePluginRegistry.h>
~~~~~~~^
2 errors generated.
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team ID. To resolve this, select a development team in the Runner editor. (in target 'Runner' from project 'Runner')
Could not build the application for the simulator.
Error launching application on iPhone 12 Pro Max.
Errors from Xcode:
/Users/dev/AndroidStudioProjects/aul/build/ios/Debug-iphonesimulator/firebase_core/firebase_core.framework/Headers/FLTFirebasePlugin.h:9:9: Include of non-modular header inside framework module 'firebase_core.FLTFirebasePlugin': '/Users/dev/AndroidStudioProjects/aul/ios/Pods/Headers/Public/FirebaseCore/FirebaseCore.h'
/Users/dev/AndroidStudioProjects/aul/build/ios/Debug-iphonesimulator/firebase_auth/firebase_auth.framework/Headers/FLTFirebaseAuthPlugin.h:12:9: Could not build module 'firebase_core'
/Users/dev/AndroidStudioProjects/aul/ios/Runner/GeneratedPluginRegistrant.m:8:9: Could not build module 'firebase_auth'
In my iOS/Runner/AppDelegate.swift file I was initiating Firebase there, which is not needed. I also added the the firebase pod plugins to my Podfile. Once I removed these things it started to work.

Oracle JET : Unable to build ojet hybrid project after upgrading xcode to Version 12.0 (12A7209)

This morning I updated my xcode to Version 12.0 (12A7209) and since then I am not able to build the project for ios
Replication steps
ojet create testapp --template=navbar
cd testapp
ojet add hybrid
ojet build ios
Getting the below error
.........
In module 'Foundation' imported from /Users/hellonuh/Desktop/testapp/hybrid/platforms/ios/build/emulator/include/Cordova/CDVAppDelegate.h:20:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURL.h:595:1: note: 'stringByAddingPercentEscapesUsingEncoding:' has been explicitly marked deprecated here
- (nullable NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)enc API_DEPRECATED("Use -stringByAddingPercentEncodingWithAllowedCharacters: instead, which always uses the recommended UTF-8 encoding, and which encodes for a specific URL component or subcomponent since each URL component or subcomponent has different rules for what characters are valid.", macos(10.0,10.11), ios(2.0,9.0), watchos(2.0,2.0), tvos(9.0,9.0));
^
3 warnings and 3 errors generated.
Cordova compile finished.
Error: Error: Command failed: cordova compile ios --debug --emulator
** BUILD FAILED **
The following build commands failed:
CompileC /Users/hellonuh/Library/Developer/Xcode/DerivedData/testapp-hfsgwahghfnpzecdcshskgzlpyep/Build/Intermediates.noindex/testapp.build/Debug-iphonesimulator/testapp.build/Objects-normal/x86_64/CDVWKWebViewEngine.o /Users/hellonuh/Desktop/testapp/hybrid/platforms/ios/testapp/Plugins/cordova-plugin-wkwebview-engine/CDVWKWebViewEngine.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
xcodebuild: Command failed with exit code 65
Please help

How to fix “swift package generate-xcodeproj” results in manifest parse error?

I'm new to Swift and the Package Manager. I'm following a tutorial that generates the Xcode project file, but I get errors when I run "swift package generate-xcodeproj" (or "swift package update" for that matter). Below is the output.
It looks like it doesn't recognise the 'uuid_string_t' type in hfs_format.h header file.
Any ideas on how to solve this? I'm using Xcode 10.2 and Swift 5 on macOS 10.14.4. My Xcode Command Line Tools setting under the Location Preferences tab is set to 10.2.
/Users/rayscott/Developer/Source/Swift/TCPClient: error: manifest parse error(s):
:353:9: note: in file included from :353:
#import "hfs/hfs_format.h"
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/hfs/hfs_format.h:794:2: error: unknown type name 'uuid_string_t'
uuid_string_t ext_jnl_uuid;
^
:353:9: note: in file included from :353:
#import "hfs/hfs_format.h"
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/hfs/hfs_format.h:796:20: error: use of undeclared identifier 'uuid_string_t'; did you mean 'uuid_variant'?
char reserved[JIB_RESERVED_SIZE];
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/hfs/hfs_format.h:787:61: note: expanded from macro 'JIB_RESERVED_SIZE'
#define JIB_RESERVED_SIZE ((32*sizeof(u_int32_t)) - sizeof(uuid_string_t) - 48)
^
/usr/local/include/uuid/uuid.h:98:5: note: 'uuid_variant' declared here
int uuid_variant(const uuid_t uu);
^
:0: error: could not build Objective-C module 'Darwin'
I had the same issue after installing Xcode 10.2 and macOS 10.14.4. Solution for me was to run the following commands in Terminal:
brew doctor, and fix the mentioned issues
sudo xcode-select --reset
After executing these steps I did a reboot, and build started to work again.

Flutter unique_identified library issue?

I have a problem that when I used a library for flutter application to get the unique_id a problem arose where I can't do the build due that x-code can't import the required libraries even after pod installation was successful ,
Here is a screenshot of what the error would look like :
here is the exception stack trace when doing dart build :
Launching lib/main.dart on iPhone XR in debug mode...
Running pod install...
Starting Xcode build...
Xcode build done. 41.0s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
/Users/mac/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/unique_identifier-0.0.3/ios/Classes/UniqueIdentifierPlugin.m:2:9: fatal error: 'unique_identifier/unique_identifier-Swift.h' file not found
#import <unique_identifier/unique_identifier-Swift.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
/Users/mac/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-0.2.1/ios/Classes/FirebaseMessagingPlugin.m:146:75: warning: 'token' is deprecated: Use instanceIDWithHandler: instead. [-Wdeprecated-declarations]
[_channel invokeMethod:#"onToken" arguments:[[FIRInstanceID instanceID] token]];
^
In module 'FirebaseInstanceID' imported from /Users/mac/Desktop/test/ios/Pods/Headers/Private/Firebase/Firebase.h:46:
/Users/mac/Desktop/test/ios/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/Headers/FIRInstanceID.h:201:30: note: 'token' has been explicitly marked deprecated here
- (nullable NSString *)token __deprecated_msg("Use instanceIDWithHandler: instead.");
^
In module 'Foundation' imported from Headers/Private/FirebaseCore/FIRAnalyticsConfiguration.h:17:
In module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:
In module 'Darwin' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/sys/cdefs.h:180:48: note: expanded from macro '__deprecated_msg'
#define __deprecated_msg(_msg) __attribute__((deprecated(_msg)))
^
1 warning generated.
*** Update on the above [ the error above was corrected by removing the file and adding them again manually but now another problem appeared , when the code that get the unique Identifier is called exception happen ]
I appreciate the help
Regards,

Resources