Xcode 11.1 Error: Multiple commands produce - ios

I see that there are several other questions regarding this problem.
Like: Xcode 10 Error: Multiple commands produce
I am asking this a new because it is for Xcode 11.1 and not older version and I think that the other questions have too many responses and people easily can get lost in them. Here we can try to answer using newer information with quicker access.
After update to Xcode 11.1 and update of cocoa pods ( no pods were actually updated, only the pods project was regenerated ).
I started to get the following error with FBSDK:
Multiple commands produce '/Users/myUser/Library/Developer/Xcode/DerivedData/myProject-euqkymjpeftprkgkcjyqpnkbalbr/Build/Products/Debug-iphoneos/FBSDKCoreKit-iOS/FBSDKCoreKit.framework/PrivateHeaders/FBSDKRestrictiveDataFilterManager.h':
1) Target 'FBSDKCoreKit-iOS' (project 'Pods') has copy command from '/Users/myUser/Documents/Workspace/myProjectDir/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/AppEvents/Internal/FBSDKRestrictiveDataFilterManager.h' to '/Users/myUser/Library/Developer/Xcode/DerivedData/myProject-euqkymjpeftprkgkcjyqpnkbalbr/Build/Products/Debug-iphoneos/FBSDKCoreKit-iOS/FBSDKCoreKit.framework/PrivateHeaders/FBSDKRestrictiveDataFilterManager.h'
2) Target 'FBSDKCoreKit-iOS' (project 'Pods') has copy command from '/Users/myUser/Documents/Workspace/myProjectDir/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/AppEvents/Internal/RestrictiveDataFilter/FBSDKRestrictiveDataFilterManager.h' to '/Users/myUser/Library/Developer/Xcode/DerivedData/myProject-euqkymjpeftprkgkcjyqpnkbalbr/Build/Products/Debug-iphoneos/FBSDKCoreKit-iOS/FBSDKCoreKit.framework/PrivateHeaders/FBSDKRestrictiveDataFilterManager.h'

I let you know my case. It was related to a Cocoapod Library installed.
The normal steps to install a Cocoapod is, after running the pod install, then you use to go at your "import library section" in your project, then add it.
I removed the library from there, and the problem disappeared instantaneouslly.
Anyway, to use the library still you need to import it as always in your files.
import YourLibrary
class your {
}
Shows the place where the library must be removed from.

In my case the problem was the that those files :
FBSDKRestrictiveDataFilterManager.h
FBSDKRestrictiveDataFilterManager.m
were added twice in the FBSDKCoreKit-iOS project. I deleted the older ones ( by comparing the actual SDK code from GitHub ). I don't know who is to blame Cocoa Pods or Facebook, but if you get that error or some kind of similar one regarding the same file, I suggest that you check for file duplicates.

Related

"Redefinition of module ..." when building for simulator

