Populating the configuration to the nested library project - objective-c

I have a main project, which includes a nested library project which produces a libCore.a library.
Both of the projects have the two configurations debug and release. Now if I build the main project with a given configuration, how can I make sure that this is passed down to the library project as well?

Make your project directly dependent on the libCore project. Do achieve this, do the following:
Drag the libCore project file to your main project. It happens sometimes, that only the xcodeproj file is moved. If this happens to you, restart XCode (this happend to me with RestKit and the latest XCode).
After point 1 is done and you can browse the dependency project, go to your target build phases and add the libCore as the target dependencies.
Link against libCore.a by adding in the Link Binary with Libraries phase.
These are 3 basic steps, I don't know what the libCore is, if it needs to be linked with any other libraries then you will also have to link your target against those libraries.

Related

How to resolve Swift Package Manager target overlapping sources error

I have a GitHub repo that is an Objective-C project that defines multiple targets (one per each targeted OS: macOS, iOS, tvOS, etc.). These targets share most of the source code files of the project.
I am trying to add SPM support to the project and in the Package.swift file I define matching targets with source path referring to the same folder containing those source code files shared across the targets.
When I add this SPM-"enabled" project/package to a test project that is trying to use it as a dependency via SPM, I get an error saying that the second target in the dependency package having overlapping sources with another target (the first one that uses the same shared source code files).
Any ideas about how to fix the problem? I would assume my multi-target configuration over the shared source code files is not that uniqueue...
I finally figured out what was the problem and what should be a solution to it.
My mistake was to think of SPM targets the same way Xcode thinks of them. In reality, SPM targets are essentially named folder containing source code files that need to be built to produce a product or products. They do not assume a definition of a recipe regarding how to build (the way Xcode targets do). However, a codebase that depends on a given SPM package does apply its Xcode targets to build itself and the dependency (prior to building its own codebase). The SPM targets are completely agnostic to the targeted device.
Hence, when I tried to map all my Xcode targets as similar SPM targets (at the same time referring to the same source code files from multiple SPM targets) it was wrong from the SPM point of view.
The correct solution anded up to be a definition of a single SPM target over a single codebase location (path) and everything went well from there.
Here is a good video that explains the SPM concepts well and that subsequently led me towards the working solution:
Creating Swift Packages

How to load cmake script with more than one project with Qt Creator

I have a CMake project, and until now, I was using Visual C++ for developing.
Using CMake-gui to generate a solution for VC++, it generates more than one project in the same solution.
But when the script is loaded in qt-creator, only one project is defined, with all the code and folder tree inside, so I can not compile it (or I don't know how to do it).
How can I load the cmake file to load all the projects?
More info:
The first CMakeList.txt has some common configuration. Then, with 'add_subdirectory' function, I add a project to make a library, and another project to make a sample application to use this library.
You should add multiple projects to the root cmake file with help of "add_subdirectory()". Then in Qt Creator you should open the root cmake file. After that you could choose which project to run in the select a kit for running (3) or debugging (4) application pane (check the link).
It sad that you can't (or I don't know how) build only one project. You have to build all projects are added to the root cmake file and then choose which one of them you want to run.
I use Qt Creator 4.0 .
Here is the offical doc http://qt-project.org/doc/qtcreator-2.8/creator-project-cmake.html
My project have a similar structure, just open the top-most CMakeLists.txt file of the project, and qtcreator will import your project.

Compile xcode project into a library file

