My project architecture is, a workspace which has two projects(Project A & Project B). Project A has three more sub projects(Project X , Project Y, Project Z).
Workspace
Project A
Project x
Project y
Project z
Project B
Project B is more a kind of utility project. It needs to be re used in Project A, Project x,Project y, Project z and elsewhere it could be. I am starting to do a prototype. But face challenges in linking Project B in other projects. Every time i need to add the .a file manually into all other projects. Do we have any solution to dynamically link?
I tried this approach as well. I moved project B inside Project A below Project z. But i was not able to access the classes in Project x, y, z because all the projects are in the same level.
Any solution to dynamically link projects in the same level?
You need to add Project B as Target Dependency from Build Phases to other projects, that way Project B is built and added to other projects just as you'd like.
Related
I have two Objective C dynamic frameworks X and Y and another Objective C app Z.
All these frameworks and apps have been created by me locally. Framework X is the very base framework used by framework Y and the app Z. So the dependency graph is something like the following:
Y ---> X
Z ---> X
Z ---> Y (---> X)
I want all my targets to be debuggable and to pick the platform tools based on run destination (device/simulator). So I have added dependencies as sub-projects to the main projects and have linked them with the dependent projects to generate implicit dependencies by Xcode.
The set up 1 and 2 works great independently. But I am struggling with the set up 3 which is creating duplicate build rules for the target X due to transitive dependency on it (target Y and Z both depends on it) and subsequently failing the build process.
Anyone has any idea on how to deal with this situation? Thanks in advance!
It seem that in Objective-C, We can't link a dynamic framework to another dynamic framework, or to a command line tool. It's always raise an exception, when running in production
Dyld Error Message:
Library not loaded: #rpath/XFrameworks.framework/Versions/A/XFrameworks
For your situation, What I think might solve your problem
X (Core features) can be built in static library
Y can be built in type of dynamic framework
will link with X library
or link with others (I mean some another code base)
Z (your application) will link with Y framework
Actually there is a way through which I could finally solve the issue of transitive dependency in Xcode. I have to use Workspace (.xcworkspace) rather than a Xcode project (.xcodeproj).
To get it done use the following steps:
Close all related and open Xcode projects.
Create a new Workspace in the root directory from File > New >
Workspace. Open the workspace by double clicking onto it and
drag/drop the required projects to the workspace.
Add the independent framework (X in my question) output to both of
the dependent project targets (Y and Z) by adding it under the
Framework and Libraries section. Embed the dynamic library only to
the top level application (Z) and do not embed it to the
intermediate dependent target library (Y).
Add the intermediate framework (Y) to the root level app under
Framework and Libraries section and embed it to the root app bundle.
This setup works like a charm for me without ever creating duplicate build rules and it spontaneously picked up the dependency as well.
Obviously, you can not do this if your independent framework is a static library and in that case it will be linked to both the dependent targets causing duplicate symbols issue during linking.
I have a workspace that contains multiple projects - Project A and Project B. In this case, Project B is a dependency of Project A. When Project A is built, project B is then added as a dynamic framework to Project A.
- Project A
- Framework 1
- Project B
- Framework 1
Both Project A and Project B rely on a framework (Framework 1). I add this framework to both projects by going Build Settings -> Framework Search Paths -> Add path to Framework 1. When I compile the project, I get Xcode warnings saying:
Class XXX is implemented in both PATH 1 and PATH 2. One of the two will be used. Which one is undefined.
What I really want to do is to tell Xcode to link the Framework with both sub projects but to understand that this is one common library that doesn't need to be duplicated. I have two questions:
Is this possible?
If it's not possible, will this warning cause any problems? For example, is it that Xcode will just use the source code from either Framework location or is it that Xcode could run parallel instances of the framework code which could cause issues with singletons being duplicated.
There are already several SO questions that address this issue, but I haven't found one that completes addresses my situation.
I have projects X, Y, and Z, that all share a common framework C. The projects and the framework all use Cocoapods. I would ideally have three separate Xcode projects that all include the common framework C. So I would have, X+C, Y+C, and Z+C. Then, when I push X+C, I want it to push the changes of X to repository X, and the changes of C to repository C. I would also like to be able to pull changes from C into X, Y, or Z. I would like to work on framework from within project X, Y, or Z, and debug the framework from each of the projects X, Y, or Z.
Is this currently possible? I know there is the concept of submodules, but it doesn't sound very robust (likely to fail with branches).
Yes it's possible with pods. You can create private framework C.
If you define path for your C framework in podfile for your projects then the framework will be generated as development pods and you can debug and edit it.
Example part of podfile
'C', :path => './C/Source')
You can use relative path. Also you can define framework in this same git repository or add submodule for your git repository project
I had a project setup properly in XCode 4, but now it seems to be a gamble in XCode 5. I have library projects that need to be built before the main one. Basically:
Main Project depends on Lib A
Lib A depends on Lib B and C
For some reason, Lib A is sometimes not being built before the Main Project causing a linking error. This doesn't happen all the time so its like a race condition. Is there some new way of specifying a strict order in XCode 5?
Addendum:
So previously my structure was:
Main Project
+
|- Lib A
+
|-Lib B
|-Lib C
And this didn't seem to work (all the time anyway).
Then I tried
Lib A
+
|- Main Project
+-Lib B
+-Lib C
The structure is how the project are in my workspace. Does that make a difference?
In the Xcode 5, click on the project file and Choose a target. Now under "Build Phases" there is a "Target Dependencies" setting. You will need to create a target for compiling Lib A beforehand if the main project depends on Lib A.
I'm currently writing a unit test project using the version 4.6.1 (Windows Vista + Eclipse). My project is divided in 3 part:
A. Unit test application (type:CLDC application)
B. Application to be tested (type:CLDC application)
C. A library project (type: library,no .jar file imported)
The A project should reference the code present in B (and of course even in C). I would like to specify that I can run without problems the project B (referencing C). My problems start when I try to run the project A.
I performed the following operations:
changing the B project type from CLDC application to library
B references the project C
A references the project B
set all project as "Active for Blackberry"
Basically A sees the two other project as two nested libraries.
The code is built successfully,but the problem is that when a class of the C library is called by B during the execution, the following exception is thrown:
NoClassDefFoundError
No detail message
Any help would be really appreciated.
Many Thanks
A NoClassDefFoundError means that A cannot find C at runtime. The usual cause is that C failed to be deployed onto the target device (simulator or real device).
Solution 1:
For project A under Project->Properties->Java Build Path ensure C (your library project) is listed under 'Projects' and the corresponding checkbox checked on the 'Order and export' tab. This should ensure that the library is exported during the build and deployment process.
Solution 2:
In project A add a symbolic link (right click project->Build Path->Link Source) to the library C source. This will force the library's source code to be included when project A is built.