Problems adding Google Analytics to iOS App - ios

When I run through implementing Google Analytics in my app, using this walk through:
http://code.google.com/mobile/articles/analytics_end_to_end.html
After adding the libGoogleAnalytics.a CFNetwork and libsqlite3.0.dylib frameworks, and added the GANTracker.h into my AppDelegate.m
I get this error:
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_GANTracker", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
and the app won't even compile. My app is aimed at iOS 5.0
I'm pretty stuck. Any advice or work throughs would be very highly appreciated.

I actually figured out the answer after posting the comment.
Click on your project in the "Project Navigator", then click on your project under "Targets". You then need to click on "Build Phases". You need to make sure libsqlite3.0dylib and CFNetwork.framework are added to the "Link Binary WIth Libraries". I had this, but what I didnt have was you also need to add libGoogleAnalytics.a to that same area. That fixed the problem for me.

In my case, I add the AdSupport.framework for the missing "_OBJC_CLASS_$_ASIdentifierManager"

Just adding to the answer of #Etch.
Xcode 4.5 dropped armv6 and only supports armv7. Therefore, your lib might be an old version and you need to download version 1.5.1 onward. Download here
Issues: http://code.google.com/p/analytics-issues/issues/detail?id=232

I was working on a Cordova based XCode project. And got stuck with these stupid errors before figuring out what the linking errors meant. So here is what you do..
First, make sure you follow the steps mentioned https://github.com/phonegap/phonegap-plugins/tree/master/iOS/GoogleAnalytics. Next make sure you have the following files under the project linked via Build Phases (You get that when you click on the project name.. figure it out)
GANTracker.h
libsqlite3.0.dylib
libGoogleAnalytics.a
CFNetwork.framework
Also make sure your Plugins folder has 2 files, GoogleAnalyticsPlugin.h and GoogleAnalyticsPlugin.m.
If that doesn't help resolve your bugs. Then God help you. Start praying. Or alternatively try a bug spray. See if that works.

I had the same issue. The solution was move the library to same level of .h files.
But I don't know why this work.

In your Link Binary With Libraries under Build Phases under your target:
Make sure you remove libGoogleAnalytics_debug.a if you added it. And ensure you have AdSupport.framework and of course libGoogleAnalyticsServices.a.

Related

Undefined symbol: _OBJC_CLASS_$_WKInterfaceController error after updating Xcode to version 11.1

