Combine two Xcode workspaces into one - xcode

I have two projects. Project A and Project B.
Project A is in Objective C, while the other is in Swift 3.0.
Project A is already stable, however a new functionality will be added.
Project A is already in a workspace.
Here's where Project B comes into place.
In Project B, I'm developing a library that will be used by Project A.
Project B is using external libraries such as Alamofire.
I want Project A to use Project B. What I've tried is to combine these two into Project A's workspace. I placed Project B inside Project A's workspace.
However, Project B's external libraries were not included in the transfer.
I'm using Cocoapods in both projects.
Or do I have to re-add the external libraries?

I just managed to get a simpler version of your problem working. I had one existing Cocoapods workspace, that built a framework, that I wanted to combine with another project. I created a new workspace, and then added three projects to it, and then embedded the framework and its dependencies. Let me describe in more detail.
The three projects were as follows:
My framework (MyFramework)
My framework's dependencies, managed by Cocoa pods (Pods)
My New App (MyApp)
The first two, MyFramework and Pods, were from the existing workspace. Got that?
When I created a new workspace, there were basically two steps. First I had to add the above three projects. Then, in the General tab of the MyApp project (in my new workspace), I had to add MyFramework to the "Embed Frameworks" section. That got everything wired up.
As it turned out, in my particular case, I got a crash at runtime which complained about a missing bundle. That bundle was actually a product of the Pods project. I found that bundle on my filesystem and then dragged it into my workspace (which added it to the "Copy Bundle Resources" section of my General tab for MyApp). That got everything working.
In short, I didn't combine two workspaces. Instead, I dismantled the first workspace (in a manner of speaking) and added its parts to a new workspace, which included my new app.
I hope the above gives you a hint as to how to proceed. Good luck!

Related

Cocoapods generating separate additional workspace project file?

Somewhat of an intrigue to me is how Xcode creates a new workspace project file after you make your project 'cocoapods aware' to install a pod to your current project. So the older project file has blue icon, the new one has the same name but with .workspace appended and has white icon.
I am wondering why the need to have this separate file and also if the older one without the pod is still needed by this new file?
A workspace is an Xcode document that groups projects and other
documents so you can work on them together. A workspace can contain
any number of Xcode projects, plus any other files you want to
include. In addition to organizing all the files in each Xcode
project, a workspace provides implicit and explicit relationships
among the included projects and their targets.
Since Cocoapods is a library manager and install/integrate all the libraries you want in your project. After installing pods, you have noticed that it creates a workspace that contain your project + Pods Project (this one contain all the libraries that you have installed.) as your project has dependencies on those libraries and this is how CocoaPods works. You can open your project with older name '.xcodeproject' but you won't be able to access the libraries as it does not contain pod.

How to keep Xcode class in sync with other projects

I have a single class with all handy code snippets I use all the time in every projects. What I would like to do is keep that single class in sync with other projects in Xcode.
Example:
I have two projects both with the "general class". I open Project A and add some code to the "general class". Then when I open project B it will be there too.
Is this possible in anyway? Can this be done with Git?
I had the same issue, I used the solution below to solve it
Copied all classes to be shared in a folder out of any project.
Added that folder into different projects (using git) by right-clicking in the project navigator and choosing "Add Files to " without creating a local copy.
For example I have the following folders:
DataAccessLayer- contains C++ class to acces to the DB
BusinessLayer- All C++ core business classes of my applications
iOS- All iOS interface classes and a wrapper for C++ classes
XOS- All iOS interface classes and a wrapper for C++ classes
In the last 2 folders are projects which use same clases. When I edit a file from a project the change is reflected in the other projects
I hope this will help you
You can use cocoapods for that. Create podspec, then add it into Podfile of all projects as local dependency by "pod MyLib, :path => '~/path/to' ". See more https://guides.cocoapods.org/syntax/podspec.html#specification
Git submodules are another clean way of doing this. The submodule will be seen as a directory in multiple projects, and you can push changes to it as it is also a git repository. See https://chrisjean.com/git-submodules-adding-using-removing-and-updating/ CocoaPods are another good option, but require you learning about how to make CocoaPods.

How to make main project to use libs built from other projects in solution

Actually, question was set in the Theme of the message. But yet again,
i have Solution with 3 projects, two of whitch are Static libraries and one is Application. How my Application project could know from where to pull these .libs.
Yeh, i can do it from Linker->Input->Additional libraries, but i think there are must be other way if projects are in one solution.
There is another way, works on VS2010 and up. Right-click your EXE project, Properties, Common Properties, Framework and References. Click the Add New Reference button and select your project that generates the .lib. Repeat as necessary.
This does two things, it takes care of the Additional Dependencies linker setting, automatically adding the output of the library project. And it ensures that projects are built in the right order, normally something you'd have to with the Project Dependencies command. In your given example, with enough machine horsepower, the library projects will build concurrently. And the main project won't start building until they are both done.

xcode target dependencies between two projects

I have a problem with setting dependencies in XCode 4 between separate projects. Currently, I have two projects in the same workspace. The first project have a Framework amongst it's products. I would like to use this framework in the second project, as a dependency for Bundle target.
First project build successfully. However, the second one claims that it cannot access headers from the framework, although it exists in there. I added the framework to Build Phases -> Link Binary With Libraries section of my target, but this does not help. I was looking for an answer, but all I found were suggestions to add library on the Summary page. Unfortunately, in opposite to Application targets, Bundle target does not have this pane. Is there any other place where should I add the framework?
This answer describes the current procedure for adding a library dependency, including headers: https://stackoverflow.com/a/9726445/382938

Target Dependency between two projects in the same workspace

I'm using Xcode 4.3 to create a framework for OS X. I created a workspace and a project (with a framework target) to go in this workspace.
Now, I want to include & link with a third-party framework which I've also added to the same workspace (but not within my project). I clicked the + button in the "Link Binary With Libraries" build phase, and the third-party framework simply appeared in the list of available libraries.
The linked framework shows up red in the Project navigator, as the third-party library has not been built yet (confusingly, though, my project successfully builds — although I'm not yet trying to use the third-party framework):
I was going to solve this by adding it as a Target Dependency, but when I click + on the "Target Dependencies" build phase, the third-party target doesn't show up in the list.
How should I properly configure/resolve this dependency? Also, do I need to create a Copy Files build phase to ensure the framework is copied into my target's Frameworks directory? How would I set that up properly?
I ran into something similar but with static libs.
Do what you did to build the framework, build your app (even if it fails, the framework should build)
Remove the reference to the framework in your app target's link build phase
Locate the built framework in the Finder (the one built by your app workspace).
drag/drop it into the app project that uses it. Notice that this time it appears with black color (not red)
click it, and make sure the Xcode inspector shows "relative to built products" (you may need to change it reference type), and that the path is just the myframework.framework.
check that it has been added to the app link phase (it should)
that's the one you can use in the copy/build phase.

Resources