How to share files between two xcode projects in workspace? - ios

I learnt about Xcode workspace .I know how to share the static library but i want to share the files between two xcode projects in workspace and is it possible to run multiple targets at a time?Can you provide me the information of how to do this.
Thanks in advance

Sharing files between projects in the same workspace is easy, even if the projects are on the same level (no subprojects):
Assume you want to share constants between Project1 and Project2, and these constants are defined in a file SharedConstants.swift, which is defined in Project1.
In order to be used in Project2, it must be compiled there.
Thus, activate in the project navigator Project2, select the target and open the Build Phases tab.
Open there Compile Sources by tapping the little triangle left.
Tap the + button below the listed sources for this target. This will show you a list of files of Project2. There you cannot select your shared constants, because they do not belong to this project.
However left bottom is a button Add other…
Tapping it will open a standard file selection window where you can select SharedConstants.swift from Project1.
After tapping Open, a 2nd window opens with a Destination: Copy items if needed checkbox.
Important: Do not check this box!
If you would check it, a copy of SharedConstants.swift would be used in Project2, and any changes that you make in Project1 would not be visible in Project2. Instead, it you uncheck it, only a reference to SharedConstants.swift in Project1 would be used in Project2, and any changes will affect both projects.

To share the files you can probably use the bundles
Targets are manipulated with Schemes in Xcode 4, you can launch several targets in the same time if you select the different destinations (with OS X you can probably have the same destination :) )
You'll see a little triangle below the stop button indicating that you can long-press it to select which operation should be terminated:
You can switch the console with the popover at the Debug area where you see the target name and icon - that's a button.

You can drag Xcode projects into other Xcode projects to nest them.
More info here:
How should I manage dependencies across projects in an Xcode workspace?

Related

Using a single xcode file for multiple projects

I haven’t tried this before but wanted to know how it happens. Suppose I have an Xcode file for my project called ‘Project A’. Now I want to make another project with the same features as that of ‘Project A’ for a project called ‘project B’. But for ‘project B’, I don’t want to make a different Xcode file but rather want to incorporate the changes in ‘project A’ itself so that when I run the same project, I’ll be able to run project A or project B as per my need. How can I achieve this…?
Click on your project, Goto General > Targets.
Right click on your project Target and select Duplicate.
You will get to choose between iPad and continue to duplicate for iPhone.
Going ahead in each new/existing file, you can choose which target it belongs to and keep doing your development. If you exclude the file from an target, it will not contribute to that app's size.
You can also keep your future files in both Targets depending on your needs.

What is causing Base Localization to create duplicate storyboard files?

