GCM Library errors: Integration GCM in iOS Swift - ios

What I have done after 2 days of reading stack overflow:
Keywords to problem: "Apple-Mach-O Linker Error", "libGcmLib.a(GCMRmqManager.o)", sqlite3", "GCMRmq2PersistentStore"
Installed latest pod.
Tested 'Other Linker Flags' -ObJC and empty as well.
Cleaned the project and rebuilt. Deleted project and recreated, no help. Header is in the right path and properly configured.
Manually copied dependencies but it didn't help.
Manually copied new source code from Google's Github as well as their recently updated 'GCM Playground', nothing worked.
Integrated CoreData.framework to no avail.
Tried these solutions:
Apple Mach-O Linker Error when compiling for device,
CocoaPods adds incorrect Other Linker Flags, Google Cloud Messaging Bridging Header import fails, Xcode - symbol(s) not found for architecture x86_64 (iOS Lib), Undefined symbols for architecture arm64, Apple Mach-O-Linker Error CocoaPods, Swift iOS don't recognize GCM library imports?
So I am stuck. How do I solve the problem(s) displayed in the image below: "sqlite3.... ", referenced from: "GCMRmq2PersistentStore in libGcmLib.a(GCMRmqManager.o)?
IMAGE

GCM seems to be using sqlite3 in the library. You should link your app against it to build it. You tried integrating CoreData but it should rather have been sqlite3.
You should also check CocoaPod's generated xcconfig file i.e. Pods/Target Support Files/Pods/Pods.debug.xcconfig file and the OTHER_LDFLAGS option should have -l"sqlite3" in it. That should have linked it for you.

Related

iOS firebase Mach-O Linker Error without cocapods

I'm trying to import Firebase into my iOS app. I followed this tutorial for doing this manually with Objective-C (as opposed to using CocoaPods).
http://www.mokacoding.com/blog/setting-up-firebase-without-cocoapods/
When I try to build my project, I get the following errors:
"Apple Mach-O Linker Error"
"Linker command failed with exit code 1 (use -v to see invocation)"
I'm familiar with the Linux CLI (less so with Macs), but I don't understand how to apply the -v flag to XCode's build process to get more info.
I've been Googling this for the last 3 hours, but every answer I find seems to be directed at users who weren't using an XCode workspace with CocoaPods.
I don't have CocoaPods installed, so I don't think this is my issue. Despite that I have converted my project and properly imported it into an XCode workspace, this still didn't solve my problem.
My app is a Swift project, and I have imported the modulemap, firebase.h, and googleServices.plist files.
I've also made my Header and Library search paths recursive for the entire project folder in an attempt to fix this.
Here's my project navigation. Although at this point I suspect it's some kind of build setting that isn't correct.
Some selected answers I've tried to apply without success:
Apple Mach -O Linker command failed
In Xcode how do I create a new workspace and add 1 project to it so that I can see the project and its files?
Framework not found GoogleToolboxForMac
Adding system header search path to Xcode
https://github.com/firebase/firebase-ios-sdk/issues/258
Apple Mach-O Linker & Ditto Error - Xcode 8
https://github.com/invertase/react-native-firebase/issues/198
https://forum.ionicframework.com/t/ios-xcode-8-apple-mach-o-linker-ld-error-group-in-xcode/89903
Upgrading to xcode 9.2 fixes this. It appears to be an issue with earlier versions not properly handling linking.
Which is misleading b/c the firebase documentation indicates it's compatible with xcode 8. But I think that's assuming you use cocoapods. If you don't, and instead try to link the obj-c frameworks you need xcode 9+
Once I knew how to examine the more verbose linking error, googling for x86_64 led me to some helpful answers.
This and other answers helped me investigate upgrading.
ld: framework not found Stripe for architecture x86_64

How to solve liker error:can't link directly with lib system_configuration.dylib

I am adding Google Analytics a bit older version by directly downloading the libraries for a reason.
Followed this tutorial https://www.raywenderlich.com/53459/google-analytics-ios
but after adding all the files and trying to build basic analytics code I am stuck at a linker error
ld: cannot link directly with /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/lib/system/libsystem_configuration.dylib. Link against the umbrella framework 'System.framework' instead. for architecture x86_64
I am not sure what exactly is happening , my Xcode is at 7.2 and trying to run this code on iPhone 6 simulator.
**** EDIT ***
Also above error has occurred after adding Google Analytics specific libs and headers

Linking Errors while integrating SKMaps.Framework