I have two projects that are build on 2 different compilers. I need to combine both into one single app. Found out from a source that it is possible to compile any one of the project into a library and add it into the other to use it.
I fairly new this concept. Has any one done anything like this? How do i convert one of the project into a library and how would i connect the two? Will i still able to call the views in that project(library) in my other project? I am using XCODE 4.2 and iOS 5.
Create a "Cocoa Touch Static Library" to build your "Project"/target, and include the then-built library (with its public headers) into the second one. Note that the details depend quite a bit on what you mean by "project" and by "call the views" (which looks a bit wrong).
If you have two existing projects (with .xcodeproj files), open the "app" project (guessing one is of such kind), and include the lib project inside it (by drag & drop, or by "Add Files..."). Not the opposite.
Then in the "Build Phases" of the app project, you can add your "lib" project as a target dependencies (making your lib to always build when building your app). Finally, add the lib project product (the .a) in the "Link" build phases of the "app" project.

Adding dependent project in XCode 4

I am trying to add a dependent project in XCode 4. The link to the project is this: https://github.com/jverkoey/ObjQREncoder
The author described a way to add this but it's for XCode 3. I am trying to add it to XCode 4.
I dragged the project inmy frameworks, then went to Targets and QREncoder in Target Dependencies. Then I added libQREncoder.a in "Link Binary with Libraries". Then I added this for header search path "src/Classes".
When I include "QREncoder/QREncoder.h", it gives me this error: file://somePath/FINALQRAppDelegate.m: error: Lexical or Preprocessor Issue: 'QREncoder/QREncoder.h' file not found
This is how my project is set up:
FINALQR is my project to which I am trying to add the dependency and the dependency project is in src.
Thanks.
The problem is it doesn't recognize the QREncoder class.
Only Xcode 4 workspaces benefit from shared build folders across multiple projects. From the main menu, select File > New > New Workspace... Save the workspace, then drag your subprojects into its Project navigator panel.
Be careful where you place them (make sure you're not making one project a subproject of another within the workspace) so that they're all top-level projects within your workspace. This will cause them to share the build folder and automatic dependency detection should work.
Unless, of course, you have custom search paths set in your targets' build settings. :-)
I think your problem is you need to set the following as your search path:
"$(SRCROOT)/src/Classes"
not
"src/Classes"
If you already have an Xcode4 project, you should be able to drag QREncoder into it as a subproject, as I think you have already done, and then add the .a file, also as you've done.

Xcode won't build IB plugin into resources folder

I've created a custom control and a framework/IB plugin for it using the IB3 plugin template.
According to the docs the plugin should be built right into the resources directory of the framework. When I build my project the plugin is in the configuration folder (Debug) along with the framework instead.
This is the same behavior right out of the box when I create a new template. I tried changing the CONFIGURATION_BUILD_DIR to be $(BUILD_DIR)/$(CONFIGURATION)/FrameworkName.framework/Resources/ but got no change.
For grins I also tried messing with the install path, but also got nowhere. I've checked out a couple other open source projects to check their build settings, but they're identical to my own and yet their plugin is built and put into the resources directory as expected.
Don't mess with build settings. Instead, add a "Copy Files" build phase to the framework target. In the inspector for the copy files build phase, set the directory to "Resources". Add the plugin to this build phase by dragging the plugin product from the "Products" group in the "Groups & Files" tree in Xcode.
To get the built product of one Xcode target to be included in the resources directory of another Xcode target's product, you should find the product in the groups and files tree and drag the product into the copy "bundle resources phase" of the other target. You should also add a target dependency between the two targets with the get info panel for the target.
If you're seeing the built plug-in in the build products directory that does not mean that it wasn't also copied into the framework's resources directory. Xcode builds all targets into the build directory, and then copies (not moves) them into their final destination - which in this case is the framework's resources directory. One reason for this is that a product can have multiple final destinations.
Thanks, Barry. When I tried using a copy files build phase, IB wasn't able to resolve the connection between the framework and the plugin. It couldn't find the associated plugin for some reason.
However, after endless fiddling, I found that I was closer than I thought. Changing the CONFIGURATION_BUILD_DIR to:
$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/FrameworkName.framework/Resources/
and updating the framework search paths solved the problem for me. This isn't the behavior of the plugin template (at least on my machine) out of the box, so hopefully this will help someone else.