iOS/Google Ads giving Linker Code Failure - ios

Trying to insert Google Ads/Firebase into a test app. Suspect I've almost got this working but. Using the Google notes from https://firebase.google.com/docs/admob/ios/quick-start
When I compile I receive "Linker code failed with exit code 1":
ld: warning: directory not found for option '-L/Users/edward/Library/Developer/Xcode/DerivedData/TotalConversion-gtwxqoywudjqpodqkpfpwcnovyuz/Build/Products/Debug-iphoneos/GoogleToolboxForMac'
ld: library not found for -lGoogleToolboxForMac
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have created the Podfile as instructed with:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, ’7.0’
target 'TotalConversion' do
pod 'Firebase/Core'
pod 'Firebase/AdMob'
end
and then run a pod update. I don't see a .xcworkspace file referred to in the docs. Does the iOS, '7.0' line above need to be altered?
I presume that using pods GoogleAds is instead of the standard framework (Build Phases/Link Binary) approach.

If there is a linker error, this might be few things. First, check if you haven't open .xcodeproj instead of .xcworkspace by mistake. If not, the solution might be simple project cleaning by pressing cmd+shift+k. At last, check if those libraries are linked with project and are having status required in your target's general/build phases (Pods_YourProjectName.framework).
In Podfile you can actually comment out lines with source and platform by placing # in front of them. Go to terminal, cd to your project directory and try pod install once again, maybe that will do the job.
Sorry for not placing this in comments but my reputation doesn't allow me doing it.

The {projectName}.xcworkspace folder should be in the same folder as the .xcodeproj that you have open. Close Xcode {projectName}.xcodeproj instance and open {projectName}.xcworkspace using the Finder, command line, or Xcode open.

Related

Xcode error: library not found for -lGoogleToolboxForMac

I am trying to install admobs in my iPhone App (written in objective-c). I have implemented this many times using swift projects, but currently I keep getting the following build error:
ld: warning: directory not found for option '-L/Users/charlieseligman/Library/Developer/Xcode/DerivedData/ThamesClippers-csissodainpbbjenykdyxuutzxtg/Build/Products/Debug-iphonesimulator/GoogleToolboxForMac'
ld: warning: directory not found for option '-L/Users/charlieseligman/Documents/GIT/iOS.ThamesClippers/build/Debug-iphoneos/GoogleToolboxForMac'
ld: library not found for -lGoogleToolboxForMac
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I am definitely opening the .xcworkspace file (and not the .xcodeproj file).
I have also tried deleting 'DerivedData' folder contents & 'Cleaning' the project and doing a 'Clean Build Folder'. None has resolved the issue.
My podfile only includes the following pods:
# Pods for ThamesClippers
pod 'Google/Analytics'
pod 'Firebase/Core'
pod 'Firebase/AdMob'
# Trying to fix GoogleToolboxForMac missing error
pod 'Firebase/Messaging'
pod 'GoogleToolboxForMac/Logger'
pod 'GoogleToolboxForMac', '~> 2.1'
I have tried adding the bottom 3 one-by-one but kept getting the same build error.
Can anyone help? At a complete loss on this one. Seen these two questions but their accepted solutions have not resolved this issue:
Framework not found GoogleToolboxForMac
ld: library not found for -lGoogleToolboxForMac
Finally worked out a fix:
Xcode > Product > Scheme > Manage Schemes
Select to 'Show' the scheme that was failing (GoogleToolboxForMac)
Select this scheme in the dropdown, just to the right of the 'Stop' button
Build this scheme
Then select the original scheme (in the dropdown mentioned in step 3) and rebuild
All built correctly.
So it looked like I had to build the separate scheme manually.
Note: To build these automatically, use Product > Scheme > 'Edit Scheme' > Build > And make sure all targets are added with your project target at the bottom.
I got this error in Xcode 10 when building to the Simulator. This is because I deleted the Debug base configuration in the xcodeproj when attempting to resolve the Cocoapods warning:
"CocoaPods did not set the base configuration of your project because your project already has a custom config set."
I resolved the issue by:
Adding the Debug base configuration
Setting the Debug configuration value to None
Running pod install
This is how the base configuration should look like after step 3:
]1

Xcode: Cannot parse the debug map for .. is a directory

