'pod lib lint' conflict between 'route.h' and <net/route.h> - ios

I'm trying to run pod lib lint on a Cocoa Framework swift project and it returns the following error:
- ERROR | [iOS] xcodebuild: /MyProject/route.h:164:8: error: redefinition of 'rt_msghdr2'
- NOTE | [iOS] xcodebuild: /Applications/Xcode.app/Contents/Developer/Platforms
/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk
/usr/include/net/route.h:164:8:
note: previous definition is here
I have an Objective-C class (NetworkUtil.h - NetworkUtil.m) with the following import structure.
#if TARGET_IPHONE_SIMULATOR
#include <net/route.h>
#else
#include "route.h"
#endif
This, because route.h file only exist in the iOS Simulator SDK, but not in the actual iOS SDK (https://stackoverflow.com/a/23411469/5973853). I check whether it is an iPhone simulator, so the original < net/route.h > will be imported, or it runs on an actual iPhone, in that case it gets my manually copied 'route.h'.
Xcode manages to build and run the whole project correctly, but xcodebuild used by pod lib lint doesn't. For some reason, it imports both < net/route.h > and 'route.h' without considering the #if_TARGET_IPHONE_SIMULATOR validation and that makes the conflict due to "redefinition of several functions".
Is there any solution or workaround to this conflict?

Related

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.

Flutter iOS build failing on BigSur, XCode 12

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.

#import "sqlite3.h" from a pod's source

I have a private podspec for a library that relies on Apple's sqlite3.h. Unfortunately, it fails lint:
- ERROR | xcodebuild: Returned an unsuccessful exit code. You can use `--verbose`
for more information.
- ERROR | xcodebuild: /Users/tewha/Library/Developer/Xcode/DerivedData
/App-cglpwsgirxhgugbbcytbhfqnbjrw/Build/Products/Release-iphonesimulator
/SQLPackRat/SQLPackRat.framework/Headers/SQLPRDatabase.h:10:9: error: include of
non-modular header inside framework module 'SQLPackRat.SQLPRDatabase':
'/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform
/Developer/SDKs/iPhoneSimulator10.3.sdk/usr/include/sqlite3.h' [-Werror,
-Wnon-modular-include-in-framework-module]
Unfortunately, there doesn't seem to be a modular include for sqlite3.h.
How do I fix this? It seems to work anyway, but I imagine this will cause trouble for me later (probably as I start to use Swift in this project).

How to make cocoapods build for device only?

I'm trying to create a cocoa pod out of my Cocoa Touch Framework project. The project is not intended to support iOS simulator, only devices. It doesn't even compile for simulator. And it becomes a problem, because cocoapods tries (at least I think so) to build it for simulator and fails.
When I run the following command:
pod spec lint --verbose
it failes and the part of the output is the following:
The following build commands failed:
CompileC /var/folders/_w/9b4kyb8x2lzb9hvpn94jtrh00000gp/T/CocoaPods/Lint/build/Pods.build/Release-iphonesimulator/jsoncpp.build/Objects-normal/i386/jsoncpp.o jsoncpp/dist/jsoncpp.cpp normal i386 c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
-> RevSDK (0.1.0)
- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code.
- NOTE | xcodebuild: Headers/Public/RevSDK/time.h:62:10: fatal error: 'base/base_export.h' file not found
Analyzed 1 podspec.
[!] The spec did not pass validation, due to 1 error.
I'm not really good at understanding how the whole process goes and what exactly is wrong, but this line in the output:
CompileC /var/folders/_w/9b4kyb8x2lzb9hvpn94jtrh00000gp/T/CocoaPods/Lint/build/Pods.build/Release-iphonesimulator/jsoncpp.build/Objects-normal/i386/jsoncpp.o jsoncpp/dist/jsoncpp.cpp normal i386 c++ com.apple.compilers.llvm.clang.1_0.compiler
makes me think that cocoapods is trying to compile my project for the simulator. So I need to exclude it somehow. I need to let it know that it should compile for device only. What I tried was adding the following into my .podspec file:
s.xcconfig = {
'VALID_ARCHS' => ['armv7', 'armv7s', 'arm64']
}
but unfortunately it produced no effect. And I literally don't know what to do. Can anyone help me?
This is probably the same or similar issue around VALID_ARCHS being deprecated in Xcode 12 and EXCLUDED_ARCHS needed.
s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
Try this:
s.pod_target_xcconfig = { 'VALID_ARCHS' => 'armv7', 'armv7s', 'arm64' }

Can't debug my iOS project since updating to cocoa pods to use_frameworks! for Swift

After cocoapods 0.38.0 I updated my project to use_frameworks! so that I can make use of Swift modules.
Now whenever I try and debug via lldb I get the following error:
error: Error in auto-import:
failed to get module 'my-app-name' from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Path/To/Project/Pods/Target Support Files/FBSDKCoreKit/FBSDKCoreKit-umbrella.h"
^
/Path/To/Project/Pods/Target Support Files/FBSDKCoreKit/FBSDKCoreKit-umbrella.h:6:9: note: in file included from /Path/To/Project/Pods/Target Support Files/FBSDKCoreKit/FBSDKCoreKit-umbrella.h:6:
#import "FBSDKAppLinkResolver.h"
^
/Path/To/Project/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkResolver.h:26:10: error: include of non-modular header inside framework module 'FBSDKCoreKit.FBSDKAppLinkResolver'
# import <Bolts/BFAppLinkResolving.h>
^
could not build Objective-C module 'FBSDKCoreKit'<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Path/To/Project/Pods/Target Support Files/FBSDKLoginKit/FBSDKLoginKit-umbrella.h"
^
/Path/To/Project/Pods/Target Support Files/FBSDKLoginKit/FBSDKLoginKit-umbrella.h:3:9: note: in file included from /Path/To/Project/Pods/Target Support Files/FBSDKLoginKit/FBSDKLoginKit-umbrella.h:3:
#import "FBSDKLoginButton.h"
^
A fatal parse error has occurred. LLDB may become unstable; please restart your debug session as soon as possible.
I did a bit of digging and found that if you set Allow Non-modular Includes in Framework Modules to yes for the FBSDKCoreKit target in the Pods project, that fixes the LLDB errors.

Resources