I have an iPhone app that needs to be physically cleaned to prevent the following build error:
This is what I have in the Navigator:
And this is what I have in the Localization section of Build Settings:
It works, but I'm not sure this ever worked the way it was supposed to; it was written several (like 4) years ago. Now, I am trying to clean it up so I can convert it to a universal app (first I need to make sure it works as designed before making any drastic changes.)
Can someone please point me in the right direction for cleaning this up? (I.e. what files to delete, or ?)
Here is what probably happen in that project:
This xx.lproj file is a legacy. You should be able to find it in Finder but not in a Project Navigator. Like this:
This is only the internal structure of xcode so just remove references from project navigator for all this ``xx.lproj` groups without removing files from project and you'll be fine.
If the app stop building you may need to re-add this files to your target, to do this just select a "parent" storyboard and go to "File Inspector" (first tab on Utilities panel) and select desired target.

How to manage multiple projects in single project copy in iOS?

We have projects which are same for all the cities now I want to make those project in one project, so I can do a change in single project and effected in each.
You need to create one different target for every city, on the same project.
They will have the same core code and then, you can configure different ressources for all of them. (icons, images, fonts ...)
Each of them can use a different plist file in order to have some flags and not others.
To create a new target :
* Go to your project panel (with tabs General - Capabilities - Resources tag ...)
* Open the left panel
* There is a + at the bottom to create your new target (or you can copy an existing one)
You can switch from a target to another on the top bar at the right of the selected device to debug
When you have a file, you can decide on which target he can go on the right panel on the section "Target Membership"
Need screenshots ?
Very nice explained with pictures is here.
You can achieve it by using targets in Xcode.
As well here is explained about targets.

Creating custom framework in iOS

I am trying to create my own iOS framework for my project. I am following the below link to create it:-
Creating custom framework in iOS
I am not getting any error as well as warning but not able to see the content of Product folder generated during project creation.
I am facing problem in this step:-
To build, select the target as iOS Device and press cmd+B to perform the build. Once completed, the libRWUIControls.a product in the Products group of the Project Navigator will turn from red to black, signaling that it now exists. Right click on libRWUIControls.a and select Show in Finder.
Looking for all yours help and support on this.
Suppose you are using Xcode 6, and Apple has provided an easier way to create a custom framework.
You can refer to some instruction on How to create an iOS Cocoa Touch Framework using Xcode
And you may still encounter some problems while using your custom framework in your app.
Here are 3 tips to solve the problems you may face.
Add your public headers:
In your custom framework project, please select TARGETS->Build Phases->Headers->Public, and drag and drop your headers here.
Build a static library framework:
In your custom framework project, please select TARGETS->Build Settings->Linking->Mach-O Type, and select it as Static Library.
To fix Xcode “Missing Submodule” warning while import your custom framework in your app:
Please refer the solution here.
Enjoy your own framework.
There are several parts to this "step"
Assuming since frameworks are fairly advanced that building is not your issue.
This tutorial uses multiple targets. To choose which target you want to build you must select it from the drop down menu at the top left of your Xcode window. This is immediately to the left (and loosely tied to) the drop down for choosing the device/emulator type. The target selected in the drop down becomes the active target and will respond to the build menu and shortcut keys.
Once a target is built the object created by the build will be displayed in the XCode Project Navigator inside the folder named "Products" In the default view the left most panel in XCode is the Navigator panel. Selecting the folder icon at the top of this panel will display the Project Navigator and the projects file structure. This is where you will find the Products folder containing your newly created file.
If the file is still red then the build did not complete correctly.
If it is black then you can right click on the file and choose "Show in Finder" to see the file.
If the file remains red or as an alternative to finding the file location you can use the build log.
To show the build log - in the Navigation Panel select the "Report Navigator". This is the right most icon at the top of the panel and looks like a cartoon text bubble. In the Report Navigator highlight the "Build" Entry associated with your static library. You can now review the build log to determine why the target didn't build correctly or if it did build correctly you will see an entry near the end of the log showing the path of build files.

Add project dependencies in Xcode

I am working with the AR Drone to develop new application.
I want to establish a dependency between two projects. So when I compile one, I hope Xcode will help compile the another one automatically. I had searched with Google for this question. The solutions found are quite old and not applicable for Xcode 4.
Right now, I have two project, namely, ARDroneEngine.xcodeproj and FreeFlight.xcodeproj.
ARDroneEngine is a library for FreeFlight. Here comes the screenshot.
If I compile FreeFlight with iPhone / iPad simulator, it is fine since the ARDroneEngine is last compiled with the same setting. This is where the question lies. To test my application, I want to compile and run FreeFlight in my iPhone. So when I change the setting to "FreeFlight > xxx's iPhone" and compile, the error occurs: "Apple Mach-O Linker Error".
I think the problem is rooted from the Target Dependencies between two projects.
A quick workaround will be: Compile the ARDroneEngine again with the new Scheme "ARDroneEngine > xxx's iPhone" and launch FreeFlight in Xcode for my iPhone.
But I want a more complete solution with the dependencies between projects. If more information is required to solve the problem, I can always provide new info.
Thanks,
Steven
Xcode's solution to cases like this is to use a Workspace that encompasses both projects: then, when one project has a target that references the build product of another, it automagically works out the dependencies and builds them in order.
Create a new Workspace (File > New > Workspace); name it and save it anywhere you like (though putting it in a parent folder to both project directories might be a good idea).
Add both projects (drag the xcodeproj files from the Finder into the navigator pane, or use File > Add Files).
Expand the Products group of your library project so you can see the (placeholder for the) built library (libARDroneEngine.a).
Select the app project (FreeFlight) in the navigator and its app target in the editor -- you should be looking at the Summary pane for the target (the one with bundle identifier, deployment info, entitlements, and most importantly, the "Linked Frameworks & Libraries" list).
Drag the library (libARDroneEngine.a) from the navigator (where you made it visible in step 3) into the Linked Frameworks & Libraries list.
That's it! Now you can choose the FreeFlight > xxx scheme and it'll automatically build the library project before building the app.
You can probably get a more complete summary of these instructions (with screenshots and all) in the Xcode help for Workspaces.

Resources