I updated Xcode to version 11.1 and got this expected error:
WatchKit is not available when building for iOS Simulator.
Then I deleted WatchKit from iOS app target as suggested. Since then I am having this error:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_WKInterfaceController", referenced from:
objc-class-ref in INFOnlineLibrary(IOLWatchKitHelper.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker
command failed with exit code 1 (use -v to see invocation)
Undefined symbol: _OBJC_CLASS_$_WKInterfaceController
PS: The x86_64 part is dependent on the device/simulator choice. If I choose a real device it gives the same error for arm64. So I don't think it is a architecture issue also because of the fact that the framework that includes WKInterfaceController is just a standart watchOS framework which is Watchkit.
PS_2: There is no use of WKInterfaceController or even WatchKit in the iOS app. It is only used in WatchAppExtension part
What I have tried so far:
First thing was to add WatchKit framework to WatchApp and
WatchAppExtension targets.
When I searched for Undefined symbols for architecture x86_64 type of errors in general there were many different suggestions. Even though I think it is not architecture dependent thing, I tried setting building active architecture only no in all targets. The most suggested putting $(inherited) to the search paths was already done before.
Checked the target of .m files. They are all fine.
I even went far and commented all the code that is using WKInterfaceController. Nothing has changed after. I also deleted watch app, it still looked for _OBJC_CLASS_$_WKInterfaceController but I am not sure did it properly.
I checked the WatchKit.framework Device Supporting Files with file WatchKit.framework command and saw that it supports arm64. Then added that library manually to libraries, ran on device but still didn't work.
When I saw this error, it turned out to be because one of my .mm implementation files was not checked in the "Target Membership" section of the options pane, and so was not being built.
Please check "Link Binary With Libraries" in "Build Phases". Is there any library that used still WKInterfaceController or is dependent on the WatchKit?
I was getting the same error though with another framework. You just have to make sure that error files have the required framework is in your Link Binary with Libraries.
In my case I had the error Undefined symbol: OBJC_CLASS$_SKStoreProductViewController which is related to StoreKit.
All I had to do was add the StoreKit.framework into Link Binary with Libraries
I faced a similar error, but in my case it was probably some unclean library lying around after adding / removing dependencies. So I did Xcode -> Product -> Clean Build Folder , and rebuilt the project. It succeeded.
I had to drag & drop the framework into Xcode, under the Frameworks group. It was already added under Target > Build Phases > Embedded Frameworks, but apparently that wasn't enough.
If you are sure that implementation files are checked in the "Target Membership" section of your app for the build, make sure that there is an implementation of the header file somewhere. I ran across this issue when I had a class that I had defined within the same file as another class and forgot to put its implementation in the related .m file for both classes.

Undefined symbols for architecture x86_64 on Xcode 6.1

All of a sudden Xcode threw me this error at compilation time:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_Format", referenced from:
objc-class-ref in WOExerciseListViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
After doing some research, I may understand that a library I'm using is not compatible with 64 bit version. But this is very strange since I've been working with the same libraries for at least a week without having a single compilation problem during that time. The two libraries are just composed of a bunch of classes, and when I removed them from my project I got the same issue. Since I have never created libraries myself, I have no idea how I can find wether the ones I'm using are compatible with 64 bit (?)
I also tried the following changes for architectures under the target panel :
added $(ARCHS_STANDARD_INCLUDING_64_BIT) to the Architectures
build active architecture only -> set to 'NO'
for 'valid architectures' -> set to arm64, armv7 and armv7s
deleted the DerivedData folder and its contents, cleaned and built again
But none of these changes work. Please, does someone have a clue on this?
Thanks
Apparently, your class "Format" is involved in the problem. Check your declaration of this class, especially if you did it inside another class you probably forgot the #implementation or something similar.
Check if that file is included in Build Phases -> Compiled Sources
Make sure the WOExerciseListViewController is a Target Member; that worked for me!
Yes, I think the library you are using is not compatible with 64 bit version but you can solve the problem -
Just navigate to Build Settings>Architectures & replace $(ARCHS_STANDARD) to $(ARCHS_STANDARD_32_BIT)
So that your xcode build your project with 32 bit supported version.
I just had this error when I opened a (quite) old project, created in Xcode 4~ish, in Xcode 6.4. While the linked Frameworks were visible in the Project sidebar, I overlooked that there were no linked libraries in the Target Build Phases tab. Once I fixed that, it compiled fine.
It turned out I forgot to write my #implementation part.
I simply wasn't linking the libraries in the "Link Binary with Libraries" section.
I solved the same issue by going to Xcode Build Settings and in Architectures, I changed
the Xcode 6.1.1 standard architecture to:-
$(ARCHS_STANDARD_32_BIT)
I just had the exact same error, and solved it by restarting xcode.
For me the issue occurred after an svn update, the file in question was added to the projects folder, but it never appeared in xcode(9.3.1) – until I restarted it.
Same error when I copied/pasted a class and forgot to rename it in .m file.
I solved the problem by deleting reference to the file and adding it again in project. In my case it works.
this setting worked for me:
Architectures=$(ARCHS_STANDARD_32_BIT)
Build Active Architecture Only:YES
Valid Architectures armv6 armv7 armv7s arm64
Delete the $(ARCHS_STANDARD) and add the $(ARCHS_STANDARD_32_BIT).

Xcode 6 linker error - Undefined symbols for architecture armv7

After upgrading to Xcode 6 beta 7 (and now still with Xcode 6 GM) I am unable to link my Swift app. I receive errors such as:
Undefined symbols for architecture armv7:
"_swift_stdlib_compareNSStringDeterministicUnicodeCollation", referenced from:
...
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have seen the other SO posts that recommend deleting the Derived Data folder and/or using the Clean Build Folder option to get past this error, but that solution didn't help at all in my case. Nothing has changed about my code or the CocoaPods I'm using since Xcode 6 beta 5 which is the last time it worked.
Any ideas?
EDIT:
A full posting of the error log:
Undefined symbols for architecture arm64:
"_swift_stdlib_compareNSStringDeterministicUnicodeCollation", referenced from:
TFC12MyProject21BarcodeViewController13captureOutputfS0_FTGSQCSo15AVCaptureOutput_24didOutputMetadataObjectsGSQGSaPSs9AnyObject___14fromConnectionGSQCSo19AVCaptureConnection__T_ in BarcodeViewController.o
"__TFSs21_arrayConditionalCastU___FGSaQ__GSqGSaQ0_", referenced from:
TFC12MyProject27SessionsTableViewController17viewWillDisappearfS0_FSbT_ in SessionsTableViewController.o
"__TFSs15_arrayForceCastU___FGSaQ__GSaQ0", referenced from:
__TFC12MyProject7RestApi12tokenMappingfS0_FT_CSo15RKEntityMapping in RestApi.o
__TFC12MyProject28AttendeesTableViewControllerg24fetchedResultsControllerCSo26NSFetchedResultsController in AttendeesTableViewController.o
__TFC12MyProject27SessionsTableViewControllerg24fetchedResultsControllerCSo26NSFetchedResultsController in SessionsTableViewController.o
__TFC12MyProject21BarcodeViewController13startScanningfS0_FT_Sb in BarcodeViewController.o
"__TFSs26_forceBridgeFromObjectiveCU__FTPSs9AnyObject_MQ__Q_", referenced from:
__TFC12MyProject7RestApi12resetRestKitfS0_FT_T_ in RestApi.o
__TFC12MyProject16BluetoothManager17_startAdvertisingfS0_FT_T_ in BluetoothManager.o
__TFC12MyProject19LoginViewController32registerForKeyboardNotificationsfS0_FT_T_ in LoginViewController.o
__TFC12MyProject19LoginViewController35deregisterFromKeyboardNotificationsfS0_FT_T_ in LoginViewController.o
__TFC12MyProject19LoginViewController16callProcessLoginfS0_FT_T_ in LoginViewController.o
__TFC12MyProject21CheckinViewController16enableBeaconModefS0_FT_T_ in CheckinViewController.o
__TFC12MyProject21BarcodeViewController13startScanningfS0_FT_Sb in BarcodeViewController.o
...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What's happening here has nothing to do with your Derived Data location.
When a swift application is built, it goes through several steps:
Write auxiliary files
Create product structure
Compile swift source for each architecture
Copy resource rules plist
Copy application bridging header
Link against swift runtime libraries for each architecture
Copy application swift module for each architecture
Create the application binary
Copy resources build phase
Copy the swift standard libraries into the application
Package it up
Sign it
Whew! That's a lot. Your build is failing when linking against the swift runtime libraries. They live in Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos inside the Xcode developer directory. Specifically, the library that is not being correctly linked is libswiftCore.dylib. If you use nm on that library, you can see it defines your first missing symbol:
quellish% nm /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftCore.dylib | grep compareNSStringDeterministicUnicodeCollation
00197c8c T _swift_stdlib_compareNSStringDeterministicUnicodeCollation
000000000018352c T _swift_stdlib_compareNSStringDeterministicUnicodeCollation
You can also use lipo to see what architectures are in the file:
quellish% xcrun lipo -info /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftCore.dylib
Architectures in the fat file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftCore.dylib are: armv7 arm64
It contains armv7 and arm64. It's not the library architecture that's the problem.
Linking against the swift standard library is not working. It's possible that source control or migrating Xcode versions has caused your project file to drop part of the linking step, or it's simply not able to find the libraries it needs to link against. Xcode project files are complex and use a lot of references - it's possible that a merge, etc. caused a critical reference to be come dissociated from the linking step. Without a full build log and a look at your machine it may not be possible to tell.
This library, as you might guess, has nothing to do with the project's derived data location.
The best way to move forward would unfortunately be to recreate the project file. Comparing the build log of the broken project to a swift project that does build correctly may provide some insights, but it may also be a waste of time - something fixable may be the problem, but more likely not.
I would encourage you to file a bug and include the troublesome project file with it.
I have solved my issue by deleting all the data in the ~/Library/Developer/Xcode/DerivedData folder. I read about that in another thread, but ignored it thinking a clean included that process!
I have Updated on Yosemite, Xcode 6.1.
I have updated gem xcodeproj (0.19.4) and cocoapods (0.34.4).
I have resolve my conflict by :
Clearing the Library/Developer/Xcode/DerivedData folder
replace in Target -> Build Settings -> Linking -> Other Linker Flags : $(OTHER_LDFLAGS)
Check in Target -> Build Phases -> Copy Pods Resources : "${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh"
1) I face the same problem but just clear the applications from derived data from User/Library/Developer/Xcode/DerivedData and I am able to run the code.
2) In your case may be, it will run by removing armv7 architecture from build settings. And make sure your compiler is Default Compiler in Build Settings.
Thanks I hope this helpful to you and everyone.
This seems to be caused (for most) by linking a third-party library that does not support the requested architecture.
I had somewhat similar problem (a linker error from Apple's framework). As it turned out, the problem was that I was missing the library LocalAuthentication.framework. I am wondering if maybe you need to delete the Foundation.framework from the Build Phase tab (in the Link Libraries section), and then re-add it? Maybe that will solve the problem?
'Upgraded' to xcode 6 and swift app wouldn't build for simulator yet would build fine on an iPad - Linker error, undefined symbols for i386 for the simulator.
Clearing the Library/Developer/Xcode/DerivedData folder worked for me.
There appears to be a bug in Xcode 6.0.1 that is causing the linker to drop dependencies in existing project files. I have had this same problem across several different projects, new and old, since the 6.0.1 update.
The easy 'fix' is to just trash your entire 'Derrived Data' and all build files (i.e. manually clean the project) and then rebuild after a fresh Xcode restart. Magically, the linker now finds all the missing architectures/symbols.
NOTE: I have had several incompatible v-table crashes caused by this same bug. The C++ linker appears to be generating incomplete linkages, causing absurd errors where there are no real errors to be found. Again, just rebuild from a clean state and .. ta da.. save yourself a LOT of headache and wasted time tracking down a non-issue.
I solved this issue after trying all that was suggested here with no luck.
Like someone said earlier, it's a SourceControl issue.
One of my project files (the one referenced in the error message) was missing from the project browser. However, XCode still had a reference to it (I was going to the class definition when I was selecting "jump to definition" from Xcode GUI).
As a matter of fact, the project.pbxproj was not listing it. This was probably a Git Issue. In any event, I just recreated the file in the same directory it has been recreated and voila.
I am a filly when it comes to iOS Objective C, though I have been coding in several other languages for many years. So I am stabbing around in the dark most of the time with Objective C.
I started having this error, "Undefined symbols for architecture armv7", directly after declaring some "global" variables in my .h file like so:
extern NSString *globalNotes;
extern NSString *globalUserCountry;
I was then referring to these variables from the .m file like so:
globalNotes= #"Error (Marker 1010)";
globalUserCountry= #"No result";
THE FIX - To correct this, I changed them to object properties like so:
#property(nonatomic, strong, readwrite) NSString *globalNotes;
#property(nonatomic, strong, readwrite) NSString *globalUserCountry;
And referred to them like so:
self.globalNotes= #"Error (Marker 1010)";
self.globalUserCountry= #"No result";
That seemed to fix my problem.

iOS - GA - library not found

I am trying to add Google Analytics to my iOS app. I followed the step of Google's tutorial but now my projet doesnt compile and I have the following error message.
ld: library not found for -lGoogleAnalyticsServices
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I checked and the the library libGoogleAnalytics_debug.a is in my project folder so I dont understand where the problem comes from.
Does anyone have an idea how to fix this?
Many thanks
Go to your project > Build settings > search for the LIBRARY_SEARCH_PATHS and check their paths.
just put lGoogleAnalyticsServices.a near with myapp.xcodeproj, and drag library in your frameworks block in xcode
I also had this error and was able to fix it like this:
Go to the app project settings
Go to the General tab
Under Linked Frameworks and Libraries, drag libGoogleAnalyticsServices.a to be at the end of the list.
Order matters because if a dependency of said library isn't built first, Xcode won't be able to link it.

Google Analytics Library IOS

When i add google analytics library, i have this warning
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_NSAttributeDescription", referenced from:
objc-class-ref in libGoogleAnalytics.a(GAICoreDataUtil.o)
objc-class-ref in libGoogleAnalytics_debug.a(GAICoreDataUtil.o)
"_OBJC_CLASS_$_NSFetchRequest", referenced from:
objc-class-ref in libGoogleAnalytics.a(GAIDataStore.o)
objc-class-ref in libGoogleAnalytics_debug.a(GAIDataStore.o)
"_NSSQLiteErrorDomain", referenced from:
l003 in libGoogleAnalytics.a(GAIDataStore.o)
Please help me
Add libGoogleAnalytics.a to your target setting [Build phases]-[Link Binary with Libraries]. Also check if libsqlite3.0dylib (where GA stores tracking data) and CFNetwork.framework are added there as they are required for Google Analytics/iOS (version 2.0 beta 3).
P.S. For Google Analytics/iOS version 3.0 CoreData framework is required instead.
I had have the same issue on NSAttributeDescription. In documentation this function is from CoreData.framework, so I have added this framework and no more errors on that issue.
Problem related to Google Analytics SDK for iOS v2 migration.
I am not sure which topic to write it to as there is no exact problem--I've bumped into and solved by my own--found (this one seems to be the closest (not sure if I should open a new one)), but might be helpfull for someone.
Problem:
I have my previous (1.5.1) SDK installed in "SDKs/GoogleAnalytics SDK" separate folder. On v2 migration I've placed the new files into "SDKs/GoogleAnalytics SDK v2". After following all the instructions about migration (from Google site) (and, in details, that was just removing the previous references to the files from the first folder and adding the new ones from the new one), I started to get the following error message on compilation:
Undefined symbols for architecture armv7: "_OBJC_CLASS_$_GAI",
referenced from:
objc-class-ref in AppDelegate.o ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code
1 (use -v to see invocation)
I went trough first pages of googling (and stackoverflowing) and the most popular solution suggested was "to set 'Build active architecture only' property to 'YES'" (my active architectures are "armv7 armv7s"). But that DID NOT HELP at all.
Solution:
However, a miracle happened. I've noticed that there is an old directory "SDKs/GoogleAnalytics SDK" was listed in linker pathes. So, after that directory removing (as I don't know where the list of the directories exists in settings) everything started to compile and work like a charm (also setting 'Build active architecture only' to 'YES' was not necessary for me).
Add -lGoogleAnalyticsServices in Build settings -> Other Linker Flags
I had similar errors as above, actually more (SDK 2.0 beta 4). After adding the Analytics library/headers, linking with these two frameworks solved the issues:
CoreData.framework and SystemConfiguration.framework
I followed this tutorial. It says to add
#import "GAI.h"
#import "GAIFields.h"
into the NameofTheProject-Prefix.pch file.
And additionally to CoreData.framework and SystemConfiguration.framework add libz.dylib
It solved all issues.
I was having this issue because i didn't add the libGoogleAnalytics_debug.a file. The problem just got resolved as i added this file and built the project again.
I had an ODD odd issue. For some reason libGoogleAnalytics.a was in Copy Bundle Resources when it was supposed to be in Link Binary With Libraries
Hopefully that helps someone.
Had similar issue after migrating to SDK 2.0 beta 4. Resolved by removing old GA library path from My Build Settings > Library Search Paths as pointed by Adri.
If using Cocoapods make sure Other linker flags has only $(inherited) flag and remove any child architecture flags.
For framework search paths and Library search paths also set only $(inherited) flag.
Inside the header bridging file put the #import <Google/Analytics.h>
I followed all suggestions and I was still getting an error on XCODE 5.1.1.
For me the error was in target > Build Setting > Architecture > Architectures.
I replaced the value with ARCHS_STANDARD_32_BIT and the error was gone.
Maybe the libGoogleAnalytics lib was not compiled for 64 BIT architecture.
Hope this will help someone. Or get latest lib which is compiled for 64 Bit.

Resources