I just finished installing CocoaPods. My app target builds and runs.
I added a link_with line in my Podfile to allow cocoapods to also add the frameworks to my Tests target. Now I get some linker errors when trying to run tests. I was able to resolve a missing XCTest error by specifying the XCTest framework in other linker flags as in the picture.
I'm still left with this, which is a reference to a class in my project. There are a couple other references to other classes in my tests that don't seem to cause an error, I can see nothing different ServerController.
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_ServerController", referenced from:
objc-class-ref in TestServerController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here's my header search paths:
To me, this looks like you're trying to compile and run tests on the simulator without actually building for the simulator's processor architecture.
Your test project might have i386 listed as a valid architecture, but does your main project have it listed there as well?
Check Valid Architectures in your build settings for your product's target and make sure i386 is listed as a valid architecture, then clean and build for testing again.
Related
I've done this before, several years ago with Xcode 5 or 6. Now using Xcode 8 or 9, I seem to be missing someting.
No matter what I've done, when I try to build and link my project, I get the Linker message:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_MyClass", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is not a duplicate question. It is not an architecture issue.
None of the other results I've found on S-O or google resolve this issue.
I'm obviously missing some build settings, but cannot figure out which one(s).
Between build attempts I've cleaned the build folder, and deleted DerivedData. Quit and restarted Xcode. Created a new set of projects with a new workspace and walked through the steps outlined below.
I'm writing in objective-C for this project if that matters (I don't think it does)
My question is what did I forget?
What I did --
Create a project for my framework and static library
a) create the project for a cocoa-touch framework - let's call it mySDK which creates mySDK.framework
b) Add a target for a cocoa-touch static library - let's call it SDK which creates libSDK.a
c) optionally build both targets -- they build fine
d) close the project
Create a project for my application - myApp - then close the project
Create a workspace - myWorkspace -- and open the workspace
Drag both project files from #1 mySDK and #2 myApp into the workspace
Build the framework and static library (both build and create the targets successfully)
Add the static library to myApp
a) Select myApp and go to build phases
b) Open Link Binary with Libraries
c) Drag from the library build products libSDK.a into the link binaries pane, set to "Required"
The library now appears in the Frameworks group-area in the myApp
7) Select the myApp project and go to build-settings
Add to Header Search Paths = "$(SRCROOT)/../mySDK/mySDK"
This resolves compile errors in finding the headers
Now I ask, why do I need to do anything else, shouldn't Xcode figure the rest out?
Various solutions or tutorials I've reviewed suggest adding:
Other Linking Flags = -ObjC
Library Search Paths = $(BUILT_PRODUCTS_DIR)
Library Search Paths = "$(SRCROOT)/../mySDK"
Changing Skip Install from YES to NO
Installation Build Product Location = $(BUILT_PRODUCTS_DIR)
I've tried all of these in different combinations.
Once I added the library to myApp I see that the Frameworks/libSDK.a file changes from red to black when I build the library so something in the workspace/project knows I built the library and it sees it.
So why when I try build myApp, do I still see the liner error:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_MyClass", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Nothing I have done seems to clear that error. I am pulling my hair out trying to find a solution.
I have also checked that it is building all the appropriate architectures, confirmed it using 'lipo -info'
Xcode obviously knows about the library, why isn't it linking?
My app also compiled with no problem but would hit an error while linking to the static library. My library was based on C++.
I had 2 problems to fix in my case:
The headers lacked proper extern "C" declarations for C functions in a C++ file.
One .cpp file did not #include its matching header so the extern "C" would be properly applied to the compiled version.
The linker had issues because the compiler used a mangled name for the function due to the mistakes. Later confirmed this by looking in the .a file with a text editor. I found my function with "_Z11" prefixed and "v" suffixed.
There was another clue: the error was reporting the missing function name with an underscore at the front.
Undefined symbols for architecture arm64:
"_myCFunction", referenced from:
SwiftModule.swiftFunction () -> () in MySwiftClass.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
When trying to build my iOS app in Xcode, I get the following error message.
Undefined symbols for architecture i386: "OBJC_CLASS$UIPresentationController", referenced from: _OBJC_CLASS$SSSidebarPresentationController in libtools.a(SSSidebarPresentationController.o) "_OBJC_METACLASS$UIPresentationController", referenced from: _OBJC_METACLASS$_SSSidebarPresentationController in libtools.a(SSSidebarPresentationController.o) ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have the latest version of Xcode. I have tried cleaning and deleting derived data but that did not help. I've noticed a lot of other people on the internet have similar error messages but the solutions did not help me.
Add the AVFoundation and CoreLocation frameworks to your target. After you do this, delete derived data, clean, and build again.
Also, check in your architectures under build settings and make sure that you have armv7 and armv7s listed under valid architectures. If the above answer does not fix your problem then try adding or removing arm64.
I am working on a project with the Swift programming language and I am trying to use some code from some older Objective-c projects. I have created the bridge file and imported the headers that I need but I get the following error, which I know it has to do with linking some framework, but even when I added CoreGraphics as an added framework it still appears. Any ideas?
Undefined symbols for architecture x86_64:
"_CGPointMake", referenced from:
_CGPointAdd in SKActionEffects-669E235BD7235D6A.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Thanks
UPDATE: setting the BaseSDK did not do the trick. This is what my build settings are like with xcode6.
Check if the "Target Membership" of your files are appropriate.
I don't think that adding a class to test target just to test it is a good idea. In my case checking "Allow testing Host Application APIs" made a difference.
I seem to be getting the error message while trying to compile TestFlightSDK in my app via cocoapods
Im my Podfile i have the line:
pod 'TestFlightSDK'
And the pod update works fine.
When i try and compile the app i get the message:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_TestFlight", referenced from:
objc-class-ref in OurDealAppDelegate_iPhone.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
my app is only supporting Architecture armv7 (because if i add armv7s or arm64 older libraries fail to compile - so i assume its something to do with this.
Is there any work around for this?
Okay, you need to confirm whether Cocoapods has included libTestFlight.a library in your project. Cocoapods has never added the library for me.
So, please follow the steps below:
Open the Pods-TestFlightSDK target in the Pods.xcodeproj project
Open Build Phases tab and add libTestFlight.a
libTestFlight.a can be found at [$SRCROOT]/Pods/TestFlightsSDK
Background:
I'm trying to use a Phonegap with cocoapods. Phonegap already has issues compiling from command line so I'm just using Xcode with the generated project file (and assumably I'd have to do that anyway when using cocoapods).
I've pushed up on Github a reproduced empty project with my problem:
https://github.com/Dan2552/phonegap-reproducable-issue
You can see the steps I made after making a plain brand-new Phonegap app in the build_ios script in the root directory on the repo. But I've also pushed up the generated project files (platforms/ios) so anybody without Phonegap should be able to open the project.
Problem:
I'm having a weird issue with compiling. Probably issues with the pre-bundled Cordova library and cocoapods.
When building without doing anything after generating the project with Phonegap and adding in the cocoapods, I get the following errors:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_OTPublisher", referenced from:
objc-class-ref in libPods.a(OpenTokPlugin.o)
"_OBJC_CLASS_$_OTSession", referenced from:
objc-class-ref in libPods.a(OpenTokPlugin.o)
"_OBJC_CLASS_$_OTSubscriber", referenced from:
objc-class-ref in libPods.a(OpenTokPlugin.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Cocoapods warns:
[!] The target HelloWorld [Debug] overrides the OTHER_LDFLAGS build setting defined in `Pods/Pods.xcconfig'.
[!] The target HelloWorld [Debug - Release] overrides the OTHER_LDFLAGS build setting defined in `Pods/Pods.xcconfig'.
and therefore I tried deleting the OTHER_LDFLAGS ('Other Linker Flags' in Xcode) entry altogether. This successfully compiles on an iOS device, but not on the simulator, nor will the project build on archive.
Building for simulator will get the same error as before (Undefined symbols for architecture)
Building for archive will get
/Users/dan2552/projects/ReproducableProblems/OpenTokPhonegap/Classes/OpentokPlugin.h:9:9: 'Cordova/CDVPlugin.h' file not found
I've also tried putting $(inherited) in the OTHER_LDFLAGS which produces the same results as deleting them.
Your included framework has no Simulator (i386) slice:
$ xcrun -sdk iphoneos lipo -info Pods/OpenTokSDK-WebRTC/Opentok.framework/Versions/A/Opentok
Architectures in the fat file: Pods/OpenTokSDK-WebRTC/Opentok.framework/Versions/A/Opentok are: armv7 armv7s
So its classes can't be linked for the Simulator.
Also if you plan to use CocoaPods you could remove the Cordova project and static library entirely and add pod 'Cordova' to your Podfile.
I've seen similar issues before when trying to run the Xcode project, rather than the XCWorkspace. The issue you're having sounds like it's because you're not running the workspace.
Go to your taget Build Settings -> Other linker flags -> double click . Add $(inherited) to a new line .
. Try this