Getting these error while trying to integrate SKMaps framework
Undefined symbols for architecture x86_64:
"CRouteTestManager::calculateRoute(NGRouteInput const&, std::__1::shared_ptr<CRoute>&)", referenced from:
PoiTrackerTest::createRoute() in SKMaps(PoiTrackerTest.o)
"_gpTestRoutesManager", referenced from:
PoiTrackerTest::createRoute() in SKMaps(PoiTrackerTest.o)
createNavigationObject(int) in SKMaps(NavigationTest.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Please help me resolve this error.
Environment :
Xcode 6.3.1, Mac OSX 10.10.3
Deployment Target iOS7.0
Supports Swift.
i was following this guide : http://developer.skobbler.com/getting-started/ios
and also added CoreMotion.framework as there were also linking errors related to that framework.
Cause of Linker Error
This appears to be the result of the linker flag -all_load, which may have been added to your project through a CocoaPod. In the rare case that you have a static library with nothing but categories defined then you need this flag. Otherwise, it can be safely removed from your build. See discussion here:
What does the -all_load linker flag do?
From a link in the comments section on that discussion you can see that this bug that previously required -all_load has been fixed since XCode 4.
Objective-C categories in static library
Probable Explanation
This framework has a bunch of tests defined inside, but their dependencies are not included in the framework. When the linker is forced to resolve and link all dependencies, it errors out because it cannot find them. Basically, the library should be cleaned up so that it doesn't contain these unnecessary symbols. The work around is to remove -all_load for the time being.
Faced with the same problem. Deleting -all_load flag did not help, so I continued to research and found a solution:
Despite the fact that Skobbler declares the need for linking the libc++ library, in reality you need to link libstdc++.6 library. Note that linking libstdc++ will not help.
P.S. Xcode 6.4, iOS SDK 8.4

Xcode - Missing Architecture (library linking)

For the recent couple of days I have had this compiler error in Xcode every time I've built my project:
ld: warning: ignoring file /.../(Framework Name).framework/(Framework), missing required architecture x86_64 in file /.../(Framework Name).framework/(Framework) (2 slices)
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_CLSNAME", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I also can't run this code on the iPhone 5 simulator (i386).
The iPhone device I have is outdated and can't run iOS 8. I tried setting the build settings to iOS 7 but I get an error regarding the lack of support for dynamic libraries before iOS 8.
Things to note:
I am using 2 projects, in 2 different workspaces. (one for the library and one for the demo app. Tests of the same code with the unit tests in the library project are successful.)
I used to be able to link the demo project with the library project until I had to do some changes in the library code. After I exported the newer version this error started occurring.
In order to get the library file/folder (.framework) I used the Archive option.
Running lipo -info outputs Architectures in the fat file: lib.a armv7 arm64
I have C++ code in the library project (unlikely to be the issue)
In the library project, I am using another external library I installed with Cocoa Pods (also used to work before changes in the library code)
Solutions I tried:
Changing the Architectures and the Valid Architectures list in Build Settings.
Setting "Build Active Architecture Only" to "No" in Build Settings.
Creating a new project (both for the demo and the library)
Making the library a static library (new project, got the same warning, no error, couldn't #import the files I needed)
I only started working with iOS and Xcode a couple of months ago and I am not super-experienced with everything there yet, so please try to explain everything with as much detail as you can.
Thanks in advance to anyone trying to help :)
Did you add the framework it says is missing? Also, try to delete the Derived Data folder and then clean the project. If that does not work, then turn off Modules in build settings.

Static library and cocoapods with Xcode 6.1.1 - ld: library not found Error

Not sure it is related to Xcode 6.1.1 or Cocoapods 0.35.0.
I have generated new static iOS library with Xcode 6.1.1.
SUCCESS (without cocoapods)
Generate simulator and Device library
Lipo to both and generate FAT MyLib.a static final lib
Create new View Application project. (I haven't changed any default setting. e.g. Base SDK, Valid Architecture.)
Add MyLib.a and necessary header files to application project manually.
Build the app project and IT WORKS FINE !! NO ERROR NO WARNING.
ERROR
Upload same MyLib.a & headers (generated above) to HTTP direct download server(kind of artifact server).
Generate specs & podfile.
Remove all dependency (lib and header) from app project which i have done manually earlier.
Add pod file and local specs
"Pod install" command pull out MyLib.a and header properly in /Pods folder.
But while building the app project gives me
Ld Build/Products/Debug-iphonesimulator/LibTest.app/LibTest normal x86_64
cd /Users/admin/Cocoapods/Project/Library/TestProject/LibTest
export IPHONEOS_DEPLOYMENT_TARGET=8.1
ld: library not found for -lMyLib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
When i fire "lipo" command on MyLib.a
Architectures in the fat file: /Users/admin/Cocoapods/Project/Library/Libs/Final/MyLib.a are: armv7 armv7s i386 x86_64 arm64
Its not really architecture issue otherwise it should get failed in my first attempt which doesn't have cocoapods. Cocoapods does some build configuration changes and that creates this issue.
Help me to resolve this issue.
After spending 2 days to figure out the exact issue, i found very silly fix. Its basically issue with static library naming convention issue.
If you have static library in artifact/media http server and wanted to integrate with Cococapods, make sure library name should be lib(your name).a along with headers.
In my case i have kept MyLib and it got dowloaded currently while "pod install" but during app building it was failing.
After renaming to libMyLib.a, every thing works for me. :)
Very easy to apply yet difficult to find such solution]
Not sure whether cocoapods has documented this in there any guide or not.

Resources