Building Assimp for iOS - ios

I'm trying to build Assimp for iOS, it compiles fine, with no errors, however, when I try to use it in my project I get a lot of errors (154 to be exact) during linking. Judging after the method signatures, the errors are C++ related, however, I would like to use the C interface. I've tested with lipo and the library is compiled for my arch, it's actually a fat library. They are linker errors, should be easy to fix, alas, my lack of experience doesn't help. Here is a screenshot with the errors (first rows, as there are more than 100 in total).
How should I debug this? What went wrong?
EDIT: Thanks to #Zadr I managed to narrow it down to 8 errors:
_crc32 sounds very familiar, but still can't find the reason behind all this.

The library you're building was linked against one version of libstdc++, and you're trying to link against a different version.
In the project settings, there should be a "C++ standard library" field. Change that from the default option (clang's libc++, iirc) to the other option (gcc's).

In addition to what #zadr has already mentioned, you should also link libz.dylib for the last 8 errors to go away. I'm almost certain those functions are related with it and I know for sure Assimp uses libz.

First Tell Me if You have to Putted any framework as copy-paste ?? in most of cases this type of issue created.
Generally this Types of Error Occur when your class .m file is not store/putted under Compile Sources
In This case you need to add manually this .m file to Compile Sources
Following step Describe how to put .m file in Compile Sources manually
Select Project Form Project Manager
|
|
Targets
|
|
Build Phases
|
|
Compile Sources
|
|
Click on '+' button and add .m file in it
This is Step For how to put file manually in Compile Sources.

Related

external framework File/File.h (Parse/Parse.h) file not found

