Error running Simulator: duplicate symbol for architecture i386 - iphone

I added ShareKit framework to try and here is the error running it in Simulator:
duplicate symbol _LFHRReadStreamClientCallBack in
.../Xcode/DerivedData/....build/Objects-normal/i386/LFHTTPRequest-8C6F35228BA446B9.o
and
.../Xcode/DerivedData/....build/Objects-normal/i386/LFHTTPRequest-8ACF920D803FDCA6.o
for architecture i386
I looked at previous posts Build Error - missing required architecture i386 in file and tried to edit project.pbxproj commenting FRAMEWORK_SEARCH_PATHS lines out as well as looking for .framework files accidently added to my project but with no luck.
What else can I try?

You've included LFHTTPRequest in your project twice. It's possible that another library (such as sharekit) included it for you, doublecheck the files sharekit includes and remove one copy of LFHTTPRequest and things should compile.

This can also happen if you move coredata-generated classes into a group, like "Models" and then regenerate the NSManagedObjectModel subclasses. The generated files will be placed in the project root and added into the build twice.

I got the same error when working with TessBaseAPI. I had two c++ files and both had the following declaration:
namespace tesseract {
class TessBaseAPI;
};
tesseract::TessBaseAPI *tesseract1;
uint32_t *pixels;
The I read the full error message. I got a line there:
duplicate symbol _tesseract1 in
And later, which files contains the duplicate also included (the file name).
So, I changed the instance name as follows:
namespace tesseract {
class TessBaseAPI;
};
tesseract::TessBaseAPI *tesseractNew;
uint32_t *pixelsNew;
That solved my problem.

Related

Linking dynamic library within static framework

I am building the static iOS framework upon multiple libraries in Xcode. One of them should be the card.io. I cannot use cocoapods or carthage. So far I imported .frameworks within the .framework and it works pretty well. However card.io uses static library (.a file) with bunch of headers. It works well in dynamic type of .frameworks (or iOS app project) but in static project I get these errors on including of the .a files:
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lCardIO
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lCardIO is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lopencv_core
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lopencv_core is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lopencv_imgproc
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lopencv_imgproc is not an object file (not allowed in a library)
Regarding these errors I downloaded the source codes of card.io and it looks that there is dynamic .framework target waiting for build. I tried to use this one instead of .a files and headers - so my project at least can be builded. Because the card.io does not contatin architectures for simulator (which, by the way, it should with this release 5.2.2) I am not able to test it in unit tests, so when I test this solution on device I get this error:
dyld: Library not loaded: #rpath/CardIO.framework/CardIO
Referenced from: /var/containers/Bundle/Application/55D3AF7F-83F4-4B3D-A667-0FCO93CCC441/App/AppDemo
Reason: no suitable image found.
So far my knowledge+google+stackoverflow is stuck here, because it looks that xcode does not support the .framework within .framework this way.
To this moment I spent two days with this "issue", so the question is: Does exist any solution for including dynamic library into static framework? Or any solution to include card.io into static framework?
EDIT:
Well actually the solution was more stupid than I would think (as always). Just to include card.io in the .framework go to "Project Description -> Build Settings -> Library search paths" and type the path where should xcode look for the libraries. This approach solves the first one issue of this post - this means the implementation of the .a libraries and headers.
At this moment I cannot guarantee it will work in releases based on my framework so I will update this post to confirm it later. I hope it helps someone...

Can't build command line project with SQLite.swift

I'm trying to build a command-line tool which uses sqlite. I have downloaded Stephen Celis' swift wrapper, SQLite.swift, and built a working OS X app. However, I am not able to build my command-line tool. I believe that I correctly followed the instructions to do so in the SQLite.swift Documentation for frameworkless targets, but apparently I am missing something. I get an error in Helper.swift # import CSQLite -> No such module 'CSQLite'.
I am linking against libsqlite3.dylib (also tried libsqlite3.tbd)
I added the SQLite.swift source to my project
I added #import sqlite3.h & #import "SQLite-Bridging.h" to my bridging header file. Perhaps of note, when I right-click on sqlite3.h or SQLite-Bridging.h, xCode does not know where/what they are.
I'm happy to send my test project (about 80KB, compressed) to anyone who can and is willing to help. There is probably a very simple solution, I just do not see what it is.
thx for any help,
-Craig
I've faced the same problem.
There were lots of compiler errors like "Connection.swift:26:8: Could not build Objective-C module 'CSQLite'"
The error has roots to the "lctx.h:13:25: Use of undeclared identifier 'SYS_getlcid'"
It worth mentioning that I have two Xcodes installed - v 6.2 at /Applications and v 7.3 at ~/Applications. My project is iOS app on Swift with SQLite pod and I open it with the Xcode 7.3.
The SQLite pod has a file at project_folder/Pods/SQLite.swift/CocoaPods/iphonesimulator/module.modulemap.
The file had the content
module CSQLite [system] {
header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/sqlite3.h"
export *
}
To fix compiler errors I changed the content of module.modulemap to
module CSQLite [system] {
header "/Users/my_user_name/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/sqlite3.h"
export *
}
The change is that I pointed search of sqlite3.h into my ~/Applications folder where Xcode 7.3 is located.
This made my project compiling.

