Xcode aggregate target dependency - xcode

I have an XCode project with 3 targets:
The application
An external build system target that builds my assets
An aggregate target that has 1 and 2 as dependencies.
The functionality that I want is:
Building the application will only build the application
Building the external build system will only build the assets
Building the aggregate will build the external build system first and then the application
Currently the aggregate builds both simultaneously which creates a race condition if the application gets to a certain point before the external build system completes. I can't add the build system as a dependecy for the application, because then building the application would do both. Is there a way to accomplish this without making a copy of my application target?

The following works for me in a similarly arranged project.
Under Build Phases -> Target Dependencies arrange the targets in the order that you want them to compile. (external build system then the application).
Second, in the Edit Scheme window for the aggregate project, under Build, uncheck Parallelize Build.
Additionally, to get the application to build only the application, you may need to uncheck Find Implicit Dependencies in the application project's build scheme.

Related

Embedding/excluding certain SPM libraries in specific build configuration

Currently our project are utilising come libraries added through SPM which contains some forbidden symbols, e.g RxTest, so before uploading the build to AppStore Connect we have to remove those libraries manually in Target -> Frameworks and Libraries, but this way we cannot make the upload into an automation process.
Is there any way to configure those libraries to be embedded only in certain build configurations, e.g. Debug but not Release? Or in order to achieve the same goal, is there any command to remove specific libraries?

Exclude a file form project at compile time swift3.2 - xcode

I have one file which reference I have added in xcode main project target and test case both.
This file reference needs to be added to main project only when test cases are running.
I don't want to include it when I create main project build since this file is for testing purpose only.
What is the best way to remove reference from main project when test cases are not running?
I have resolved my issue by using Exclude files setting from xcode's build setting.
I have added mock file reference to both app and test target.
Then for release and AppStore build configuration I have excluded mock file so that it doesn't any extra size in app store build.
Since test cases run only in debug mode. This is safe solution.

How to build same project with multiple configuration C# VisualStudio2012

I have a solution with many projects.
I Would like to build several projects with multiple configuration settings.
e.g:
ProjectA is set as target framework: 3.5 and platform target x86.
output assembly name is: ProjectA.dll.
I want, when clicking the build button, to build the project in several output files:
ProjectA_3.5_x86.dll - for Target framework 3.5 and platform x86
ProjectA_4.5_x64.dll - ...
This is what buildservers does.
Is there a way to have config file that build operation looks at, and then determine how to build each projects, with different assembly names and different build configurations ?
Thanks !
As far as I know, you can only produce one dll per compile of a project. It sounds like what you would want to do is create different build configurations; which can be done by manually editing the project file or using the configuration manager. You can set up different configurations (3.5 framework, x86 CPU, with an assembly name of xxx.yyy) and then select that configuration when you do a compile. However, it is important to understand that you will have to do multiple compiles on your code, selecting the different configurations, to produce the different dlls. If you have an automated build process, you should be able to just set up the project to compile multiple times and change the configuration name.

Target dependencies vs. Link binary with libraries

I don't understand the difference between these Xcode features.
I'm building and app - but the functionality of the app is being abstracted into libraries (so they can be distributed separately as an "SDK").
So I have a workspace of library projects and the app project. I can add library projects to the app project by doing "link binary with libraries". This gives me a list of .a library projects in the current workspace which I can link to.
I can also add frameworks here.
In the "target dependencies" bit all I can add is other targets in the current project.
What I really want to do is both - I want my app project to build all the other library projects when I build it. I also want to make it verbose what libraries the app (and other libraries) depend on.
So can somebody please explain the difference, and whether what I am doing is the right way to go about it?
Many thanks!
It says here...
Drag your framework product (located in the Products folder) to the existing Link Binary With Libraries build phase of your application
target. This causes the application to link against your framework.
And...
In the General tab of the inspector window, add your framework as a dependency for the application. Adding this dependency causes Xcode to
build the framework target before building the application target.
The build dependency you establish in the application target causes
the framework to be built before the application. This is important
because it guarantees that a built version of your framework will be
available to link against and to embed in the application. Because of
this dependency, you can set the active target of your Xcode project
to your application and leave it there.
So it seems that you're supposed to use both. Seems redundant though, because if you're linking to a framework then its a dependency. I suppose you might want to only link to a library and not build it first. Although Xcode seems to build linked libraries even without them being added to the dependency section. Perhaps that's a result of the "Find Implicit Dependencies" option in a scheme's build settings.
I do something similar and was explicitly setting the 'header search path' and 'library search path' in the final executable target. However this all depended on where the objects were being generated. Initially I had set this to be within the source tree (actually a sibling directory called build), however after changing the location of the Xcode DerivedData directory and telling it to build into that directory, the projects no longer built.
The final solution was simply to remove the explicit setting of the 'header/library search path' and set the target dependencies correctly. This resulted in the project building for debugging and archiving without issue.

What is a target dependency?

I feel so noob asking this question, but what is a target dependency? I see it all the time in Xcode.
A dependency is another target that must be built before the current target can be. For example, if you have an app target and a framework target, the app target can have the framework target as a dependency, to ensure that the framework is built first. That is, the app target "depends" on the framework.
Xcode Explicit Dependency
Xcode Dependency[About] is a dependency required to build a selected target.
Explicit dependency
Explicit dependency is a source code aka Non-compiled dependency. Xcode builds all explicit dependencies before the dependent target. Explicit dependency overrides implicit dependency with the same product_name.
Explicit Dependency is specified in Build Phases -> Target Dependencies.
There are multiple ways to specify in Xcode that our target depends on other target’s products:
If a target is located in the same project
No additional setup
If a targets is located in different projects using cross-project reference[About]
Specify search path
Additional notes:
Dynamic Framework
You should specify General -> Embedded Binaries. If not - on the real device you will get dyld: Library not loaded[About]
If you start adding your dependency from General -> Embedded Binaries and select a product that is explicit dependency, Xcode automatically add it into Build Phases -> Target Dependencies
Static binary
You can fill out only Build Phases -> Target Dependencies
[Implicit dependency]
[Vocabulary]

Resources