Xcode add multiple frameworks to multiple targets and projects - xcode

I have dozens of projects that I need to update, and they have two seperate Targets each. I need to add 9 new Frameworks to each of the Targets in each project.
I know I can use CMD+CLICK to select all 9 frameworks at one time and add them to each Target. However is there any way I can add them to both targets at once?
What about adding all these frameworks to multiple projects at once?
Thanks

I found a solution to this (or kinda of a quicker way than the original way).
First add the framework(s) to the first target.
Go to the Navigator area(left pane of xcode), and select the frameworks folder to see the list of Frameworks.
Click through each framework, and note that on the right pane of Xcode, in File Inspector, it is applied only to the first target, but you see that the other targets are unchecked.
-Check all the additonal targets you want to have the frame work and its now added to that target.
-Repeat steps for all the frameworks you want shared across multiple targets.

No, there does not appear to be anyway to add frameworks to multiple targets or projects at the same time.

Related

Merging two Xcode projects... Workspaces / Schemes?

I have two projects. One is written in Swift 3, while the other is written in Objective C. Both compile and run fine.
I have tried to add the Objective C project into Swift by adding files to the project. The project won't build because it can't import the bridging header. I have spent two days on this and am certain that I am correctly specifying the location of the bridging header and header files under build settings. I'm now looking for an alternative approach to merging these projects.
From Apple: 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.
Does this mean if I add the two projects to a Workspace that I can build the two targets into one target resulting in one product? I read something about using schemes, but the post wasn't detailed. I'm running Xcode 8 and Swift 3.
Thanks.
Workspace is used to maintain multiple projects in single space.It wont merge two projects and create a single target/product.
Simple way to add bridging header, create a new ObjectiveC/Swift file in the project will prompt "Would you like to configure an Objective-C bridging header?" dialog by xcode, will automatically create the "yourprojectname-Swift.h" file for you.

How make a automatic include class for multi target (versions) in Xcode?

I'm developing a project, an application, which will have several versions. I will reuse your source code and change only some superficial characteristics.
To help in versioning App, I adopted the solution of using multiple Target's to create different versions of the app, reusing the source code
But I have a question of how should I set up Xcode.
I performed the following operation:
I created a Target Template, possessing all the functionality I need, so whenever I need a new version I duplicate the Target Template.
But when I need to insert a new class, it is not automatically inserted into the target's already created, so I have to tell Xcode to be included the new class in the other target's hand when creating the class.
I would like to know how to set up Xcode so that every time I add a new class in the Target Template, this class is automatically included in other targets.
If someone possessed some guidance on how I can create multiple versions of the same app than with the use of multi targets.
I'm open for suggestions or other solutions!
Thx!
Note. I'm using Xcode 6 and Swift.
I would suggest setting up to have a library, (static or shared), target for the common, back end, code, possibly with a test harness in the same "project" and then using the same common back end in all your GUI targets. You could even have a GUI components library in a similar manner.
Your workflow would then be to develop and test your new back end code and classes then, when you are happy with it, simply rebuild your GUI targets. If things like menu items are derived from the back end codes published interfaces you would not even have to add the new functionality to them all, it would happen automatically on a rebuild.
Also look at using makefiles for building your code, then you can have a build all at the level above to rebuild all your GUIs.
I am not sure about XCode but a lot of IDEs now support having a super-project, called different things in different tools, that consists of multiple projects so that you can simply load your super project and build all in that.

What are "targets" in Xcode?

I have seen a lot of things about 'targets' while working with xcode. when i click on the project icon (blue, in xcode 4.2) i see 'Targets' in the middle pane with my file name under it.
What does that mean? and can I add more 'targets' to my project? If yes, what would that mean?
I have this:
http://developer.apple.com/library/ios/#featuredarticles/XcodeConcepts/Concept-Targets.html
but i didn't understand a thing
A target basically defines what it is you are building and how you are building it. You can add more targets if you would like to build more than one thing. This usually makes sense if you need to build several related things from the same project.
For instance, you might want one target for a full, paid version of an application, and another target for a reduced, free version of an application. Both targets would include much of the same code and resources, but some of the settings would be different and you might have different files included with each.
Targets are simply different ways of building a product. You have your source files, and you have your output, and there are several ways that you can get from A to B.
An Xcode project may contain a number of source files which can be built do produce a number of different products.
For example, you could build an executable using some of the files, or you could build a library (Framework) from some of the files, or a unit test library, or with different build flags.
Most projects will have a single target, but some are more complex than others.

How to include a bundle in main project xcode 4.1