I'm trying to link my iPhone simulator project and I'm getting the following error at link time:
(null): error: cannot parse the debug map for "/Users/admin/Library/Developer/Xcode/DerivedData/TrainTracks-agvvryrtufplkxecblncwedcelck/Build/Products/Debug-iphonesimulator/TrainTracks.app/TrainTracks": Is a directory
Here's the linker output:
GenerateDSYMFile /Users/admin/Library/Developer/Xcode/DerivedData/TrainTracks-agvvryrtufplkxecblncwedcelck/Build/Products/Debug-iphonesimulator/TrainTracks.app.dSYM /Users/admin/Library/Developer/Xcode/DerivedData/TrainTracks-agvvryrtufplkxecblncwedcelck/Build/Products/Debug-iphonesimulator/TrainTracks.app/TrainTracks
cd /Work/TrainTracks/TrainTracks
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil /Users/admin/Library/Developer/Xcode/DerivedData/TrainTracks-agvvryrtufplkxecblncwedcelck/Build/Products/Debug-iphonesimulator/TrainTracks.app/TrainTracks -o /Users/admin/Library/Developer/Xcode/DerivedData/TrainTracks-agvvryrtufplkxecblncwedcelck/Build/Products/Debug-iphonesimulator/TrainTracks.app.dSYM
error: cannot parse the debug map for "/Users/admin/Library/Developer/Xcode/DerivedData/TrainTracks-agvvryrtufplkxecblncwedcelck/Build/Products/Debug-iphonesimulator/TrainTracks.app/TrainTracks": Is a directory
What would cause this problem?
I started off with a Game template (Xcode 7.2.1) and deleted the main story board and AppDelegate.* files since this is an SDL cross-platform project.
This problem was caused by a second inclusion of a TrainTracks folder in my project. I already had a yellow TrainTracks group with all of my source but for some reason Xcode was also showing a blue TrackTracks folder as well. This has a duplicate info.plist and other files. I removed the blue folder reference and the project now builds successfully.
If you are using CocoaPods, and you get this error after changing the name of your Target, click on your target, go to the General tab, scroll down to "Linked Frameworks and Libraries" and then delete the following library:
libPods-YourOldTargetName.a
For me this error was the inclusion of the same .m file twice in the project. Happened while moving some files around. Quit Xcode, clean and it told me the file in a linker error.
I ran into this problem trying to run my tests, and it was because my test target required the use of one of the pods I had in my Podfile. To fix it I just added my test target to the Podfile and included the relevant pods, as per the following pattern:
workspace 'myproject.xcworkspace'
platform :ios, '8.0'
use_frameworks!
def shared_pods
pod 'RealmSwift', '~> 2.8'
end
project 'myproject.xcodeproj'
target :MyProject do
project 'myproject.xcodeproj'
shared_pods
end
target :MyProjectTests do
project 'myproject.xcodeproj'
shared_pods
end
In my case, this same error showed up because one of the frameworks used in the app was compiled without Bitcode, so I had to turn off Bitcode for the entire project.
In my case, I had made a duplicate of one of my .m files in the finder to keep as reference, and somehow (most likely my error) it was added to the project explorer. The real error was duplicate definitions since the class appeared twice. Removing the "ClassNameHere_copy.m" fixed the issue.
For me, it was because I changed my target name which made a new cocoa pods .a library but didn't remove the other from linking.
In My case I had to delete my entire repository and clone again, nothing else worked, after fresh cloning, I ran a pod install and it worked.

CocoaPods Google Analytics .xcworkspace and .xcodeproj files

I have an error in .xcodeproj:
ld: framework not found Pods (null): Linker command failed with exit
code 1 (use -v to see invocation)
I found the mistake the pod install folder was good, but I have to build the .xcworkspace, but I don't know why they're the error on .xcodeproj, and if it can be a problem on application deployment someone know why they're the error ? How to hide this error ?
Follow this steps:
Make sure close all Xcode Projects. (.xcworkspace and .xcproject) (sometimes .xcproject still open)
Run pod install and pod update
Open the ProjectName.xcworkspace
Clean and Build your Project
After that you should be able to run normally.
As cocoapods states when you setup cocoapods in your projects the first time, you need to use xcworkspace from now on. You can't work on xcodeproj directly. This is because it needs to have both Pods and your app project open at the same time.
Just close your xcodeproj and never open it again. Always open the xcworkspace and always work from there as long as you are using cocoapods in your project.

How to remove all references to a library?

I have a pretty classical error during my project building:
ld: library not found for -lAppLovinSdk
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Originally I got the library from Cocoapods pod, but then I started having a lot of errors and decided to remove the pod from the Podfile and executed pod update
My Podfile looks like this:
I've tried to clean project, reinstall the Podfile, deleting Pods folder and Podfile.lock file, "Build Active Architecture Only" is set to "No", but I still have the error. I assume I still have some references to libraries from the deleted Pod. What is the way to get rid of them?
UPDATE: Here is a full error message:
Ok, so I figured out the problem:
I had to go to Target -> Build Settings -> Linking -> Other Linking Flags and there I had to remove all deleted libraries references, manually. And then it worked!

How to remove duplicate files generated through cocoa pods in iOS

