getting an issue with upgrade to Xcode 10.2 - swift

I have a series of errors after upgrading to the newest Xcode.
MyApp/Pods/Protobuf/objectivec/google/protobuf/Any.pbobjc.m:17:10: Non-portable path to file '<protobuf/Any.pbobjc.h>'; specified path differs in case from file name on disk
When I look at the code I see the path is indeed capitalised.
#import <Protobuf/Any.pbobjc.h>
Are there any suggestions how to deal with this issue?
My pod file looks like this:
# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'
target 'MyApp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for MyApp
pod 'Firebase/Core'
pod 'Firebase/Storage'
pod 'Firebase/Database'
pod 'Firebase/Firestore'
pod 'Firebase/Auth'
pod 'Firebase/AdMob'
# Pods for PodTest
pod 'Fabric'
pod 'Crashlytics'
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'MyAppUITests' do
# inherit! :search_paths
# Pods for testing
end
end
So far, I've tried deintegrating and reinstalling all pod files but the errors stick.

This is caused by the code being compiled on a case-insensitive filesystem, where the two files:
In the source code file Protobuf/objectivec/google/protobuf/Any.pbobjc.m -
Directory and file on your machine:
Both of these point to the same file on a cave-insensitive filesystem. That is, on a filesystem that treats the directories Protobuf and protobuf as the same.
BUT, if you copy that same directory structure to a case-sensitive filesystem, then the source code will be looking for a directory different from the one actually created on the case-insensitive filesystem.
This warning is basically a reminder that there is a "gotcha" just waiting to happen.
The ultimate answer is to have the protobuf CocoaPod fix the currently-17 warnings by changing their protocol buffer compiler.
Until then, you can "disable" this warning by adding the C++ compiler option "-Wno-nonportable-include-path" to either every file with this issue, or The project as a whole. This C++ Compiler option goes into the "Apple Clang - Custom Compiler Flags" section, in the "Other Warning Flags" line.

Please delete Derived Data,
You can go to File > Workspace Settings if you are in a workspace environment or File > Project Settings for a regular project environment. Then click over the little grey arrow under Derived data section and select your project folder to delete it.
Than deintegrate and reinstalling all pod files again.
Hope this works for you!

Related

Redefinition of module 'Firebase'

I'm trying to integrate Firebase into my app, but as soon as I'm building it after I thought I finished my install I get:
Redefinition of module 'Firebase'
as well as
Could not build Objective-C module 'SwiftOverlayShims'
which I have no idea what that means but I'm assuming its a result of the first.
My podfile looks like this:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'app' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
pod 'Firebase/Auth'
# Pods for app
end
So I don't think theres anything conflicting there. I saw a solution that told me to go into my Header Search Path and see if my project had multiple Firebase directories, but I have no custom paths, so that wasn't it. Any insight?
EDIT: Here is the exact display from my errors
Uncommenting the platform line in my podfile and changing it to iOS 10.0 did get rid of the error saying "Could not build Objective-C module 'Firebase'" So we have made some progress.
Here is the path when selecting "previously defined here"
From what I can tell, it is only giving me one location. Selecting the redefinition error just gives me the relative path of module.modulemap , so I am assuming that is referring to the same thing. I am also getting multiple warnings like this
Skipping duplicate build file in Copy Files build phase: /Users/me/Library/Developer/Xcode/DerivedData/app-elgcucdextsnzqbtlznbqeulbfks/SourcePackages/artifacts/Firebase/FirebaseAnalytics.xcframework/ios-arm64_i386_x86_64-simulator/FirebaseAnalytics.framework
as well as a couple other frameworks in the ios-arm64_i386_x86_64-simulator directory, so maybe that has something to do with it.

No such module RealmSwift