So every time I update my app, Xcode claims not to be able to find a particular external framework even though it's there. It's happened again with Xcode 6 and my usual methods (I'm fairly inexperienced, so these basically involve clicking and typing things until something happens (I exaggerate but not by much)) aren't working.
I'm getting a Lexical or Preprocessor Issue error that says 'Parse/Parse.h' file not found.' But here are screenshots of it in the project and added to the library:
I also followed the steps in the most upvoted answer at ‘ld: warning: directory not found for option’ but still nothing.
Any idea what to do? Any idea at all? I'm tearing my hair out here.
Actually I was facing the same problem but after doing lots of (removing/adding parse framework) efforts I come to know that parse.framework is already added and error was still there.
Real Problem was not in link Binary for main project but it was with Tests link Binary.
Lets say your project name is "project1" and Xcode create one more folder with it called "project1Tests". So select "project1Tests" and add parse.framework in link Binary.
Check out the hierarchy:
PROJECT
project1
TARGETS
project1
project1Tests (you need to select this to add parse framework).
Hope this would help you resolve this issue.
I had this error also. I'm developing in Swift, so I added a "bridge header" as described in this Parse blog post.
The reason I got the "Parse.h not found" was that my project name contained spaces. (For project name I mean the Product Name you enter when creating a new project, which determines your folder's name.) The first day all went well, but after closing and opening Xcode, it turns out that Xcode interprets the words separated by spaces as different paths.
To fix this, you can go to Build Settings -> Search Paths -> Framework Search Paths and add an "\" before each space. (If you double click the path you'll see that Xcode shows each word separated by space as a different entry.)
Also note that the bridge header with #import <Parse/Parse.h> it's not compulsory: you can simply do import Parse.
All I had to do was remove Parse.framework from this list by highlighting and pressing delete.
Then I went down to the plus sign at the bottom of that list and had to select Add Other and manually locate the downloaded .framework file.
In my case, the error went away after I added the path to the directory where Parse.framework was to the Frameworks Search Paths Build Setting:
My project didn't even have an entry for that setting, so you may need to create it as well.
I had the same issue when upgrading parse to 1.4v. You have to delete Parse.framework from Framework List and from the project directory, when removed from both places copy again and check "Copy items to destination's group folder". It worked for me.
Its work for me.
Just go to Build Active Architecture Only and Debug should be yes and Release should be No
In my case I had to do one more thing additional to Sukhchais' answer.
It seems that though the parse.framework appears in the 'link Binary with Libraries' list for the targets, they might not have linked properly for some reason. Just remove parse.framework from the list and add it again as mentioned. By that way I was able to resolve my issue.
Just to Share my findings in case if somebody might have the same issue:
Accidentally we had two references of Parse.framework inside our source code base at two different places. And a reference of Parse.framework was linked in Build Phases of the target, from the first place. But when the app is compiled, Xcode was not smart enough to get a reference and trowed an error: "Lexical or Preprocessor Issue" error when "Parse/Parse.h" is imported in .pch file.
After spending couple of hours by trying various options, removed a reference of Parse.framework from the source base and kept only a single reference. This solved the issue.
And the app compiled successfully :)
For people coming from Ionic + Cordova if you are getting this error I solved it by removing my current parsePlugin and replacing it with this fork.
For simplicity, I used these console commands (Replace PARSE_APP_ID and PARSE_CLIENT_KEY with your keys in the Parse Console):
cordova plugin rm com.parse.cordova.core.pushPlugin
cordova plugin add https://github.com/grrrian/phonegap-parse-plugin --variable APP_ID=PARSE_APP_ID --variable CLIENT_KEY=PARSE_CLIENT_KEY
Ok, so I was having this problem as well. I uninstalled all my pods, reinstalled them again, and had no luck.
So the good news (and bad news considering the time I spent trying to find the problem) is that I eventually managed to solve it. Apparently, you have to import Foundation/Foundation.h before parse. I don't know whether this will work for you or not, but I tried everything on the net, and only this seemed to work. If you have any instances of this:
#import <Parse/Parse.h>
#import <Foundation/Foundation.h>
flip it around so that Foundation is declared first:
#import <Foundation/Foundation.h>
#import <Parse/Parse.h>
I also read somewhere that some people had issues with Facebook SDK and Parse SDK import. Apparently, the two have Bolt.Framework in common or something, which causes error. I removed Facebook SDK as well, which at first didn't make any difference. I hope I could help.

Xcode 5 Architecture i386 multiple duplicate symbols

I found the source folder for architecture i386, by copying the path specified by the error message in Xcode. There were several .o files which apparently were conflicting, however whenever I deleted one, and ran the program, it would replace it. What do I do? Also I've cleaned it and closed everything and restarted my computer. Thanks
The .o files are just the compiled versions of your source code, which is where the conflicts really lie. What you have is several things named the same thing, and the linker is stressing out over it. Take one of the error messages, you'll probably identify the name it says is conflicting (not the file, the symbol), it might have extra padded symbols, but you should recognize a method name or variable name that you used. Search for that in Xcode, and see where you're defining it more than once. A symbol can have only one definition, so if you're using it in multiple cases, you need to resolve that.
Possible Issue
This problem usually happens when you import .h files to Compile Sources.
Possible solution
Steps to clean project
Click on your project
Select target of your project
Go to Build Phases
Expand Compile Sources
Remove all files there
Steps to configure it again
On Compile Sources click + to add files again
Highlight .m on search
Add all .m files to your project
Clean project by going to Product->Clean on XCode Menu
Click run, and hope it will work!

How do I use a C libary in my Objective-C iOS project?

I'm writing a program for iOS and want to use the Apache Portable Runtime and the Subversion C library in my project.
Since this is the first time I'm trying to do this I have no idea where to start.
I already made a new C/C++ library project, imported all apr.h and svn.h files in the project, set the sdk to iOS7
It compiles well and it outputs an .a file but when I import it into my project it doesn't get linked or something.
Could anybody know a tutorial or maybe a svn library for objective c? Or at least point me in a right direction.
The only results I get while googling it are:
"Objective-C should support C Libraries natively, this should be very easy"
Not so easy for me I suppose. ;)
This is how you can troubleshoot:
Click your blue project icon.
Select the Build phases tab in your main view.
Expand "link with libraries".
Make sure your .a file is in this list. If not add it.
If you still have problems check your build logs (right most icon on left pane). The build logs contain a long list of what your compiler did. There are icons to the far right looking like 5-6 lines on top of each other. Actually the icon is hidden until you hover over it.
Clicking this will expand a compiler step and show you exactly what arguments were provided to your compiler. This will be pretty long so it might be smart to copy to an editor. But it will contain switches such as -I for including header files, -L for location of libraries etc. Check that your .a file is in fact included during compilation of the code which depends on it. Should be a -l switch I believe.
If you have the sourcecode of the C project, you can directly put all the source code into your project. Xcode knows how to compile C code and it will just be compiled with the rest of your project.
As mentioned by #Adam-Smith, you can directly interface with the C objects in your Objective-C code and the C objects will not be managed by ARC

Includes fail to resolve correctly in Xcode workspace