mpglib_interface.c 'interface.h' file not found

I an trying to compile the WunderRadio app source code available here http://dev.wunderground.com/support/wunderradio/wunderradio.1.9lgpl.zip. After making all the modifications to the project to compile on iOS5 i get the following error:
Lexical or Preprocessor Issue 'interface.h' file not found.
Of course i tried getting the interface.h from the lame library that i previously downloaded, and added it to the project with no luck. Apparently its not the right file.
What am i missing ?
I found this file at:
http://code.google.com/p/live-converter/source/browse/trunk/include/interface.h?r=13

Struggling with Xcode 4

I've recently downloaded Xcode 4 and now two of my projects that were working perfectly fine before have started giving me errors. Both errors are effectively to do with linking options, but I can't figure out how to change these options and get rid of the errors.
The first problem is with a project written in C++ using the SDL_ttf and SDL_image frameworks. The project builds correctly, but when I try to run, it gives me the following warnings on the console:
warning: Unable to read symbols for #executable_path/../Frameworks/SDL_ttf.framework/Versions/A/SDL_ttf (file not found).
warning: Unable to read symbols from "SDL_ttf" (not yet mapped into memory).
warning: Unable to read symbols for #executable_path/../Frameworks/SDL_image.framework/Versions/A/SDL_image (file not found).
warning: Unable to read symbols from "SDL_image" (not yet mapped into memory).
Since the files are not being found, the executable cannot load any images making it exit straight away when I try to load images. I think the issue here is that the frameworks are not in the directory above the executable, they are in /Library/Framework/ which worked fine before in Xcode 3.2. How do I resolve this?
The second problem comes when compiling an application I wrote for iOS. Along with giving me a bunch of warnings about depracated code on iOS 5, which I will deal with later, it fails to build due to a linker error which I have no clue how to resolve, it says:
ld: library not found for -lz.1.2.3
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang failed with exit code 1
I can answer the second question.
-lz.1.2.3
should be
-lz
You might have accidentally added the zlib.1.2.3.dylib to the project's "link binary with libraries" build phase. You should use the standard zlib without any version in its filename, or simply add -lz to the Other Linker Flags under Build Settings and not add zlib in the "link binary with libraries" build phase.
As for the missing frameworks my best guess is that it has to do with the relative path, ie if you can get rid of the /../ part and instead provide an absolute path that might resolve the issue.

Issues when installing th json framework on xcode4

Hello
I am trying to install json framework. According to installation instructions I have to copy all the classes from json-framwork/classes in my project! I did that and I am getting this error:
ld: duplicate symbol
_OBJC_METACLASS_$_SBJsonParser in /Users/user/Library/Developer/Xcode/DerivedData/testhttp-eavsbuatbfoagsgbqfnevfpjxxfc/Build/Intermediates/testhttp.build/Debug-iphonesimulator/testhttp.build/Objects-normal/i386/SBJsonParser-4254E5B76E32172.o
and
/Users/user/Library/Developer/Xcode/DerivedData/testhttp-eavsbuatbfoagsgbqfnevfpjxxfc/Build/Intermediates/testhttp.build/Debug-iphonesimulator/testhttp.build/Objects-normal/i386/SBJsonParser-46310C881BFA9776.o
for architecture i386 collect2: ld
returned 1 exit status Command
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2
failed with exit code 1
What I am doing wrong here?
Please have a look at:
iPhone: Duplicate Symbol Error?
Select the project navigator in the right sidebar. Double click your project(top element).
Now open the build phases tab. There is a section which is called Compile Sources. Open it an check if there is a duplice entry of the file which the error refers to.
My Installation of the json-framework
Just added these files to my project
Each .m file is here only once
In the class I need JSON parsing I'll just import:
#import "JSON.h"
I just erase the .m and .h files from JSON Framework wich the compilator was giving me errors, at the end I just keep from the JSON Framework: NSObject+SBJSON, NSSTring+SBJSON .h and m.
This worked for me, I hope it helps :D