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.
Related
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!
In a large monorepo of Cocoapod projects I have the following directory structure.
Project
Common
Foo.Framework
First Project
Project.Xcode
Second Project
Project.Xcode
The goal is that there are multiple Cocoapod projects and rather than have the same framework copied in multiple places within the First and Second project, I'd rather have it once in a Common folder in the parent directory, and then drag it into the project and set the framework search paths.
So I'm running into an issue where the linker cannot find the Foo.framework.
What should I set the framework search path to so that it correctly finds the framework.
If I include the framework inside the Project directories it doesn't run into any issues.
I had the same issue and solved it like following:
Go to Build Settings
Find the "Framework Search Paths"
Add $(PROJECT_DIR)/../your_directory
Use the recursive flag if the framework file isn't in the exact directory you selected)
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.
If you have a xcode project like restkit that has the core code for restkit + examples that have their own project, how do you run a specific project?
https://github.com/RestKit/RestKit/
If you look at the /Example's folder, you will see they have a few of them and each have their own project file.
You can use multiple targate in xcode.
A target specifies a product to build and contains the instructions
for building the product from a set of files in a project or
workspace. A target defines a single product; it organizes the inputs
into the build system—the source files and instructions for processing
those source files—required to build that product. Projects can
contain one or more targets, each of which produces one product.
Hy everybody,
I have two targets in one Project in Xcode. One is a foundation tool which I need in the resources Bin of the other Target, which is a Bundle App.
I am not able to add the Target one into the Copy Bundle Resources Build Phase of the Bundle App.
Do I need to use a Copy Files Build phase and put the File out of the build/Release Folder into it?
Thank you,
Michael
There should be a "Products" folder in your project, containing everything that would be built by your targets. You need to add the product reference for your tool (which will be in that folder) to the copy phase, not the target itself.