[UPDATE 03/04/2015]
The question is now 4 years old, and applies to a specific version of XCode which I have now specified in the subject.
I have searched a lot for this argument, but I couldn't find a solution, I even post on stackoverflow, but I soon deleted the question becuase of very little access.
Now I am trying again.
I have a workspace with two distinct projects A and B.
B has two targets, one that build a static library Blib.a, and one that build a bundle B.bundle. All of them get built in the derived directory.
In project A I can easily add the static library from the build phases. However I cannot find a way to include the bundle. B.bundle is not visible from "copy resource" tab in A.
Therefore I need to add manually, with all that implies.
I also thought about using a script, but I would like to use this as a very last option.
Has someone a solution for this ? Did I miss something ?
thanks
After long investigation, it came up there's no easy way of doing this. The B.bundle is never visible to A project, and there's no settings in workspace to change that.
At this point there are three solutions:
Include the bundle manually from "copy resources->other", I started with this, but everytime there's a change you have to drop and include the bundle again
Create a script to be run in build phase, if everything is built into the PRODUCTS dir you can find the bundle easily and having copied automatically into the app.bundle. This is not a bad solution. If you are using svn the script got included in project, and users have it for free without additional work.
As suggested by Apple tech support, use folder references.Build bundle B into a folder and add such folder to project A using the "Create Folder References for any added folders" option. Xcode 4 will update your bundle into that folder every time you built it.
The added folder will appear as blue once included in your project A.
Thats's it, I personally use the script, because this solution is path independent if you use standard xcode reference variable such as BUILT_PRODUCTS_DIR and so on, and the shell script is just a cp -r-f
[UPDATE 03/04/2015]
I would like to point out that the question is now 4 years old. At that time there weren't many "official" options available. I even spoke with Apple Tech Support, which proposed solution 3 as the only available solution. It is of course very likely that things are now changed, and there is a much better solution. Just to speak, I also like to add that the three above are not "hacks" but "solutions", maybe technically outdated, but they can still be used nowadays. I intend a "hack" as a..."hack", which means it probably not going to work in future software release.
Here is how I did it.
Drag and drop B.bundle from Project B → Products → B.bundle into the Copy Bundle Resources build phase of your app in Project A (select the Create groups options when asked). This will add B.bundle at the root of your Project A outline. You can move it into the Frameworks directory near Blib.a if it you prefer.
Select B.bundle and check its Location in the Identity and Type right panel (Utilities area). By default, Xcode chooses Relative to Project. This is wrong, select Relative to Build Products instead.
The path to B.bundle will now look something like ../../../../../../../../Projects/MyApp/B.bundle. This is not what you want, but you can easily fix it. Open ProjectA.xcodeproj/project.pbxproj in a text editor, search for this path and delete everything in it except for B.bundle. Your project.pbxproj should look like this:
explicitFileType = wrapper.cfbundle; name = B.bundle; path = "B.bundle"; sourceTree = BUILT_PRODUCTS_DIR; };
Save your project.pbxproj file. Xcode will automatically reload your project and your app should build just fine.
After searching for a long time and failing many times, I found this resource that has been an absolutely great tutorial to create Static Libraries and include bundles in your main project or even for distribution to 3rd party developers that may consume your library.
Absolutely recommended:
https://github.com/jverkoey/iOS-Framework
In project A, is the product of project B a dependency in your scheme's Build action? I think you might have to set up this dependency (sometimes disabling the automatic dependency discovery option is best) for it to show up and be available for copying into another target. I believe this is because it doesn't really exist (like an image resource file) until it's built and Xcode needs to ensure it's built before working with it from another target.
As of Xcode 5.1.1 I was able to drag and drop B.bundle from the Project Navigator to the Copy Bundle Resources list of project A Build Phases. I assume creating B.bundle target is not an issue.
Switch build to Generic iOS Device. This step is needed to create a non-simulator reference.
Drag the .bundle to the other project's Copy Bundle Resources.
Select the .bundle in the Project navigator of the other project, and change its Location to Relative to Build Products
Make sure your .bundle in added to Target Dependencies of your static library

Xcode -- groups and targets

I have an Xcode project. The project currently has four targets, and I am about to add more. Within the project are about 150 png files. I have all of these in a tree of groups in the Xcode "groups and files" panel.
I want to include these png files in some of my targets, but not in others. The thing is, I will always want either all of them or none of them. I don't want to pick and choose.
Is there a way to manage this? Basically, I want some targets to use all of the files in the "png files" group, and others to use none of them. If there is a way to include an entire tree of groups in a target, and remove the same tree from another target, without having to do each file individually, that would be ideal.
EDIT: starting a bounty on this due to the lack of response. If it's not possible to do the above, I would be interested in other ways to accomplish more or less the same thing -- for example would it help to make all the png files a shared library? Or to make them a target in and of themselves, and have some of my other targets depend on that one? In either case, I would need to know how to set the thing up.
My bottom line is that I want to do the whole thing as simply as possible. For example, it should be easy to add a file to the 150 and tell my project that it should be included in all targets that use that group of files.
I am using the Xcode 3.2.3 right now. I am able to right click on a group, select get info then jump over to the 'Targets' tab and select my targets I want those files to go into. It works for me, is this what you are looking for?
Write a script and include it in the appropriate targets as Run Script Phases. Since it gets environment variables from Xcode it’s pretty easy for the script to copy files over to the right place. You can also pass more information to the script and maintain a clean, code-only Xcode project.
You’ll have a directory full of images, and every time the script runs (as you build the targets) it copies everything. To add an image, you add it to the directory without modifying the Xcode project.

Resources