This is not a duplicate question.
I have been using realm for a long time. Recently I am getting the error of "No such module RealmSwift". But this is happening only in release target scheme not in build target scheme. Is there any particular reason as to why it is not working only in release? I have seen this question at a lot of places but none of those solutions worked for me.
My podfile looks similar to this:
# Uncomment the next line to define a global platform for your project
platform :ios, '12.0'
#use_modular_headers!
inhibit_all_warnings!
def shared_pods
pod 'RealmSwift'
end
target ‘************’ do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for ************
shared_pods
target '************Tests' do
inherit! :search_paths
# Pods for testing
end
end
target '************UITests' do
inherit! :search_paths
# Pods for testing
# shared_pods
end
This is more of a troubleshooting step than a direct answer since I duplicated your issue.
You've been using Realm a while so you know this but for future readers, ensure that any file where you're using RealmSwift includes
import RealmSwift
I just tried your podfile on a new project and am getting weird behavior as well. I replaced your podfile with the following 5 lines and it works correctly.
project 'Realm Test.xcodeproj'
target 'Realm Test' do
use_frameworks!
platform :osx, '10.13'
pod 'RealmSwift'
end
That was a macOS project but it worked equally well with an iOS project. On that project I uncommented #platform :ios, '12.0'
I think this is the issue
inherit! :search_paths
That lets the target know about the search paths but does not link them in. I would suggest changing that to
inherit! :complete
Which appears to be working in my project.
Oh - for completness, I ran into this once as well and the solution was
add the parent path of RealmSwift.framework (i.e., the containing
directory) to your framework search paths.
This is a common Realm bug which occurs in Xcode after pod install. Clean and Build the project once, the bug should go away!

Linking the same framework to multiple targets in CocoaPods

