iPhone Application Linking/Compile Errors - iphone

I'm working on an iPhone application. I added a new framework to my project, and this caused a bunch of linking errors, with the following error for each framework I'm using:
ld: warning: in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/System/Library/Frameworks/Foundation.framework/Foundation, missing required architecture i386 in file
This caused other errors, saying things like NSString did not exist. I deleted and re-added all frameworks several times to no avail. As another attempt to fix the problem, I copied all my source files to a new directory and created a new project. When trying to compile in that project, I get the error:
ld: duplicate symbol .objc_class_name_${PROJECT_NAME}AppDelegate in /Users/nick/Documents/SVN/Programming/iPhone/${PROJECT_NAME}/newTrunk/${PROJECT_NAME}/build/${PROJECT_NAME}.build/Debug-iphonesimulator/${PROJECT_NAME}.build/Objects-normal/i386/${PROJECT_NAME}AppDelegate-B70D3802A4DFAE4D.o and /Users/nick/Documents/SVN/Programming/iPhone/${PROJECT_NAME}/newTrunk/${PROJECT_NAME}/build/${PROJECT_NAME}.build/Debug-iphonesimulator/${PROJECT_NAME}.build/Objects-normal/i386/${PROJECT_NAME}AppDelegate-B70D3802A4DFAE4D.o
(I've replaced parts of the above with ${PROJECT_NAME} because I'm not currently able to discuss specifics of the project.)
If anyone has any insights into either of the problems I'm experiencing, I would love to hear from you.

Which way did you use to add the framework?
Did you doubleclick the app in the left bar under Targets and link the library there?

Related

Apple Mach-O Linker error. "_OBJC_CLASS_$_SwiftObject" and Foundation undefined

I have a project with library in it. If I select library as a build target it builds successfully. If I select project as a target I have linker error Undefined symbols for architecture x86_64: and list of undefined symbols.
What is strange – all that symbols are standard things like "_OBJC_CLASS_$_SwiftObject", "Foundation.URLRequest.httpBody.setter : Foundation.Data?", "Swift.String.init(Swift.Substring) -> Swift.String".
This errors disappears when I'm removing SawtoothProtobuf.pb.swift file from build. However when building only lib project which contains this file everything builds successfull.
I'm running into a VERY similar issue too. I've tried to build a static library from swift framework to be accessible by obj-c by putting #objc and #objMember in front of all the required things and I'm getting similar errors as you are. It's weird though because it works in the framework works in the demo app from the code owner but it fails when I install it on mine...
Adding a blank swift file fixed it for me. I guess there needs to be some swift libraries loaded into the app which doesn't happen if there's no exposed swift code.

Library not Loading/Image not Found - Swift 4.0

