Sharing a single cocoa framework copy across plugins - cocoa

I have a set of plugins, a plugin framework for common code and a host app. These are each in separate Xcode projects (including separate projects for each plugin). In the end, I need to be able to click build and run on the host app project to build all the plugins, the framework and host app, package them up and launch the app.
I know how to include the framework and plugins into the host app project, set up dependencies, copy actions, etc. What I am not sure about is how to include a single copy of the plugin framework in the host app for the various plugins to use rather than having a copy included in each plugin bundle.

Try weak-linking the plug-ins against the framework, copying the framework into the app's Frameworks folder, and linking, in the regular fashion, the app against that copy.

To have it automatically copy the framework to your application's bundle when the app builds, make a new "Copy Files" build phase. Drag the framework into the build phase. Then, do a Get Info on the Copy Files phase and set the Destination picker to "Frameworks".

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?

Deploying shared server controls with web.config transforms

I'm using teamcity to deploy our web application to several servers using msbuild and webdeploy.
I have a configuration per customer / environment combination - for example:
Internal-Dev
Customer1-Test
Customer1-Pilot
Customer1-Live
Customer2-Test
Customer2-Pilot
Customer2-Live
I only need these configurations so that the deployment process can use web.config transformations to set the appropriate connection strings and other settings for the installation.
The problem that I have is that I have a shared web server controls project which really only needs two configurations - debug and release - but I need to copy all the above configurations into this project in order to get them to work. If I delete Customer2-Pilot from the shared project, I can't deploy to customer 2's pilot server because it is looking for the Customer2-Pilot configuration for the shared project which doesn't exist.
Currently, I copy the application's configuration names into the shared project but that is impractical as we have several applications each going to different customers so the shared project could get dozens of configurations which are all copies of Release or Debug
I would like to be able to configure the build system so that I can say that the Internal-Dev configuration of the web application project uses the shared project's Debug configuration and all the other configurations use the shared project's Release configuration. This is possible from within the IDE, using the configuration manager which can tie a solution configuration to individual project configurations but I'm not sure how to do this from within teamcity.
My current teamcity configuration is using the MSBuild runner with the web application's project file as the build file path and the configuration parameters set to deploy it to the relevant server with the correct configuration after it has been built. The shared project is in a sub-repository of the web application repository so it is fetched and built automatically.
Is there any way that I can change this set up to get what I want? Do I need to change the build file path to be the solution instead of the project so that I can use the configuration manager settings to configure it?
It turns out that this is as simple as changing the build file path parameter to be the solution file instead of the project file. This means that you specify a solution configuration instead of a project configuration. Solution configurations are managed in the configuration manager and you can specify the configuration of each project in the solution configuration so it all works nicely.
I have two projects that need to be published (a web application and a WCF service application) and they depend upon five other class library projects. I have it set up so that the class library projects are built using either the Debug or Release configurations and the two projects that have config files that need to be transformed have one configuration per system.
One thing of note. In the old set up I had to have two build steps - one to build and deploy the web application and one to build and deploy the WCF service application. When I use the solution file as the build file, I don't need two steps any more as they are both part of the solution and so they both get built and deployed.

Include another xcode project into my own

How can I include a project (is standalone) into my project and launch it from within my own app? What are the requiered steps so that my current project recognizes all the sourcecode from the other project?
If you are intending to run an application unmodified from another application, you can't do this. iOS expects you to have one application executable with one entry point and one app delegate.
If you have a library in source form that you would like to include in your project, you can simply drag the files into Xcode while your project is open.
If you drag an Xcode project file into the project navigator sidebar it will be added to the project setup.
You will need to configure import paths and other things in order to access code though.
If you are trying to use 3rd party libraries, I strongly recommend having a look at CocoaPods. It's really easy to set up and manages dependencies with all of their build settings for you.

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.

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