I have a Swift project with some local frameworks that are linked with the main app. One of the frameworks requires a CocoaPod that the main project also requires elsewhere. Obviously I'd only like one copy. That seems to work fine, but the unit tests are getting confused. This is a slightly simplified version of the Podfile:
platform :ios, '11.0'
inhibit_all_warnings!
use_frameworks!
# The main app target
target 'TheApp' do
pod 'Instabug'
target 'TheAppTests' do
inherit! :search_paths
pod 'OHHTTPStubs/Swift'
end
end
# A framework target that's linked by TheApp
target 'Logging' do
pod 'Instabug'
target 'LoggingTests' do
inherit! :search_paths
end
end
I believe I'm supposed to nest the test targets inside their subject. TheApp imports Logging. Both import Instabug. TheAppTests has a host application of TheApp. LoggingTests has not host application.
I get Pods-TheApp, Pods-TheAppTests, and Pods-Logging the way I expect. Sometimes I get Pods-LoggingTests and sometimes I get Pods-Logging-LoggingTests. (This turns out to be tied to the inherit setting. If it's not set, then I get Pods-Logging-LoggingTests; if it is set to search_paths then I get Pods-LoggingTests.)
I'm often getting errors that Instabug isn't copied into the LoggingTest bundle, or I get errors that Instabug has been processed twice. The app itself seems to work fine. It's just that unit tests fail. (There are several other local frameworks that don't have any dependencies, and I don't list them in the Podfile.)
Note that all the framework targets live in one xcodeproj.
I suspect I'm just writing the Podfile incorrectly. Is there a canonical way to handle local (non-pod) frameworks that have their own tests and their own dependencies that match the app's?
This is CocoaPods 1.7.0. I had the same issue with 1.6.2.
I faced the same issue and I personally found it much easier to manage pods in a linear way and creating helper methods for referring each pod. This way when you share a pod among projects, you update the pod version only in one place:
platform :ios, '11.0'
inhibit_all_warnings!
use_frameworks!
##
## Group pods
##
def alamofire_pods
pod 'Alamofire', ~> '4.0'
end
def snapkit_pods
pod 'SnapKit', '~> 4.0'
end
#
# Now, lets create all subprojects and main project pod dependencies
#
target 'MySubproject' do
project 'rel_path_to/subproject.xcodeproj'
alamofire_pods
target 'MySubproject Tests' do
inherit! :complete
end
end
# Following same pattern for all other subprojects
target 'MainProject' do
project 'Mainproject.xcodeproj' # path to main project
snapkit_pods
alamofire_pods
target 'Mainproject Unit Tests' do
end
end
target 'Mainproject UI Tests' do
# specific pods for your UI Test
end
This approach worked the best and helped with running also subproject tests in the project.
Rule of thumb, also always make sure to remove old pod references from your project. That was causing issues in my case and throwing errors when building for unit tests I believe for subprojects. Cocoapods doesn't clean the old pod target references from your project's build phase.
Note pod install shouldn't change the pod target name if you don't change anything in your podfile.
You can create abstract targets that your real targets inherit from, thereby having 2 sets of dependencies, some of which are shared.
This is what I do:
project "NSScreencast/NSScreencast.xcodeproj"
use_frameworks!
abstract_target "NSScreencast-Base" do
pod "Kingfisher"
pod "R.swift"
target "NSScreencast" do
platform :ios, "11.0"
pod "AppCenter"
pod "FXReachability"
pod "Colorkit"
pod "SVProgressHUD"
pod "1PasswordExtension"
pod "OneSignal", ">= 2.6.2", "< 3.0"
pod "Reveal-SDK", :configurations => ["Debug", "Debug-LocalServer"]
end
target "OneSignalNotificationServiceExtension" do
platform :ios, "11.0"
pod "OneSignal", ">= 2.6.2", "< 3.0"
end
target "NSScreencastTV" do
platform :tvos, "10.0"
end
end
This allows me to use the shared pods in multiple targets (here, iOS and tvOS) and have specific ones for each target as well.
Does this solve your problem?

"Missing required module" when pod library is installed in one Target only

I'm embedding frwkproject.xcodeproj product (frwkproject.framework) in the mainproject.xcodeproj project.
I am trying to use Firebase Library in the frwkproject.framework only. Using this cocoa pods:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
workspace 'frwkproject.xcworkspace'
abstract_target 'Shows' do
pod 'Toaster'
target 'frwkproject' do
project 'frwkproject/frwkproject.xcworkspace'
pod 'Firebase/Core'
pod 'Firebase/Crash'
end
target 'mainproject' do
project 'mainproject/mainproject.xcodeproj'
end
end
In the mainproject project I have imported the framework with:
import frwkproject
And this error appears: "Missing required module Firebase"
Importing the cocoa pods library in both projects avoids this problem. Like this:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
workspace 'frwkproject.xcworkspace'
abstract_target 'Shows' do
pod 'Toaster'
pod 'Firebase/Core'
pod 'Firebase/Crash'
target 'frwkproject' do
project 'frwkproject/frwkproject.xcworkspace'
end
target 'mainproject' do
project 'mainproject/mainproject.xcodeproj'
end
end
But Firebase will crash when imported in both project.
Is it possible to implement Firebase in the framework project only?
Ok, got exactly the same problem. Here is how I've resolved it:
added
pod 'Firebase/Core'
in a child project pod target
added
pod 'GoogleToolboxForMac'
pod 'nanopb'
in a main project pod target (these are dynamic pod dependencies of Firebase)
added recursive $(SRCROOT)/Pods/Firebase in main target Build Settings -> Header Search Paths (got that idea from here).
Hope that helps!

Google/Analytics.h file not found when Testing

I am including the BridgingHeader.h however on importing Google/Analytics.h it can't find the file.
This works fine in the application, it only throws the error under testing.
Not sure what the issue is so any insight would be greatly appreciated.
I had a similar issue and fixed it by adding the Google Analytics pod to both the tests and uitests targets by opening up your podfile and modifying it as shown:
target 'MyApp' do
pod 'Google/Analytics'
end
target 'MyAppTests' do
pod 'Google/Analytics'
end
target 'MyAppUITests' do
pod 'Google/Analytics'
end
Once that was complete I had to run pod install twice and then it worked.
Spent near 2 hours on searching and finally found correct solution to all that madness! Accepted solution above is working, but gives a lot of Class GAIUtil is implemented in both... warnings which is not quite right that means.
Solution
You need to use cocoapods 1.0.0.beta6+
Your test target should be defined in your Podfile as next:
target 'App' do
pod 'GoogleAnalytics' , '~> 3.0'
# your other pods
target 'AppTests' do
inherit! :search_paths
# your other testing pods/frameworks
end
end
Do pod update.
All that found there https://github.com/CocoaPods/CocoaPods/issues/4626#issuecomment-210402349