Adding a framework in Xcode - xcode

Im trying to add a third party framework in Xcode but I'm getting an error that it can't be found
error: MKAbeFook/MKAbeFook.h: No Such File or Directory
I've added it in the Linked Frameworks group and added it to the Target for this project. I've also added it to a new Copy Files build phase for that target.
Basically I've followed the instructions here: http://pointlesscrap.net/mkabefook/desktop/gettingstarted
Any ideas where I'm going wrong?

Best way to diagnose this is to post the compiler invocation line, not just the error (you can just drag and drop the line from the Build Results window that says "Compiling foo.m"). My expectation is that you don't have a Frameworks Search Path set up for the location of the framework. Xcode usually adds that manually when you add the framework, but if you put it in certain kinds of places, or added it in certain ways, you need to manually point your target's Framework Search Paths at its directory.

Perhaps the author mistook MKFaceBook for MKAbeFook?
EDIT: Never mind, it looks like that is actully the name of the framework.

Related

failed to emit precompiled header

Good Afternoon
I am trying to implement googles heatmaps into my map based project.
In this particular project, I get the following errors when trying to build.
failed to emit precompiled header '/Users/zachwilcox/Library/Developer/Xcode/DerivedData/OddJobs-gbnkfettubuccoheinzfovrqefub/Build/Intermediates.noindex/PrecompiledHeaders/OddJobs-Bridging-Header-swift_3WGH9SNI96Z2-clang_16JN3VASQHE4C.pch' for bridging header '/Users/zachwilcox/Desktop/OddJobs/OddJobs-Bridging-Header.h'
and a follow up that says
'Google-Maps-iOS-Utils/GMUHeatmapTileLayer.h' file not found
I'm not sure why this is happening because I created an entirely new project and did the same implementation and it worked perfectly. But when I run it on my existing project I get these two errors.
I have been researching this problem for a while now and I can't figure out what the problem is. I have the Bridging header set to the .h file.
I have tried most steps that individuals have tried to give with their answers but for some reason, it's not working for my project. Thank you in advance. When reading googles installation guide, it said that all I needed to add was one bridging header file which is the code you see in the image below. When researching it, I have seen that I needed to add a .m file as well however I still get the same error when I do. again, in my dummy project, I don't have the .m file just everything you see below and everything compiles.
There are chances you have 'Find Implicit Dependencies" turned off for the selected Scheme. If you have updated/installed pods and try to build the project, it will more likely fail if this option is unchecked for the selected Scheme.
From Apple's Document:
Parallelize Build – This option allows Xcode to speed up total build time by building targets that do not depend on each other at the same time. This is a time-saver on projects with many smaller dependencies that can easily be run in parallel.
Find Implicit Dependencies – This is a very powerful option that allows Xcode to resolve what targets need to be built for the primary target of the scheme to be built successfully. However, this does come with some sharp edges that you have to be aware of.
Situation: You link a library against your application target and create an implicit dependency to that library’s target.
Scenario 1: “Find Implicit Dependencies” is enabled.
Result: The library will get built prior to building the application target. The application target will then link against the library and build successfully.
Scenario 2: “Find Implicit Dependencies” is disabled.
Result: The library will not get built prior to building the application target. The application target fail to build.
Fix: To ensure that the second scenario does not happen, you must add the necessary targets into the targets list and order them correctly.
If your project includes pod then you've to set the pod configuration for the test project too..
Select Root Project in File inspector -> Project Name -> Info -> Configurations
Set configuration for your test project same like your main project

Mac Ogre Xcode project can't find headers

