Google NearbyMessages cocoapod generates “duplicate output file” error - ios

I’m having a problem with NearbyMessages in Xcode 11.2. When I add pod 'NearbyMessages' and then do pod install, when I open the xcworkspace, I get a “duplicate output file” error resulting from the Assets.car that is generated by “[CP] Copy Pods Resources” build phase:
warning: duplicate output file '/Users/.../DerivedData/NearbyDemo-elvzmjtrsxnstlemqnzociqoajhv/Build/Products/Debug-iphonesimulator/NearbyDemo.app/Assets.car' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/.../DerivedData/NearbyDemo-elvzmjtrsxnstlemqnzociqoajhv/Build/Intermediates.noindex/NearbyDemo.build/Debug-iphonesimulator/NearbyDemo.build/Script-EB8FCF95DAAD8AF429AAA51F.sh (in target 'NearbyDemo' from project 'NearbyDemo’)
I’ve searched and found old issues, e.g., Google Nearby Messages API Broke App Icon, that seem like they might be related. That post looks like it might be an earlier manifestation of the same problem with assets and NearbyMessages, but it looks like the old compiler may not have caught this error.
In Xcode 10.3, this is merely a warning:
ignoring duplicated output file: '/Users/.../DerivedData/NearbyDemo-elvzmjtrsxnstlemqnzociqoajhv/Build/Products/Debug-iphonesimulator/NearbyDemo.app/Assets.car' in shell script build phase '[CP] Copy Pods Resources'. This warning represents an extremely serious project misconfiguration and will likely cause some shell scripts in your project to be skipped entirely, leading to other build failures or missing files in the build directory. This will be a hard error in the future. (in target 'NearbyDemo’)
Does anyone know of anyway to resolve this? I can downgrade Xcode, probably letting this problem pass without a hard error, but that’s not a terribly appealing solution.
It probably isn’t relevant, but here’s my Podfile:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'NearbyDemo' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for NearbyDemo
pod 'NearbyMessages'
end
I’m using Cocoapods 1.8.4 and Xcode 11.2 (11B52) on macOS 10.15.1.
I’ve posted a “Nearby Messages API for iOS - Product feedback” report, but was wondering if anyone has found a workaround in the interim.

After some searching, I found a workaround that should help with this behavior. You can achieve this by changing Xcode settings to use the old build system.
Xcode / File / Workspace Settings / Build system / select "Legacy
Build System"
If you need further information, check out this link
- https://github.com/CocoaPods/CocoaPods/issues/8122

Related

Error - linker command failed with exit code 1

I'm new to XCode Mac and IPhone development. So probably I'm missing something obvious here.
While trying to build the project I'm getting the following warnings and error. I can't figure out what is wrong here, I've looked at this answer and checked my Framework Search Path value and there is none in BuildSettings.
ld: warning: directory not found for option '-F/Users/macbook/Desktop/<app_name>__main/build/Release-iphoneos'
ld: warning: directory not found for option '-F/Users/macbook/Desktop/<app_name>__main/build/Debug-iphoneos'
ld: framework not found Pods_<app_name>
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've been banging my head for several hours now and finally given up.
The path mentioned in the error does not exist and when I looked into where build folder is located in XCode project, I realized they are in a shared directory ~/Library/Developer/Xcode/DerivedData. So I don't understand why XCode is looking for these files in the project's relative path, where build folder doesn't exist.
I'm using
XCode 10.1
CocoasPod 1.5.3 1.8.4
MacOS High Sierra
Note: The same workspace builds successfully on another system.
Edit:
If I copy the project.pbxproj from the other system onto this one, the project on this machine builds successfully too. project.pbxproj is located under *.xcodeproj file.
Also if I select Generic iOS Device the project builds fine, but as soon as I switch to any other target device I get the same error.
Edit 2:
I see a couple of framework files in red in the left side folder/directory's panel.
Foundation.framework
Pods_<application_name>.framework
Solution:
So right now I've found a solution what I believe to be a workaround and not the actual solution.
In my project's folder structure I saw multiple .framework files in red. some of them had different extensions then the ones present in the xCode package. So I updated them with the newer extension files and that got rid of most of the red file frameworks and left just one Pods_.framework the same framework in the error above. I removed the framework from the Libraries and Framework list in the General section. After I did that project build fine and I was able to run the app.
However, I noticed the Pods_<app_name>.framework file is always regenerated after running pod install. So I have to manually remove this unwanted dependency from the list each time starting a new workspace which is pain to say the least.
And so now I'm looking for a way to correct this so I don't have to remove the Pods_<app_name>.framework file each time.
While I was searching for the solution I found a closed cocoapods bug which reported the same issue for an older version. I've lost the thread and cannot find it again otherwise I would've linked the bug.
As noted in one of the answer's comment I now have updated cocoapods version 1.8.4.
Edit 3:
Podfile
# Uncomment this line to define a global platform for your project
# platform :ios, '7.0'
# Uncomment this line if you're using Swift
use_frameworks!
target '<app_name>' do
pod 'Google-Mobile-Ads-SDK', '~> 7.39.0'
end
Based on your comment and build logs I believe the podfile Pods_<application_name> is not available to your project(its added but not downloaded).
Pods are a way to share code across projects and maintain versioning.
You just need to update the pod so that it gets downloaded and added to your project. For that just launch Terminal app, cd to your project folder and fire pod update (you may refer to https://freakycoder.com/ios-notes-12-how-to-update-pods-249ecf88fe57)
If you do not have pod installed you can head to https://guides.cocoapods.org/using/using-cocoapods.html
I used to run into that problem once but I already solved it the same way #alxlive answer and it worked.
The problem happened to me because of the pod that we already installed.
During that time, I already installed my cocoapod for my project. Then, I added 2 new Build Configurations.
Your problem might be the same because you did mention copying others project.pbxproj from other system and it made your project work fine. So that might be the case.
By deintegrate and install the pod back on, that will solve the problem.
Xcode has different build system for simulator and real devices. So it will generate different app for both. If you select any Simulator target then it will builds app for simulator and if you select Generic iOS Device or any real device target then it will builds different build.
May be you are using some frameworks which are builded for iOS devices, So
follow this steps,
Differentiate that frameworks which gives you an error and remove that pods from your pod file and run pod install command and delete DerivedData.
Download that framework's code in your system.
Add project files of framework in your workspace. For that you can refer this and this.
If you don't want to add whole code of framework in your project then you can add particular( for device or simulator ) build of framework in your xcode project.
For that follow this steps,
Open your downloaded project of framework.
Select any simulator target and build project.
Get generated .framework file from Products folder.
Add this framework in your project like this.
Now build your project for simulator.
Follow above steps for devices target if you want to build for devices.
For Google Mobile Ads you can follow this guidelines. Add the -ObjC linker flag to Other Linker Flags in your project's build settings
I hope this will work for you.
Adding -ObjC $(inherited) in the Other Linker Flags fixes my issue
For me it was due to having a space in the Configuration name like "Development Debug". Once I removed the space and made it "DevelopmentDebug", the error message went away.
The pods need to be installed once per mac. The configuration set in the project.pbxproj depends on the Cocoapods version and the Xcode version on the machine.
Try the following:
1 - Delete the Podfile.lock file and the Pods folder from the local project
2 - Delete the content of the Derived Data folder: ~/Library/Developer/Xcode/DerivedData
3 - Run the command:
pod deintegrate
4 - Run the command
pod install
5 - Run the project again

Error building IOS App after installing pod file

I was installing the pod
pod 'Carte'
The library also wanted me to paste this line at the bottom of my pod file:
post_install do |installer|
pods_dir = File.dirname(installer.pods_project.path)
at_exit { `ruby #{pods_dir}/Carte/Sources/Carte/carte.rb configure` }
end
After running pod install the library was installed, however, I was getting warning messages in the terminal about
always embed swift standard libraries
I searched up and found a few Solutions. and found that settings them to $(inherited) worked for most people. I did this, cleaned and pod install again and nothing changed. I also saw someone changing
always search users paths
to $(inherited) too, so did this. The error is still there.
On building my project. I also get the error
Cycle inside APPNAME; building could produce unreliable results
To which I found changing to the legacy build system would do the trick, however, I do not want to change to the legacy build system. I do not understand why the messages have appeared. I have removed pod 'Carte' from the pod file and the line they wanted me to paste and I still get the error after installing again. I also tried deleting both the pod file and pod lock file, deleting the xcworkspace file and reinstalling the pod file and still, the error remains. Does anyone have a solution to this? Thank you.
from inspecting that error I found this:
error: Cycle inside TARGET; building could produce unreliable results.
Cycle details:
→ Target 'TARGET' has compile command with input '/Users/andrewharris/Desktop/TARGET/TARGET/TARGET/Notifications/AcceptedRemovedRequest/AcceptedRemovedCell.xib'
○ Target 'TARGET' has target dependency on Target 'OneSignalNotificationServiceExtension'
○ That command depends on command in Target 'TARGET': script phase “[Carte] Pre Script”
I think that somehow Carte has not uninstalled in some way?
I managed to solve this error by inspecting it a little closer. Inside the error:
Cycle inside TARGET; building could produce unreliable results
It told me it had something to do with the target OneSignalNotificationServiceExtension I looked in the target and found in build phases there was still [Carte] Pre Script and [Carte] Post Script and so I deleted both. I also deleted the target and recreated it just in case. I also did the same in my AppName Target and deleted both the Pre and Post script. Afterwards, I cleaned and ran the project to which it succeeded.

Xcode 10 Error: Multiple commands produce for 'app' and 'appex'

I got the recently discussed "Xcode 10 Error: Multiple commands produce..." error, but for the resulting app and appex file of my project. Does anyone have an idea what this means. My project has one app and two extensions (only one is part of the error).
Showing Recent Messages
Prepare build
note: Using new build systemnote: Planning buildnote: Constructing build description
Build system information
error: Multiple commands produce '/Users/xxx/Library/Developer/Xcode/DerivedData/MyApp-enqofdpadskdcgemmhrzsxahnjet/Build/Products/Debug-iphoneos/MyApp Dev.app':
1) Target 'MyApp Dev' has create directory command with output '/Users/xxx/Library/Developer/Xcode/DerivedData/MyApp-enqofdpadskdcgemmhrzsxahnjet/Build/Products/Debug-iphoneos/MyApp Dev.app'
2) That command depends on command in Target 'MyApp Dev': script phase “[CP] Copy Pods Resources”
Build system information
error: Multiple commands produce '/Users/xxx/Library/Developer/Xcode/DerivedData/MyApp-enqofdpadskdcgemmhrzsxahnjet/Build/Products/Debug-iphoneos/MyApp Dev Share Extension.appex':
1) Target 'MyApp Dev Share Extension' has create directory command with output '/Users/xxx/Library/Developer/Xcode/DerivedData/MyApp-enqofdpadskdcgemmhrzsxahnjet/Build/Products/Debug-iphoneos/MyApp Dev Share Extension.appex'
2) That command depends on command in Target 'MyApp Dev Share Extension': script phase “[CP] Copy Pods Resources”
Build system information
warning: ignoring duplicated output file: '/Users/xxx/Library/Developer/Xcode/DerivedData/MyApp-enqofdpadskdcgemmhrzsxahnjet/Build/Products/Debug-iphoneos/MyApp Dev.app' (in target 'MyApp Dev')
Build system information
warning: ignoring duplicated output file: '/Users/xxx/Library/Developer/Xcode/DerivedData/MyApp-enqofdpadskdcgemmhrzsxahnjet/Build/Products/Debug-iphoneos/MyApp Dev Share Extension.appex' (in target 'MyApp Dev Share Extension')
Build failed 18.09.18, 10:28 4.5 seconds
I know I can go back to the legacy build system, but I would prefer using the new and faster build system. Thank you for any help.
In case someone is still struggling with this after updating cocoapods and reinstalling pods:
Open Build Phases of the target which gives you problems
Open Copy Pods Resources phase.
Make sure the Output Files is empty. In my case I had a strange entry ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}. I removed it and the build was successful
Solved my problem by updating Cocoapods from 1.4.0 to 1.5.3
I was able to fix it by opening the Runner workspace project in Xcode 10. Then navigate to File, Workspace Settings and change the build system to Legacy Build System.
My Cocoapod version was already 1.5.3(latest).
Just running "pod install" (or "pod install --no-repo-update" if you don't want to update existing pods) solved it for me.
My workaround:
Check your pod version pod --version.
Update Coacoapods to latest version - v1.5.3 if it's not, by running sudo gem install cocoapods
Update all your pods by running pod update
Remove duplicate info.plist file from Target>Build Phases>Copy
Bundle Resources if any.
set "Build System" to "Legacy Build System" in "Shared Workspace Settings" which you can find in "File --> Workspace Settings"
Works form me:
Update Cocoapods
Delete pod file (Don't forgot to copy the contents some where else, so you can restore it)
Delete workspace project file
Delete lock pod file
Delete pod directory
Close the Xcode
Initialise pod
Install pod
Open the workspace project.
One of a possible issues causing the "Multiple commands produce" error may be several targets with conflicting module name. In my case I had a main application target and a notification service extension target with the same Product Module Name, so Xcode was trying to create two ModuleName.swiftmodule files, two ModuleName.swiftdoc files etc. Changing notification service extension module name fixed the problem.
You might have ran into this CocoaPods issue which is caused by this Xcode issue
This reply might help you, it suggest to specify the subspecs explicitly in your Podfile.
For example use pod 'SDWebImage/Core' instead of pod 'SDWebImage'
Apparently, this causes the build product path to always contain the subspec name which might fix the issue.
The key was to do pod deintegrate and rm *.workspace file !
In my case, there was duplicate reference in Copy Bundle Resources of App Target.
I just removed one of them and it worked.
If your error is not gone by updating cocoa pods then simply create new project but change folder location. you will not get this error.
I had a problem like this . . . The solution worked for me was
Go to your Project Target and delete the dupicate reference of your file under the Copy Bundle Resources.
Hope this helps!!!
My problem was rather unique.
I had a unit testing target that had a host application as "Target1"
I had a separate ui testing target that had a host application as "Target2"
I also had Target2 being capable of testing using both my test targets.
The solution was to remove the unit test target from Target2 test (inside edit scheme).
I could also have both my testing targets use the same host application (which I will)
For me, it was a scheme that lost its PRODUCT_NAME after a merge conflict.
To know if this is your problem, you can go to build settings and search for PRODUCT_MODULE_NAME if you see one of your schemes missing it, that's your problem. for me, I fixed it by adding PRODUCT_NAME = <my app's product name like shown under other schemes> to <appName>.xcodeproj/project.pbxproj under the relevant scheme.
But you can probably get it done in Xcode's build settings
I had the same problem with Xcode 10 GM. In my case below solution worked.
Check-in Project -> Build Phases -> Copy Bundle Resources have files with the same name. Just remove the repetitive file

Cocoapods Completely Broke

To start: I'm using Cocoapods 0.37.2, XCode 6.3.1 compiling for iOS 8.3
My project worked just fine before I ran a basic "pod update" now it's completely refusing to compile. I'm quite positive this has nothing to do with the pods themselves. Specifically the error I'm getting is this:
ld: warning: directory not found for option '-F/Users/user_name/Library/Developer/Xcode/DerivedData/AppName-bjozswzeepmhacfkeimeepxzcxgb/Build/Products/Debug-iphoneos/include'
ld: library not found for -lPods-AppName-AFNetworking
Podfile is this:
# Uncomment this line to define a global platform for your project
platform :ios, "8.0"
def shared_pods
pod 'SocketRocket'
pod 'AFNetworking'
pod 'DateTools'
pod 'Spotify-iOS-SDK'
end
target "AppName" do
shared_pods
end
target "AppNameTests" do
shared_pods
end
I have cleared DerivedData (many many times), cleaned my builds, restarted XCode, restarted my machine, I have ensured my config files and linker config lists are set up correctly. I've been using Cocoapods for years and never had this much trouble.
Completely frustrated and confused... questioning sanity.
Any help?
Information from CocoaPods troubleshooting doc. Hope this helps you.
If Xcode complains when linking, e.g. Library not found for -lPods, it
doesn't detect the implicit dependencies:
Go to Product > Edit Scheme
Click on Build
Add the Pods static
library, and make sure it's at the top of the list
Clean and build again
If that doesn't work, verify that the source for the spec you
are trying to include has been pulled from GitHub. Do this by looking
in /Pods/. If it
is empty (it should not be), verify that the
~/.cocoapods/master//.podspec has the correct git hub url
in it.
If still doesn't work, check your Xcode build locations
settings. Go to Preferences -> Locations -> Derived Data -> Advanced
and set build location to "Relative to Workspace".

dyld: Library not loaded with cocoapods 0.37 and Xcode 6.3

I've been reading all the issues about the error:
dyld: Library not loaded: #rpath/Bolts.framework/Bolts
Referenced from: /private/var/mobile/Containers/Bundle/Application/1542F906-CCE1-4181-AC7C-B5E3EE50E7D7/eBikeMotion.app/eBikeMotion
Reason: no suitable image found. Did find:
Which makes my application unable to run in a real device (but it runs without any problem in the simulator.
Until certain point I thought that it was an issue with the frameworks I was installing, but after installing manually the original one that was throwing the error, Alamofire, and the next Framework throwing the error was the next one in alphabetical order (Bolts, as you can see in the code snippet)
So I've reached the conclusion that is indeed CocoaPods which is producing these errors. I've got the last version (0.37) with a clean install, Iv'e tried to create a new project, I've tried all the proposed solutions to this issue without any luck, so I have to open an issue, with the hope that someone can help me.
Regards.
After reinstalling the whole system and don't finding a solution, I've found that some of the Build Phases mandatory for CocoaPods to run properly were missing.
The solution for this problem goes for the next steps:
Deintegrate the cocoapods project (you can install the tool with sudo gem install cocoapods-deintegrate).
cocoapods-deintegrate on Github
Modify your Podfile:
You should define your target linking with link_with 'ProjectName'.
You should define the target for your pods: target 'ProjectName' do [pods here] end.
Make an install with pod install
After doing this, go to XCode and check the following settings:
Into project settings, under "Configurations" check that in Debug and Release you've got a Configuration set named Pods-ProjectName.[debug|release]
Into your target, under "Build Phases" you should have three new phases that should be named: Check Pods Manifest, Embed Pods Frameworks and Copy Pods Resources.
Make a clean, then build, then run into your device.
That's it.
In my case, I followed the above answer by #Jorge, but it didn't resolve the problem. The exact error was a bit different because the missing file was #rpath Pods.framework/Pods. I finally resolved it with help from CocoaPods issue #3586:
Go to target > General > Linked Frameworks and Libraries section
set both Pods.framework and Pods_target.framework to Optional.
Still trying to figure out exactly why.... this answer has some info: what-does-it-mean-to-weak-link-a-framework
I had to fix two issues:
Go to each target then Build Phases then Link Binary With Libraries and select Pods.framework. Set it to Optional.
Cocoapods did not create the needed run scripts for my second target. My first target had all scripts. The second not. So I copied all missing run scripts from the first to the second target. You need to tap on the small "+" sign on the top left, add a run script and paste the script from the other target. I've done that for Check Pods Manifest.lock, Copy Pods Resources and Embed Pods Frameworks.
Then it did run on the device. Finally.
Had same issue adding pods to WatchKit Extension. Linking main target with Watch app is not the best option at all. Found out that cocoapod 0.37.2 hasn't added 'Embed Pods Frameworks' script into build phase.
Script:
"${SRCROOT}/Pods/Target Support Files/Pods-ExtensionName/Pods-ExtensionName-frameworks.sh"
In order to have cocoapods generate the build phases Check Pods Manifest, Embed Pods Frameworks and Copy Pods Resources:
1 - Go to build phases and remove any custom modifications. I had to remove everything under the Link Binary With Libraries phase.
2 - Do a pod deintegrate (Or just remove the files yourself)
3 - Run a new pod install
This worked for me. Without the first step, it never did.
To Resolve this you need to change status in Link Binary with Libraries in build phase for pod_projectName.framework and Bolt.framework
I got the same error in my project.
get error in CommonCrypto.framework
Resolved error by changing Required to Optional
The easiest thing to do would be to ensure that your Protobuf.framework is a dependency in your target's scheme inside the Build step.
This tells Xcode to compile the Protobuf.framework created by your pod install/update whenever it builds your target.

Resources