I have an iOS xcode project that builds fine when I have Generic iOS Device selected as my destination. However, when I select any of the simulator options I the build fails with many Redefinition of module 'abcde', one error for every module defined in iOS 11.4/usr/include/module.modulemap.
The duplicate definitions are coming from Simulator - iOS 11.4/usr/include/module.modulemap. I've combed through my workspace/project settings and found no reference to the simulator. All the deployment targets are iOS 11.4.
It appears that when I build for the simulator it is including both the platform and simulator modules. How can I specify one or the other?
This problem popped up out of the blue about a day after adding cocoapods and swift code but I don't know if it is related. (The sdk/deployment targets for the pods are also iOS 11.4 and swift version is 4 (except for Socket.IO which is using 3)).
My pods project is using the generated modulemap (I haven't edited it at all):
framework module Pods_MyProjectName {
umbrella header "Pods-MyProjectName-umbrella.h"
export *
module * { export * }
}
I've googled this problem over and over and haven't been able to find any solution for it. I've tried cleaning and rebuilding, deleting the contents of the Library/Developer/Xcode/DerivedData folder, deleting the pod's modulemap file, commenting out each line of the pod's modulemap file, removing all the code written since the problem began... I have the feeling that I'm looking in all the wrong places.
I had the same issue with other pods. I assume the issue has to do with recursive dependecnies that are also imported explicitly. I tried all the same things as you did, although the only thing that helped me was to close xcode, run
pod deintegrate
pod install
and rebuild.

Why can't XCode find GoogleMobileAds

I know this has been asked before and I've reviewed the other answers. I have closed XCode and run pod install multiple times. When I re-open XCode I use the .xcworkspace project file. And I have checked that my target -> Build Phases -> Link Binary With Libraries section includes GoogleMobileAds.framework
So why am I still getting No such module 'GoogleMobileAds' as a build error?
(Note I did used to get a link error previously and following some other stackoverflow Q&A I deleted the directories that were showing up in link errors from the Library Search Paths.)
Try build your project once. It will first compile the pods project(thus compiling the GoogleMobileAds framework), then stop the build when it starts to compile your swift code, or you can let it finish if you want. After that, you should be able to see the framework and use it for auto-completion. I have personally found this much faster than to wait for Xcode to pre-build and index.

Can't Use "Vendored Framework" CocoaPod Inside Workspace Playground

I've created a sample project illustrating my issue here.
In summary, I'm trying to use a "vendored framework" CocoaPod inside a workspace playground. I think this is possible but requires a bit of fiddling with project settings, and I can't quite figure out what to change.
To observe the issue in the sample project, do the following:
Open CocoaPods-Test/CocoaPods-Test.xcworkspace in Xcode.
Pods should be installed and committed in the repository, but can run pod install if necessary.
Note that the CocoaPods-Test target builds and runs successfully, importing PromiseKit and TwilioChatClient pods.
Navigate to Playground.playground within the workspace.
Note that the playground executes fine while importing PromiseKit but if TwilioChatClient is imported, playground execution fails with "no such module 'TwilioChatClient'".
After reading the following resources:
https://github.com/CocoaPods/CocoaPods/issues/5334
https://github.com/CocoaPods/CocoaPods/issues/5215
https://github.com/CocoaPods/CocoaPods/issues/5563
https://github.com/CocoaPods/swift/issues/3
https://github.com/CocoaPods/CocoaPods/issues/4135
https://github.com/CocoaPods/CocoaPods/issues/2240
https://github.com/CocoaPods/CocoaPods/issues/6669#issuecomment-300188519
https://guides.cocoapods.org/using/troubleshooting.html
https://www.objc.io/issues/6-build-tools/cocoapods-under-the-hood/
I think the issue is probably related to the fact that TwilioChatClient is a "vendored framework" (see its podspec), which means a pod target is not created for it. After reading the above resources, I feel like a solution is within reach, but I can't quite figure it out.
While the sample project here illustrates what I think is the underlying issue, the issue that prompted me to create this example project is just a small bit more complicated.
In my project, I create a framework target containing all my app's code (so it can be imported into my app and also into my playgrounds using app resources). This framework then has pod dependencies, including PromiseKit and TwilioChatClient. The execution error in the playground is different ("Couldn't lookup symbols" instead of "no such module"), as I am not importing the CocoaPods module directly but my framework which uses the pod framework.
I suspect if I can solve the "no such module" issue, it will help me solve my "couldn't lookup symbols" issue.
Finally, this seems like a good opportunity to make an open source contribution others don't seem to have wanted to do (see discussion here). Tangentially, I'd love to contribute but just don't feel like I understand what exactly is going on with CocoaPods, the Xcode build process, etc., after reading about it a bit (e.g. here and here). Any references to help understand the Xcode build process and what CocoaPods is doing under the hood are appreciated. It seems like the resources I've found are either "a very high level overview" (which I get), or "digging through the source code", with not a whole lot in between.
If you must have this work, I came up with a workaround by creating a framework target inside the Pods project which is named the same as the vendor framework, and uses all its headers publicly, using the framework as a sole dependency. I have forked your GH example and linked it here.
It's not the most elegant solution, but it will help you out in a pinch.
UPDATE
Build "fake" framework first, then build app target, then go to playground.

Are there different ways to include Objective-C pods in swift xcode xcworkspace projects post pod install?

Using pod dependencies, the import behavior is inconsistent.
This behavior is different on different machines for the same pods in Podfile. After successfully installing pods, my team came across the following two situations.
On one it worked through the #import statement in the bridging-header.h file but throws
No such module '<moduleName>' error in the ViewController.swift file when tried that way.
While on another mac it threw errors in the bridging.h file and worked through import <moduleName> in the ViewController.swift file.
Both machines have Xcode 8.1, using Swift 3 syntax and cocoapods version is 1.1.1. We were able to re-create the issue multiple times.
Does anyone know why this happens and if there is some project setting which can be used to produce consistent reults?
We have experienced this behaviour also. We could sometimes 'solve' it via: product>clean.
Sometimes we even had to quit+restart xcode and run clean again.
We agree, it is strange behaviour, probably xcode is losing state information or something.

Xcode Cocoapods Not Finding Framework Header Files

So I am working on an old Xcode project that was developed by a separate developer and am having build errors when running on my Mac due to Cocoapods. The first error is "The sandbox is not in sync with the Podfile.lock”, which I can fix by removing the various Cocoapods files and the old xcworkspace from the project and running pod install in the terminal to create all of this again. The new issue is that some of the classes cannot find the header files from the podfile's listed frameworks.
My theory is because this is an old project and the old developer didn't put version caps on some of the frameworks in the podfile, is that the project is trying to use old methods / classes that are deprecated in the newest updated frameworks. However I am not sure how to get around this as I tried putting version caps on those frameworks in the podfile without any success.
There are two paths:
You investigate each framework, estimate the approximate pod version that could have been used at the time project was active, and use particular version of each pod (you can find info on configuring pod version here
This solution won't work in 90% of cases, however, as iOS is evolving really fast and old frameworks are most probably outdated and not compatible with latest changes.
You investigate each framework and understand what actually changed. You look at headers that each pod has, understand what actually changed and implement changes in your code.
You start with headers, making sure that you include the right ones, and then start migrating code to the newest versions.
Big projects usually have migration guides.
There are no other options. As soon as any project becomes dependant on external code, it's up to developers to ensure that it's up-to-date.

Resources