I'm totally stuck trying to run a project on the simulator using AFNetworking. I've used this dependency before on other projects, so I don't understand what is going wrong here. First, the error when I try to run the project:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_AFHTTPSessionManager", referenced from:
_OBJC_CLASS_$_SharedNetworkObject in SharedNetworkObject.o
"_OBJC_CLASS_$_AFJSONResponseSerializer", referenced from:
objc-class-ref in SharedNetworkObject.o
"_OBJC_METACLASS_$_AFHTTPSessionManager", referenced from:
_OBJC_METACLASS_$_SharedNetworkObject in SharedNetworkObject.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'm sure that this is part of the problem, but I don't know how to resolve it:
This is the offending .h file:
#import <Foundation/Foundation.h>
#import <AFNetworking/AFNetworking.h>
#import "SharedSessionKey.h"
#interface SharedNetworkObject : AFHTTPSessionManager
+ (SharedNetworkObject *) sharedNetworkObject; // class method to return the singleton object
#end
It may be of interest to note that when I start typing the import line for AFNetworking, the line fills in after a few characters, so I know that there is some awareness of the presence of the AFNetworking dependency.
I installed the dependency using CocoaPods. Here is my Podfile:
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
source 'https://github.com/CocoaPods/Specs.git'
target 'WeRun' do
pod "AFNetworking", "2.5.2"
end
target 'WeRunTests' do
end
And, of course I am working in .xcworkspace (not .xcodeproj).
One more thing, my xcconfig file looks like this, which matches with other successful AFNetworking builds:
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking"
OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/AFNetworking"
OTHER_LDFLAGS = -ObjC -l"Pods-MyApp-AFNetworking" -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration"
OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS)
PODS_ROOT = ${SRCROOT}/Pods
I don't know what else to look for. I've completely removed the pod and reinstalled, only to find the exact same error. Can anyone help me figure this out? Thanks!
I spent a couple of hours fighting with this exact same issue, going through all the Google hits I could find. Building for the device was working, but building for the simulator was not.
Here are the steps that finally solved the issue for me:
Clear the XCode caches:
rm -rf ~/Library/Developer/Xcode/DerivedData/
Clear the CocoaPods caches and reinstall the dependencies:
rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod update
Finally go to the "Pods" project and set the Build Active Architectures Only to No also for the "Debug" configuration.
I would suggest you to add the $(inherited) flag into the "Build settings".
Tap on the blue project icon
Select "Build settings" tab
Under "Linking" you'll find a setting called "Other Linker Flags"
add $(inherited) into the textfield
I had the same issue, when I had -lc++ already set on Other linker flags for cpp library usage purpose.
I added these two flags -ObjC -l"AFNetworking" on Other linker flags, which worked and compiled successfully. These are the two flags -ObjC and -l"AFNetworking". You scan add simultaneously -ObjC -l"AFNetworking".
Do not give version after AFNetworking in pod file. And try again. Make sure you remove the comma also.
Well, I resolved this, but I'm not sure why it worked. I was experimenting with the Other Linker Flags in the Build Settings. I deleted the flag that was put there by the CocoaPods installation (presumably) and replaced it by copying the flag from the .xcconfig file. Specifically, I added this text: -l"Pods-WeRun-AFNetworking" as the second flag right after -ObjC. It looks to me to be exactly what I had just deleted, so I really hesitate to suggest this as an 'answer', but it works now, so something must have changed.
If anyone can shed any light on this or tell me that I am fooling myself, please let me know. Thanks for the suggestions.
this happened to me too. and what I fixed it just one step:
Kill the Xcode, and right click the Xcode to show info, open it using Rosetta, then open the project to build. It works!!!
By the way, I am using M1-chip Mac Mini.
Before that, I tried everything I got from google, like: clean the cache, check the other linked flag, etc. they won't work for me.
I hope this can help you guys!
A simple method. Download the repository file. Drag and drop the contents of the AFnetworking folder (You can create groups if necessary) then use the library. (Use #import "AFnetworking.h" )
Related
I am trying to add Firebase analytic support to an existing iOS app.
The app was already using CocoaPods to import FMDB, and also has a manual build dependency on TensorFlow C library.
After adding Firebase to my podfile file my build failed with,
"Module 'Firebase' not found"
Podfile
target 'myapp' do
pod 'FMDB'
pod 'Firebase/Analytics'
end
Header Search Paths
$(TENSORFLOW_ROOT) $(TENSORFLOW_ROOT)/tensorflow/contrib/makefile/downloads $(TENSORFLOW_ROOT)/tensorflow/contrib/makefile/downloads/eigen $(TENSORFLOW_ROOT)/tensorflow/contrib/makefile/downloads/protobuf/src $(TENSORFLOW_ROOT)/tensorflow/contrib/makefile/gen/proto $(TENSORFLOW_ROOT)/tensorflow/contrib/makefile/downloads/nsync/public/ $(TENSORFLOW_ROOT)/tensorflow/contrib/makefile/downloads/absl ${PODS_ROOT}/Headers/Public/**
Framework Search Paths
"${PODS_ROOT}/FirebaseAnalytics/Frameworks" "${PODS_ROOT}/GoogleAppMeasurement/Frameworks" "${PODS_XCFRAMEWORKS_BUILD_DIR}/FirebaseAnalytics" "${PODS_XCFRAMEWORKS_BUILD_DIR}/GoogleAppMeasurement"
Library Search Paths
"${PODS_ROOT}/FirebaseAnalytics/Frameworks" "${PODS_ROOT}/GoogleAppMeasurement/Frameworks" "${PODS_XCFRAMEWORKS_BUILD_DIR}/FirebaseAnalytics" "${PODS_XCFRAMEWORKS_BUILD_DIR}/GoogleAppMeasurement"
Other Linker Paths
"${PODS_ROOT}/FirebaseAnalytics/Frameworks" "${PODS_ROOT}/GoogleAppMeasurement/Frameworks" "${PODS_XCFRAMEWORKS_BUILD_DIR}/FirebaseAnalytics" "${PODS_XCFRAMEWORKS_BUILD_DIR}/GoogleAppMeasurement"
Attempt 2
This seems to be fixed by adding $(inherited) to the "Header Search Paths" and "Framework Search Paths", as if these paths are customized they don't seem to pick up the pods without this. Although FMDB was working fine without this.
But this still failed with a later build error,
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_FIRApp", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1
If I remove the reference to FIRApp in my code, it builds fine.
Attempt 3
Build settings
Add $(inherited) to "Other Linker Flags"
This gives a build error on FMDB now,
ld: library not found for -lFMDB
Attempt 4
Build settings
Add $(inherited) to "Library Search Paths"
This gives a different build error in FMDB
duplicate symbol '_OBJC_IVAR_$_FMResultSet._parentDB' in:
/Users/paphus/Library/Developer/Xcode/DerivedData/Miami-btsjnxdkshhzzmcximegwcbjweif/Build/Intermediates.noindex/Miami.build/Debug-iphonesimulator/Miami.build/Objects-normal/x86_64/FMResultSet-8b2ff65f24dc1207099e1a3d8676b2cd074aac777d9679e86442f90b5f7cd476.o
/Users/paphus/Library/Developer/Xcode/DerivedData/Miami-btsjnxdkshhzzmcximegwcbjweif/Build/Products/Debug-iphonesimulator/FMDB/libFMDB.a(FMResultSet.o)
ld: 49 duplicate symbols for architecture x86_64
Attempt 5
Build Phase
Link Binary with Library,
Seems to be missing FirebaseCore now?
ld: library not found for -lFirebaseCore
I also tried "pod deintegrate" and pod cache clean" and a few other things, no luck.
Did you try setting OTHER_LDFLAGS build settings to $(inherited) flag?
So I gave up on getting the pod to work and instead followed,
https://firebase.google.com/docs/ios/setup#frameworks
downloaded SDK from,
https://firebase.google.com/download/ios
This was way way easier and simple to setup and worked the first time.
Just added the FirebaseAnalytics directory to the project as a group and added the Firebase.h file to the project, that's it. Works.
I'm trying to import Appodeal to my React Native iOS app, I followed this Appodeal XCode Tutorial
So I met an error in linking, and found some existing ways to solve it, but none of which did help me.
ERROR:
So here is my "Link Binary With Libraries" list:
And here is my Compile Sources & Target Membership:
Bitcode disabled:
Other Linker Flags:
Architectures:
Appodeal dependencies in the root of my project:
And that's all I've changed, so any ideas on where did I go wrong?
I should've added CoreBluetooth.Framework (they missed it probably in the tutorial or whatever), now it's nice.
Found my answer here: groups.google.com/forum/#!category-topic/google-admob-ads-sdk/… ( Thanks Jaap ! )
And also I added libs with this instructions by SleepyViking from (https://forums.developer.apple.com/thread/4572):
Go to Build Phases >Link Binary with Librairies > + > Add other
Once in the file selection window do "CMD"+Shift+G (Go to folder) and type /usr/lib/
From /user/lib you can add : libz.dylib and more...
Compile and have fun
The pod was installed properly. I also tried a clean/build multiple times. My header files are included in the bridging header.
My architectures include arm64 but I'm still receiving this error.
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_Stripe", referenced from:
__TMaCSo6Stripe in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Actually when I ran pod install, it didn't inherit my path in
OTHER LINKER FLAGS
so it was a manual fix by adding
$(inherited)
Hope this helps someone if they encounter the same problem.
I just integrated the Stripe cocoapod yesterday and had quite a few issues myself. I'm guessing in your Stripe/Support Files in your Pods directory, you have a file called Stripe-umbrella.h.
The only luck I had integrating Stripe was importing the umbrella file in my bridging header like below (make sure to remove quotes):
#import <Stripe/Stripe-umbrella.h>
Add this, clean, build and you should have better luck.
For the record, I'm using XCode7.
After I updated Fabric Crashlytics in my app I cant anymore run it on my iOS device. On simulator it works fine. Error is:
Undefined symbols for architecture arm64:
"_gzopen", referenced from:
-[CLSPackageReportOperation compressFile:] in Crashlytics(CLSPackageReportOperation.o)
"_gzwrite", referenced from:
___42-[CLSPackageReportOperation compressFile:]_block_invoke in Crashlytics(CLSPackageReportOperation.o)
"_gzclose", referenced from:
-[CLSPackageReportOperation compressFile:] in Crashlytics(CLSPackageReportOperation.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Crashlytics and Fabric require you to link your target against the following:
Security.framework
SystemConfiguration.framework
libc++
libz
Just select your target -> Build Phases -> Link Binary with Libraries -> add the ones missing.
I hope it helped.
I solved this issue by just adding $(inherited) to other linker flags in Build Settings.
I run into a similar issue, when I was updating an app that was created before Xcode 5.
Since Xcode 5 new projects build with modules enabled by default. In my old app "Enable Modules" was set to "No". So this was the solution.
Solved. I removed Crashlytics.framework and reinstall it.
For me, the solution was Build Phases - Link Binary With Libraries add libc++ and works, in my legacy project.
My solution for this problem was:
Change "Build Active Architecture Only" to "Yes" also for "Release".
The setting can be found selecting your project > "Build Settings" > "Targets" (your target) > "Architectures"
do it in your project targets and also do it in your projectTest targets
Extending Ricardo's answer here. Select the “Build Phases” tab, click the “+” next to “Link Binary With Libraries” and add -
Security.framework
SystemConfiguration.framework
StoreKit.framework
libsqlite3.tbd
libz.tbd
libc++.tbd
As per Google, developers should use Crashlytics via Firebase. This worked for me as of Firebase v5.16.0 and Fabric v1.9.0 (Xcode 10.1).
I solved the issue by adding $(inherited) $(OTHER_LDFLAGS) -ObjC -l"sqlite3" -l"z" -l"c++" -framework "Crashlytics" -framework "Fabric" -framework "Security" -framework "SystemConfiguration" -framework "UIKit" to other linker flags in Build Settings.
In Project(not target) Info tab set the configuration file to none and run pod install again
On M1 Mac
In Excluded Architectures Add "Any iOS Simulator SDK" - "arm64" in Target, Test, and all libraries you added.
I solved it by removing "library which causes the error" from other linker flags.
I've got the following error when building the project in Xcode:
ld: file not found
/Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Products/Debug-iphoneos/Social_Events.app/Social_Events
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'm stuck with this error for the past hour.. Any solutions?
Code worked fine in iOS 7 and xCode 5.0. Now for iOS8 it gives me this error.
Using frameworks:
CoreTelephony
Mapkit
Facebook.SDK v3.20
Foundation
CoreGraphics
UIKit Framework
FULL ERROR:
<pre>
Ld /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Intermediates/Social_Events.build/Debug-iphoneos/Social_EventsTests.build/Objects-normal/arm64/Social_EventsTests normal arm64
cd /Users/MacBookPro/Desktop/Social_Events/Social_Events/Social_Events
export IPHONEOS_DEPLOYMENT_TARGET=7.1
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
</pre>
>/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch arm64 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk -L/Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Products/Debug-iphoneos -F/Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Products/Debug-iphoneos -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/Developer/Library/Frameworks -filelist /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Intermediates/Social_Events.build/Debug-iphoneos/Social_EventsTests.build/Objects-normal/arm64/Social_EventsTests.LinkFileList -dead_strip -bundle_loader /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Products/Debug-iphoneos/Social_Events.app/Social_Events -framework XCTest -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=7.1 -framework XCTest -framework UIKit -framework Foundation -Xlinker -dependency_info -Xlinker /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Intermediates/Social_Events.build/Debug-iphoneos/Social_EventsTests.build/Objects-normal/arm64/Social_EventsTests_dependency_info.dat -o /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Intermediates/Social_Events.build/Debug-iphoneos/Social_EventsTests.build/Objects-normal/arm64/Social_EventsTests
>ld: file not found: /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Products/Debug-iphoneos/Social_Events.app/Social_Events
clang: error: linker command failed with exit code 1 (use -v to see invocation)
>(null): File not found: /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Products/Debug-iphoneos/Social_Events.app/Social_Events
You might be getting this error because you renamed your project and Tests cannot be found anymore. This is easy to fix:
Solve it in Xcode like this:
Select your project from the project navigator.
Select [Your project's Tests] under targets
Under General tab change the Host Application from the drop down
Build and run.
This problem happened to me because I renamed my project and the tests could't find it anymore.
The problem is that after renaming the product its Tests target is still looking for the previous app name.
Select your Tests target and then in Build Settings modify the TestHost values to correspond your new product name in the following way:
$(BUILT_PRODUCTS_DIR)/YourNewProductName.app/YourNewProductName
I had a similar problem -- it's because I was using Cocoapods and had opened the .xcodeproj file instead of the .xcworkspace file... doh!
I have solved it by renaming the product.
In the Application's target choose Build Settings.
Under the Packaging options, you have to rename your product to the name thats shown in the error.
It solved my problem and the code started compiling. My test cases are also executing.
Did you try cleaning up your derived data?
Xcode5->Organizer->Projects->Select your project->Delete the derived data.
Try to remove "Social_EventsTests" target.
Goto Build settings of your tests named PuzzleGameTests.
Go to Testing settings, write $(BUILT_PRODUCTS_DIR)/PuzzleGame.app/PuzzleGame
Clean and build
Note: PuzzleGame is new name of my project(product name).
RandomNumber is old name of my project(product name).
I had issue with "framework not found". It was after renaming my project.
Go to Project settings, select the target (not the project). In the General tab, find "Linked frameworks and libraries", and delete the old name.
I encountered similar problem while adding FBSDKCoreKit.framework and solution was :
If frameworks already added then remove it with option remove all references.
Drag & drop frameworks straight in the group you want it to put in project.
do not re-drag or change its location afterwords
Note: When we drag & drop frameworks in xcode it automatically set framework search path under <yourproject> -> Targets -> <yourproject> -> Search Paths -> Framework Search Paths .
once we relocate the frameworks, the Framework Search Paths becomes empty and it results in linker error , framework not found.
Had similar kind of problem when I added unit test target to my existing project. Got all sorts of error. Had to run through some loops to get it finally running. Listing them below
Make sure your entry under Header search path for test target matches that for Header Search Path in your main project folder
If you are using pods you might run in some error such 'No Module found Firebase'. For this simply add the following lines of code to your pod file and run pod install
target 'YourProjectNameTests' do
inherit! :search_paths
# Pods for testing
end
If you also get Bridging header file not found error like I did make sure you add the same for your test target in Build settings under Swift compile code general
Also you will have to follow the steps mentioned by #Jose Llausas
I had similar kind of problem when I added a framework to my project.
I have resolved the issue by removing the framework and again adding the framework to the project by dragging and dropping the framework file to the projects frameworks folder and selecting the Copy items if needed option.