Swift: Apple Mach-O Linker Error - ios

I'm working on Parse/Facebook login that keeps giving me the following error:
Undefined symbols for architecture x86_64:
"_FBSDKAccessTokenDidChangeNotification", referenced from:
There are over 60+ such errors, not sure why they are appearing since this code is working in a different project. I was copying over some code and this started happening, any advice?

Check if you have the import part copied to your new project as well, so does the dependencies.
When it said undefined symbols, it means the function _FBSDKAccessTokenDidChangeNotification can't be found while compiling, which usually means the correspond framework/SDK/library were not there.

While I'm not sure what caused this issue, the following solution cleared up the error messages:
Go to the main page for the app (on the navigation thing on the left click on your apps name or the top section) -> Build Settings and under Linker Flags, make sure there is nothing in your Other Linker Flags

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 i386: trying to add in AVFoundation

Attached is an error readout I've been getting. I've added the proper frameworks in my linked libraries, I've checked my target memberships for implementation files, I just don't know why I'm constantly getting the error below.
My project was building fine the other day, and when I opened up my computer the next morning and tried to build, I was given these error messages. I messed around with the architecture in my build settings, as per advice from other stack overflow questions, and it brought the number of errors from 20 down to 5. Still totally confused on this.
You are getting this error because you have not added AssetsLibrary in your project.
Add that library in "Link Binary With Libraries" your error will be gone.

entry point (_main) undefined xcode 6

I can't for the life of me find a solution to this! I'm using Swift. All of a sudden I get this error:
Undefined symbols for architecture i386:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture i386
It doesn't matter what simulator/device I try to run for, I still get it:
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
What is this?! I've almost removed everything from my project. I.e. all frameworks and everything. It's still there.
Please help me
Have this in your AppDelegate.swift:
import UIKit
#UIApplicationMain
Another cause (not for you but for others searching for an answer) is that AppDelegate.swift is for some reason not included in the app target. I don't know why that would happen-- I assume it was user error on my part-- but without that you'll get this error, and the cause isn't obvious. Make sure the checkbox for the file is checked in the app target.
I had the same problem, but I just forgot to put #UIApplicationMain on the top of the AppDelegate.swift
My Issue was this:
"main.m" got removed the project.
My problem was the following. I had 2 AppDelegate files. The original one that I wanted to delete, and another one I wanted to add. I first added the new one to the project and then deleted the old one. Following this order created a linker error. It worked when I deleted the new one and added it again to the project. Cheers
I had this same error and found that main.m was included in the list of project files, but was not ticked in the Target Membership list.
Some of the classes and frameworks(like FB SDK) are not ticked like in the picture.
So, I manually ticked(only .m files and frameworks) in all classes and frameworks in the Project Navigator.
If this error come you have two problems:
you comment out (with //) the appleDelegate.swift, you should uncomment it
you miss the appleDelegate.swift in your project
To fix this issue in Xcode 12.3, add the #main attribute to AppDelegate.

How to add CocoaHTTPServer to an iOS project on XCode 4

I'm trying to add CocoaHTTPServer to my project. I encountered many problems on the way - my problem (adding CocoaHTTPServer to a project (and have it working)) is still there - but I've also included the errors and solutions I encountered on the way for others' reference.
First I looked at tutorials on adding a framework, but it didn't look like a framework.
Next I right clicked on my project (on the left sidebar), and manually added it with "add files". I followed the SimpleHTTPServer example but got a "cocoa/cocoa.h" not found error. I searched around and found that Cocoa is for mac and not iOS. But the CocoaHTTPServer description talks about iOS apps too, so I just deleted the samples folder (the error was coming from the DynamicHTTPServer example if I recall.
Then I got a "Lexical or preprocessor issue libxml/parser.h not found" error. I tried adding it as a framework, but that didn't work. I found this tutorial on adding libxml to the header search path (at the end), but I ended up with 46 "Apple Mach-O Linker Error _CFHTTPMessage..." errors, and I decided to ask my question here. I tried this answer but got many Apple Mach-O Linker Errors
I added CFNetwork and Security frameworks (project => build phases => link binary with libraries), and was left with 2 errors:
ld: warning: path '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/usr/lib/libxml2.dylib' following -F not a directory
Undefined symbols for architecture i386:
"_NSlog", referenced from:
-[AppDelegate application:didFinishLaunchingWithOptions:] in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I see i386 which is intel, and not the ARM architecture on iDevices. However, the real problem was I mispelled NSLog (look carefully - it wasn't capitalized in the error message). When I googled this - other possible causes may be missing frameworks.
Now it compiles. When I run the sample application, I get the "server started on X port" and when I go to localhost:X I get the welcome/success screen. When I do the same on my project, I still get the "server started on X port" messages, but when I go to localhost:X the browser gives a "cannot connect" messages. No errors in the XCode console.
There are no errors from [httpServer start:&error] and httpServer.isRunning is true.
So what's the best way to add CocoaHTTPServer to my project? In terms of a clean setup - for example, when I inspect the sample iPhone project, I don't see any of the messy steps to add libxml - I don't even see libxml anywhere at all. And in terms of configuring everything so that it actually works and serves files. Right now, I'm suspecting there may be some project settings that need to be enabled for it to actually be a server.
While adding the external files, have you checked your project as a "Build Target"?

iOS: Pull To Refresh error

I'm trying to implement a "pull to refresh" functionality to my table views.
I found a couple of classes that should do the trick (iStopped's PullToRefreshView & Leah's PullToRefresh)
Both classes throws me an error about undefined symbols for i386...
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_PullToRefreshView", referenced from:
objc-class-ref in FeaturedTableView.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit
code 1 (use -v to see invocation)
Thing is.. I linked against QuartzCore.framework in the Build Phases..
And in the Build Settings, under "architectures" (and "valid architectures"), I see both "armv6" & "armv7".
I searched around the web for that error regarding PullToRefresh, and all I could find is that the framework is missing... but it isn't (I even removed it and re-added it).
I also came across this tutorial, which says I need to Refactor (edit -> refactor) my project (convert to Objective-C ARC), but I can't do that because when I choose my target, I get LOTS of errors (especially from the Facebook SDK).
Isn't there a simple way to add a pull to refresh functionality? :)
Any help would be much appreciated!
Thanks!
Ok, I've found the actual issue:
I have several Targets that share the most of the project's code.
When I was importing the PullToRefresh class, I de-selected all of the Targets, because I noticed that all the other shared files in the project had all the targets in their properties de-selected...
When I re-imported the class and selected all the Targets, everything works fine... I'm now actually using the EGOTableViewPullRefresh and it's working great.
So I guess de-selecting all targets doesn't mean that it's completely shared across all targets :) I wonder why all my view controllers and all don't have any targets checked and they are available to all targets...
But the issue has been resolved (^_^)
Thank you, #jrtc27 , for making me check the import procedure again.
(Without seeing your code) You need to import the PullToRefreshView class.
#import "PullToRefreshView.h"
Or you need to make sure that your table controller (which seems to be FeaturedTableView) is a PullRefreshTableViewController.
Example
#interface FeaturedTableView : PullRefreshTableViewController
{
/* your objects here */
}
#end

Resources