I am using cocoa pods to integrate multiple third party files into my project.
I have to integrate below pod into my project
xcodeproj 'MyApp'
workspace 'MyApp'
source 'https://github.com/CocoaPods/Specs.git'
target :"MyApp", :exclusive => true do
platform :ios, '7.0'
pod 'AFNetworking', '2.0.2'
pod 'TwilioSDK', '~>1.2.2'
pod 'SocketRocket', '0.3.1-beta2'
pod 'AppRTC'
end
When I run pod install. I get duplicates as shown below..
When I build my app I am getting error
ld: warning: directory not found for option '-L/Users/anand/Documents/
Project/myApp_Backups/myApp_June/myApp_WEBRTC/Pods/build/Debug-
iphoneos'
duplicate symbol _MD5_Update in:
/Users/anand/Documents/Project/myApp_Backups/myApp_June/
myApp_WEBRTC/Pods/AppRTC/Lib/libWebRTC.a(nss_static.md5.o)
/Users/anand/Documents/Project/myApp_Backups/myApp_June/
myApp_WEBRTC/Pods/TwilioSDK/Libraries/libcrypto.a(md5_dgst.o)
duplicate symbol _SHA1_Update in:
duplicate symbol _OBJC_IVAR_$_SRIOConsumer._readToCurrentFrame in:
/Users/anand/Library/Developer/Xcode/DerivedData/myApp-
gxdbyoohznnpigavdqmaeilzlavd/Build/Products/Debug-iphoneos/libPods-
myApp-SocketRocket.a(SRWebSocket.o)
/Users/anand/Documents/Project/myApp_Backups/myApp_June/
myApp_WEBRTC/Pods/AppRTC/Lib/libWebRTC.a(socketrocket.SRWebSocket.o)
ld: 71 duplicate symbols for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I thought to do below solutions:
1) Remove SRWebSocket.h file -- but it may get errors as it is in Pods.
2) Remove pod 'SocketRocket', '0.3.1-beta2' from pod file and run pod install -- but I used both SRWebSocket.h and SRWebSocket.m in my project before installing AppRTC into my project..!
Please suggest how can I solve this issue..
Thanks in Advance..!
I have fixed the above issue as below
At my Xcode project -- Build Settings -- Other linker Flags -- I removed -all_load then some of the duplicate errors are gone.
Still I get Socket Rocket duplicate warnings after the above solution.
I fixed this by going to Pods Project -- Selected Socket Rocket pods target -- Removed the SRWebSocket.m file from Compiling. It works fine and duplicates are removed.
Thanks for all answers..
You need to remove the socketrocket object code from libWebRTC.a
run lipo -info libWebRTC.a to see what architectures are in the library (current version is i386, armv7, and arm64)
Then run
lipo libWebRTC.a -thin i386 -output libWebRTC-i386.a
Do this for each architecture by replacing i386 with the relevant value. You then need to extract the object files from each archive.
mkdir libWebRTC-i386 && cd libWebRTC-i386 && ar -x ../libWebRTC-i386.a
Do this for each of the new single architecture libraries you've just created. In each of the new folders you will find .o files that contain "socketrocket" - delete these.
Then re-archive the object files for each architecture
libtool -static *.o -o ../libWebRTC-i386.a
Once you have done this re-combine them into a fat library
lipo -create libWebRTC-armv7.a libWebRTC-arm64.a libWebRTC-i386.a -output libWebRTC.a
And voila, it should now work. Really the libWebRTC.a binary needs re-building without the socket rocket object code, and socket rocket should be added as a dependency to the podspec.
Solution
Backup your project
Close the Xcode
- install this gem on terminal:
https://github.com/kylef/cocoapods-deintegrate
run the command line below :
pod deintegrate
remove the Podfile.lock file in your project directory
run install again :
pod install
Open Xcode and Clean your project and Derived Data directory then run again
Hope this solution will fix your problem.
Best
In your build phases, check to see that you aren't compiling the same file more than once.
In your case, maybe there're two same m files in Compile Sources, just remove one and try to rebuild.
Follow the below steps to resolve your duplication symbol error.
1) Select your Xcode Project > Navigate to "Build Phases".
2) From there, search the file name for which you are getting duplication.
3) If possible, then there might be more than one ".m files" for your search keyword.
4) Remove all the files except one which you need to actually compile.
5) Same way follow the process for all the duplicate error
6) That's it! Your problem will be solved for sure.
Create an issue for AppRTC repo to remove the header and set a dependency on SRWebSocket instead.
As a temporary solution - link AppRTC to a local path with :path directive and remove this file from the local directory. Or you may link to a local podspec file with ignorance on SRWebSocket header in exclude_files config.
Now it's very easy to remove duplicate pod files or any pod which is not in use for your project.
open your pod file.
comment all pod file which you want to remove.
use commend pod install
you will your all comment pod will remove in terminal
Enjoy your day with a cup of tea or coffee while doing code.

Resources