While trying to get the template Xcode 4 ogre project to work, the build fails because it can't find OgreCamera.h.
I've installed Ogre to /opt/local/lib/OGRE, and specified that as the Ogre SDK location when creating the Xcode 4 project.
Needless to say, the header and framework include paths in the project settings point exactly to where all the header files are, yet not one of them can be found. I've tried commenting out the include of OgreCamera.h, and upon trying to run, the next include, OgreEntity.h, cannot be found. Commenting that out and running again, the next include can't be found, and so on (these includes are in OgreFramework.h.
I don't understand why these headers, which clearly exist when I go look for them in the Finder or Terminal, can't be found by the project, even when I specify their full path like this:
#include </opt/local/lib/OGRE/lib/release/Ogre.framework/Versions/1.7.4/Headers/OgreCamera.h>
Did I somehow install the Ogre SDK incorrectly? (I copied it from the DMG into place…)
I had the same problem, and found partial success by following rjstelling's answer from this thread:
why can't Xcode find this header file?
That solved the OgreCamera.h include issues, but now I'm stuck on including the boost libraries. They are not picked up on the search paths, or in the Indexing group as suggested in the thread above.
Basically it looks like a bug in XCode4 that has to be worked around until a patch is released. There is also more information here:
Compile, Build or Archive problems with Xcode 4 (and dependencies)

Adding OCHamcrest to an IOS Project

The documentation for the project says just add the framework and the linker flags and you are good to go. Hours and hours of wasted time later, I have figured out that that's not true. If you do that, the project does not see the header files. You have to put the framework somewhere were the compiler will find the headers. In my case, that worked when I dropped the framework into /Developer/Library/Frameworks and then told it to recurse in searching that framework directory (do not fiddle around with the headers search directories).
Then the problem I get is that the link fails with the message:
ld: framework not found OCHamcrestIOS
I noticed that the documentation for the project says that it was updated for Xcode 4. I pulled down the binary of the framework after checking out the code and wasting a ton of time unable to build the IOS version of the framework.
The documentation is here.
I also noticed in that documentation that the cocoa instructions tell you to put a copy files phase into the build. I tried that. Didn't change the outcome.
The last time I fell into a sink hole it was because the library was C++ code. Maybe that's still the problem.
Barring a rapid solution here, I am going to go back to using STAsserts, as sickening as that prospect is, this is far, far worse.
Update: reinstalled Xcode. Still doesn't work. There are cheap ways to make this work, like add the header files to the project. Did a blog post about this that brought out a person with the same experience.
I use a number of frameworks in my projects. Some from other people and some are mine. Looking at the documentation I would suggest that the copy phase stuff is not for iOS development. So I would not do that. I downloaded the latest zip from https://github.com/jonreid/OCHamcrest and it appears to contain a ready to go iOS static library. (Not on my mac so I cannot test to confirm).
Anyway, the way I include static libs is to
Select the project (XCode 4).
Select the target I want to add the library to.
Select the Build phases tab.
Expand Link binary with Libraries.
Click the [+] button to add a framework.
Click the [Add Other ...] button and navigate to the directory containing the <lib>.framework directory and select that.
Thats all. The targets search paths will be updated to include the framework directory and the framework will be listed on the left under the project. Expanding it will show the headers.
The problem you mention sound like a couple of things. Firstly the framework not found sounds like the framework has not been included in the target. When you select the framework in the project list on the left, you should be able to see it's Target Membership displayed on the right. Check it's on for the target you are compiling.
Secondly building frameworks is not a trivial task so don't attempt it unless you have the scripts to do it. I say this because building a iOS static framework means compiling for both simulator and devices, combining the compiled lib files into a universal one, and then storing it and the header in a specific directory strucuture.
The downloaded zip from OCHamcrest though, appears to have the correct OCHamcrestiOS.framework in it. So if you store that directory somewhere and link to it using the steps I've outlined above it should work just fine.
So the solution I adopted for now, after much thrashing around, was to include the framework in the project.
Create a group inside the Xcode project called Third Party.
Link it to a folder called thirdparty.
Go to the Add Files in Xcode and pick the framework.
Drag it over to the dependencies.
Run the tests, they pass!
This is maybe preferable anyway because referencing it in /System/Library/Frameworks would present some versioning issues, and this can be setup very quickly. Furthermore, we have a continuous integration server, and having to get in there and sync versions whenever something changes is not so great.
Thanks for checking it out, Derek.

Do I have to do something to get OCunit tests to compile out of box with XCode 4?

I just installed XCode 4 today (using Apple mac app store), and I created a new Mac OS application, and tried to switch to test mode,and build the test skeleton code it generated for me. It failed here:
In mytests.h:
#import <SenTestingKit/SenTestingKit.h>
The error is:
file://..mytests.h: error: Lexical or Preprocessor Issue: 'SenTestingKit/SenTestingKit.h' file not found
Now, when I use locate from the terminal to find SenTestingKit.h, I notice it exists under the /Developer-old/Library/Frameworks folder (which is what XCode 4 installer renamed my /Developer folder to). There is no new /Developer/Library/Frameworks. And I can't seem to find SenTestingKit.framework on my disk, other than the developer-old one.
What's up? It seems SenTestingKit.framework is not shipped with XCode 4.
Update:
Furthermore, When I copy my old SenTestingKit framework from XCode 3 into /Developer/Library/Frameworks, it sort of builds, but it doesn't work the way I would expect. The dummy test is designed to just fail, but when I "run test", I just get the normal cocoa app document window opening, and no indication that my test has failed (as I intend it to do).
This is pretty bad. I can't get a Unit test to FAIL. That's not the usual situation for me, you understand.
You may find that the reason for this is because you've installed Xcode 4 into a directory such as /Xcode 4.x/ or similar. The space is causing the problem because the -I paths are "Xcode" and "4.x/Library/Frameworks".
To fix this, what you need to do is select your test target, and under its build settings go and find the Framework Search Path, and put quotes around the two arguments, so you have:
"$(SDKROOT)/Developer/Library/Frameworks" and "$(DEVELOPER_LIBRARY_DIR)/Frameworks"
Then you default tests will compile, link and fail.
You will maybe need to import the framework into your project. Otherwise, the header file won't be recognize.
If you can't see the framework you're looking for, you can adjust the framework look paths in your project's build settings.
When you're building unit tests in the same project as you main code, make sure that XCode 4 didn't automatically connect you mytests.m file into the "Compile Sources" section of your main code.
For example, if you have two targets in our project:
MyProject
MyProjectTests
Check the Build Phases for MyProject to see if XCode added mytests.m into the "Compile Sources" accordion. This will cause your builds to fail because SenTest isn't included in the main project.

How do I change an existing Xcode target from dynamic to static?

I'm working with an existing project that produces a dynamic library (Cocoa API).
I'd rather generate a static library, but if I change the
[Linking|Mach-O Type] field from "Dynamic Library" to "Static Library",
both the Clean Project and Build Project complain that the
target has an invalid MACH_O_TYPE value of 'staticlib'.
Is there a straightforward way to get the build to produce
a static .a file?
Thanks,
Eric
Opens up the project.pbxproj file in YourProjectName.xcodeproj folder using TextEdit, search for productType and change it's value from "com.apple.product-dynamic" to "com.apple.product-static"
I ended up creating a new 'static library' project, and then added all
the members. Closing xcode and bringing up the two project files in
a text editor let me quickly complete the new project.
I managed to do this, with the help of this post and a bit of digging around. Additional changes I had to make were changing compiled.mach-o.dylib to archive.ar and changing various references in the project file (including inside comments, call me pedantic) from foo.dylib to libfoo.a.
I also had to create a new 'scheme' before it would build, but that might be because I changed the name of the project, I'm not sure. Also, any frameworks referenced by the library need to be added to the application(s) that link against it when you move from .dylib to .a.
It was well worth persevering though as it preserved all the subtleties of the original project (such as building a 32/64 fat binary for release but not for debugging). Result.
Delete your build target, then create a new one, choose "Library" and make sure you choose type "Static". After this, you only have to add your sources and dependencies again.
You have to change two settings:
Under Library, set Mach-O Type to Static Library
Under Packaging, set Executable Extension to a
This worked for me on Xcode 13.1.

Resources