I'm having trouble linking to a static library in Xcode 5. I did read the chapter on building and using a static library in the Pro iOS 5 Tools. What it told me to do after creating your static library, was to link against the framework in the Build Phases tab. That part is pretty straight forward. Then it says in the Build Settings, under "Header Search Paths", to add:
$(BUILT_PRODUCTS_DIR)
Then in order to use my static library, I just import it like so:
#import "ConversionCalculator/ConversionCalculator.h"
So this used to work up until yesterday. I tried adding a new static library to my project which didn't seem to work. So I cleaned my project, and tried rebuilding again, but now Xcode complains about #import "ConversionCalculator/ConversionCalculator.h". It says
Lexical or Preprocessor issue. 'ConversionCalculator/ConversionCalculator.h' file could not be found.
I was wondering if anyone has any tips on debugging this. I've looked through different tutorials like this:
http://blog.stevex.net/2012/04/static-libraries-in-xcode/
http://cocoamanifest.net/articles/2011/06/library-management-with-xcode-workspaces.html
http://www.raywenderlich.com/41377/creating-a-status-library-in-ios-tutorial
But I can't seem to find the "golden way" to link to a static lib, or how to troubleshoot why Xcode cannot find my file. My file structure is setup on my machine like so:
Projects\
DistanceCalculator\DistanceCalculator.xcodeproj
ConversionCalculator\ConversionCalculator.xcodeproj
DistanceCalculator.workspace
Like I said, this all used to work too when I followed the tutorial in Pro iOS 5 Tools book. Now I don't know why my workspace cannot find ConversionCalculator when it has used it before. The part I find hard is different articles say different things about the header search path, and I'm not sure what the best way to populate that field is. Any thoughts? Thanks in advance!
Edit:
I'll add that I can build for the device without errors. But when I switch to the iPhone simulator, it gives me that error about not being able to find the file. I also see that I get this warning:
ConversionCalculator was rejected as an implicit dependency for 'libConversionCalculator.a' because its architectures 'i386' didn't contain all required architectures 'i386 x86_64'
Looking at that, I'm not sure what that means. If it means that my library is not being built for all architectures, I just tried creating a Target that builds for all architectures according to the wenderlich article in the above link. That seems to work as when I go to the dervieddata folder, I see for debug, release, and universal, I see the libConversionCalculator.a file. But then when I go back into the workspace and try to rebuild the project for the simulator, I get that could not find file error and the implicit warning.
Edit #2:
I just saw a warning flag on Xcode that says upgrade to recommended Build Settings. Now I get no errors. Not sure what happened... but I guess no errors is good.
I would follow the description available in Xcode's Help topic "Linking Against Your Library" in chapter Configuration Your Application in Introduction to Using Static Libraries in iOS
(you may search within Xcode Help, too).
Except that I would recommend to include your headers from libraries always using angle brackets:
#import <ConversionCalculator/ConversionCalculator.h>
Using double quotes may inadvertently search and find files with the same name in some sub-folder relative to the file where this import directive is written. Only after there was no file in any sub-folder the preprocessor starts searching with the specified header search paths.
Using angle brackets, the preprocessor immediately searches only at the specified header search paths.
So, since you actually want to find headers for the corresponding library, always use angle brackets.
Note: If you follow the recommendation to create a static library project, you don't need to explicitly set a header search path in the target that links agains the library: Xcode will already add a search path:
$(BUILT_PRODUCTS_DIR)/includes
Your library headers are located in
$(BUILT_PRODUCTS_DIR)/includes/<product-name>
which are placed there through the "Copy-Files" phase of the iOS static library target, whose "Destination" is set to "Products Directory" and whose "Subpath" is set to "includes/${PRODUCT_NAME}" per default.
You may change these default settings to other reasonable and sensible values. (if you do, consider the the consequences for Xcode's default search paths!)

How to link a Cocoa Touch Static Library to a MonoTouch project?

I have created a Cocoa Touch Static Library using Xcode 4 and I want to use it in a MonoTouch project. How do I proceed?
Here is the content of my Static Library :
MyClass.h
MyClass.m
I built using "Build For Archiving" after following THIS BLOG POST and I took the libMyLib.a it generated and added it to a new MonoTouch Binding Project.
Then I replaced the content of libMyLib.linkwith.cs, because THIS BLOG POST said so.
[assembly: LinkWith ("libMyLib.a", LinkTarget.ArmV6 | LinkTarget.ArmV7 | LinkTarget.Simulator, ForceLoad = true, Frameworks="CoreGraphics QuartzCore UIKit")]
Then I added this to ApiDefinition.cs
I left StructsAndEnums.cs empty.
Then I built with Release and took the dll from the bin folder and added it to the root of a MonoTouch iPad project, and added it to the references.
Then, after following the instructions in THIS ARTICLE, I set the mtouch arguments to this
-gcc_flags "-L${ProjectDir} -lMyLib -force_load -ObjC"
Then I tried to run the project and I got this error in the Build Output
error MT5201: Native linking failed. Please review user flags provided to gcc: "-L/Users/herpderp/Projects/TestProject/TestProject" "-lMyLib" -force_load "/Users/herpderp/Projects/TestProject/TestProject/libMyLib.a" "-L/Users/herpderp/Projects/TestProject/TestProject" "-lMyLib" "-force_load" "-ObjC"
This directory contains a full sample showing various ways of integrating Objective-C libraries with MonoTouch:
https://github.com/xamarin/monotouch-samples/tree/master/BindingSample
The error message for MT5201 tells you there was an error while doing the native link step. That's 100% sure. The second part ask to to review your gcc_flags, which is the most common reason, for the failure. However it's not 100% sure this is the issue. When you seek help you should always paste the lines above any error (as they might be useful).
The error is likely about the duplication of the options given to the native linker. This occurs because you did supplied them twice (i.e. in your binding project and in your main project).
From the Binding Objective-C Types article you linked:
Or you can take advantage of the assembly-level LinkWithAttribute, that you can embed in your contract files...
It means the additional mtouch arguments are not needed with you use LinkWith attribute. Since you're using this way (the best one :-) to bind your static library you can skip this step (from your main project).
By doing so you do yourself (and anyone using your library) a favor since they are less risky to get out-of-sync (e.g. library update or different build configuration).

Resources