So I am very new to Swift and XCode. I am trying to use an external library called JJFloatingActionButton the projects build fine but when I try run it on an emulator I get:
dyld: Library not loaded: #rpath/JJFloatingActionButton.framework/JJFloatingActionButton
Referenced from: /Users/mkangwa/Library/Developer/CoreSimulator/Devices/
3E58C8A1-3F02-4CA0-8EF3-A79311A202A2/data/Containers/Bundle/Application/D8BBF9A8-5BC7-4619-
B08C-2E6F7C6BCB85/DriversHub-iOS.app/DriversHub-iOS
Reason: image not found
Now of course I know you can't come ask a question like this on StackOverflow without researching and trying to find a solution yourself, so thats what I've been doing for the past few hours I have been looking at what was causing this, I started thinking that maybe it was the library it's self so this one is the third or fourth I've tried till I came across a few posts on SO that were about this issue.
Most people fixed this by just putting the Framework into the Embedded Binaries in the targets General Settings. And I tried this but I now receive a log:
I also get a Dependancy Analysis Warning:
I don't know much about these types or warning and errors but it's saying that it can't find the file which is pretty self explanatory but when I am adding the file to Embedded Binaries it shows the framework file there
What I often do when I have problems with cocoapods is remove cocoapods from the project and reinstall it.
You could use pod deintegrate (https://github.com/CocoaPods/cocoapods-deintegrate) to remove it and then a pod install to reinstall.
So it took a day and a half to work this out but I have finally got it and I can carry on with my project.
Problem:
The problem in my particular case (because other methods seemed to have worked for people trying to achieve the same thing) that the reason my project wouldn't build and was throwing Build Time errors was because after adding the Framework to Embedded Binaries it was also adding it to Embed Frameworks in my targets Build Phases. This then, I believe, caused the compiler to try and build it twice hence the Multiple Build Commands error
Solution:
So the errors I kept getting where saying No such file or directory above it was saying Multiple build commands for output file and what I did to fix this I went to Build Phases in my target settings and deleted the framework from Embedded Frameworks but made sure it was still under [CP] Embed Pods Frameworks.
in my case I was have to make framework "embed & sign" in stead of "don't embed"

Restkit and three20 with ios5

I have some serious issues...I need to build a project from another developer in ios 5 and Xcode 4.2 which which has both RestKit and Three20 library...
At first I deleted those two libraries and used fresh copies of two...they did built but I found out other developer edited the restkit and used three20 inside the restkit also...So I have to keep the old restkit...then restkit is ok but I had to integrate three20 both to my main and restkit project...then I integrated that..after integrating I found this error..
ld: duplicate symbol _OBJC_CLASS_$_TT_FIX_CATEGORY_BUG_UISplitViewController_TTNavigator in /Users/mdrezaurrahman/Library/Developer/Xcode/DerivedData/Fake_Conversation-dyigdwifnataxadzsxfirsdjnhsc/Build/Products/Debug-iphonesimulator/libThree20UICommon.a(UISplitViewController+TTNavigator.o) and /Users/mdrezaurrahman/Library/Developer/Xcode/DerivedData/Fake_Conversation-dyigdwifnataxadzsxfirsdjnhsc/Build/Products/Debug-iphonesimulator/libRestKit.a(UISplitViewController+TTNavigator.o) for architecture i386
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang failed with exit code 1
then I thought it is because two project is using same libraries at a time..Then I used two copies of Three20 and integrated one with main project and another with restkit project
then I faced this error
ld: duplicate symbol _OBJC_IVAR_$_TTSectionedDataSource._items in /Users/mdrezaurrahman/Library/Developer/Xcode/DerivedData/Fake_Conversation-bbrkduxuzifkumgngujfpbbboyzb/Build/Products/Debug-iphonesimulator/libRestKit.a(TTSectionedDataSource.o) and /Users/mdrezaurrahman/Library/Developer/Xcode/DerivedData/Fake_Conversation-bbrkduxuzifkumgngujfpbbboyzb/Build/Products/Debug-iphonesimulator/libThree20UI.a(TTSectionedDataSource.o) for architecture i386
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang failed with exit code 1
I think this is the same error...can anyone show me the path?
Looks like you are trying to link two copies of the Three20 Library into one binary. That would not work. If the copy of RestKit you obtained already contains Three20 then you would not need to link it separately. If it only contains part of Three20, try to get rid of that part.

Duplicate dylib

Is there a general solution for "Duplicate dylib" warning when building Xcode project?
I've seen these two posts and but they are not enough information to me.
Safely resolve dylib warning?
Duplicate dylib warning in xcode
My warning is:
ld: warning: duplicate dylib /Xcode3.2.5/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/usr/lib/system/libSystem.host.dylib
I also have that library twice in my Xcode installation, so the problem does not lie with the file being duplicated, but with your project linking it twice.
I suggest first of all to make a clean build, the build again. If your project is ok, this should fix it.
EDIT:
Then, I think that your project got somehow corrupted when doing an upgrade from one Xcode version to another (I am just guessing based on my experience). Could you check in the framework section of your project if you have multiple libSystem? Ideally, you should open the *.project file inside you project bundle (it's a text file) and search there for any appearance of libSystem... see whether you find anything suspect...

SQLite on the iPhone, strange linking errors

I've been reading through this tutorial for using a SQLite database within an iPhone app. This is great and I've got everything working nicely, in the Simulator. As soon as I build to device I get the following linker errors:
ld: warning: in
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/libgcc_s.1.dylib,
missing required architecture arm in
file ld: warning: in
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/libSystem.dylib,
missing required architecture arm in
file ld: in
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/libobjc.A.dylib,
missing required architecture arm in
file collect2: ld returned 1 exit
status Command
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2
failed with exit code 1
I've tried including different versions of the libsqlite3.0.dylib files as mentioned around this site and other message boards but it doesn't make anything any different (and yes, I have tried cleaning).
If anyone has had a similar issue, how do you get around this?
It looks like you are linking against "Current OS" as SDK. You should select an iPhone SDK in your build settings.
Edit:
Alternative you have selected a library in a different SDK than your current.
The solution to this was very bizarre, and I'm not entirely sure what I've done by removing it... However, this is what I did...
Under the target build settings, I noticed in the "Search Paths" section that under "Library Search Paths" the following was set:
"$(inherited)"
"$(DEVELOPER_DIR)/SDKs/MacOSX10.6.sdk/usr/lib"
"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk/usr/lib"
"$(SRCROOT)"
I checked this with applications that I had created before iPhoneOS 3.1.3 was released and it was blank. By removing the above, my application built and compiled straight away...
Very strange. Thanks goes to Claus Broch for getting me 50% of the way there!