IBPlugin and paths to framework - cocoa

IBCocoaSimulator crashes when IB cannot find the framework, I assume that happens to you too. I can run IBCocoaSimulator without crash, when I manually copy my framework+ibplugin from the build dir into /Users/username/Library/Frameworks. I'm doing this with Finder, this is not optimal, but works.
I have searched for a smarter way and each solution (BWToolkit, BGHUDAppKit, KTUIKit) I have been looking at, does things in much different ways. One solution runs a sudo script that copies it to the system wide /Library/Frameworks. Another sets #loader_path and yet another uses #executable_path. I haven't had luck with any of them and because of the great differences it's hard to see the pattern.
I'm confused.
How do you config you IBPlugin, so that you can embed it in your app?
UPDATE 1:
Yay, solved it, after reading a blog post by dribin about how to use #rpath, I figured out how to get it working with my IBPlugins. So copy using Finder is no longer needed.
What I did was:
For MySmallFramework set Installation Directory to #rpath
For MySmallPlugin set Runpath Search Paths to #loader_path/../Frameworks
For MySmallApp set Runpath Search Paths to #loader_path/../Frameworks
Nice.

Might be obvious to most of you, but neoneye's solution as posted in his "Update 1" requires your plugin target to have a "copy framework files" build phase with the given framework assigned to.
(don't yet have enough points for direct commenting :( hence the answer post)

You can call this with external makefiles xcode project from ibplugin makefile like following example:
install_name_tool -change #loader_path/MyPluginName.framework/MyPluginName #loader_path/<absolute path or level to updirectory>/MyPluginName.framework/MyPluginName $(BINDIR)/MyPluginName.ibplugin/Contents/MacOS/MyPluginName

Related

macOS Application Bundle Frameworks Directory Codesign

I am packing my macOS application into an application bundle. I need to codesign it and pass notarisation. It is possible to put the frameworks in the "Resources" directory?
I have two frameworks. Normally, I used to put such frameworks into the "Frameworks" directory of the bundle. However, for (stupid) designing reason I need to have some more libraries in the same directory of my frameworks. Since such libraries will prevent code signing if placed in the directory "Frameworks", I want to move frameworks + extra libraries into the "Resources" directory.
Reading Apple documentation it seems that frameworks should - of course - belong to the "Frameworks" directory, however I could not find any reference to what should NOT be included into the "Resources" directory. Is this bad practice? Would my .app structure not pass gatekeeper?
Any suggestion would be very much appreciated
You've probably already tried putting a frameworks in Resources by now. As you said, even if it works today, this is not a good idea.
You might be able to work around whatever issue caused you to want to do this by using the install_name_tool to change one of the paths built into your frameworks. Adding symbolic links are another handy device for issues like this. This kind of stuff can be done automatically in a Run Script Build Phase or a Build Phase Post Action.

If no additional directory in the install_name of a dynamic library, then which path does dyld search?

Mac, for a compiled project (using QT 5.5.0), I directly run the executable file, the error:
libraw.10.dylib not loaded;
OK, I know the reason.
One solution is to use install_name_tool to change the install name of libraw.10.dylib and put it in somewhere, like in the article:
"Qt for OS X - Deployment"
But right now I don't want to do this way.
One reason is that I do not need to really deploy it; so I want to make it simpler by only copying the library "libraw.10.dylib" to the right place.
The second reason is that I am curious what the default path for an install name without additional directory.
But no matter where I put the file "libraw.10.dylib", the same error comes out.
I tried to look into the details in the man page of dyld,
I couldn't figure it out.
Maybe all path variables are empty (I tried several popular variables, such as DYLD_FALLBACK_FRAMEWORK_PATH, DYLD_FALLBACK_LIBRARY_PATH, etc; they are empty).
Then I put the library "libraw.10.dylib" on the root, parallel to the folder "Applications". Still the same error.
So what dyld is looking for when it encounters:
libraw.10.dylib

Compiler warning after install Xcode 7 Directory not found for option '-F ...'

I check this answer with no success.
Maybe sounds obvious but I look for inside the path and effectively does not exist the path, but this path is used for Xcode and not for my code (at least not that I know it)
The folder suppose to be here the but it does not exist (create the folder manually but does not fix it)
Somebody have an idea ?
I had the same problem, here's how I solved it:
Go to the "Build Settings" of the Tests Targets (Make sure it's the "Tests" files with the white building block logo) and erase the Framework Search Paths.
Since you claim that the path doesn't exist, I suppose you were looking under the normal file instead of the "Tests". At least that was my mistake.
Good Luck!
I changed the last "Developer" in the Tests target's "Frameworks Search paths" path to "System" (...iPhoneOS9.0.sdk/System/Library/Frameworks) because there is a System/Library/Frameworks directory. My code builds and the warning goes away.
Ups !!
I have the problem in the Test Compiling.
I delete the path and fix it.
I have the same problem. I can temporarily rectify the issue by selecting "Product - Clean" from the menu. It soon returns though.

Generate an xcodeproj

I know this might sound a bit strange but I'd need to generate a xcodeproj automatically.
Basically scanning the filesystem and adding certain files to the project and to a specific target.
The main reason behind this, is that I work in an zero IDE environment. Thus, we have our own build system and source files are added and removed all the time.
I could use "create folder references for any added folders". However, xcode won't ever parse source files if they aren't part of any target. So, no symbols, no code completion...
To me, my only option would be to "auto-update" my xcodeproj with a script...
Thanks in advance for your inputs!
Cmake is one option (see this related question) and there's also Scons which I think can generate Xcode projects. There's also Qt's qmake which can generate the project files, but this is probably overkill unless you're using full Qt.
You can either user AppleScript (or anything OSA-compatible) to automate the process of creating the project in Xcode itself, or you could look at CMake, which is able to generate Xcode project files.

Xcode dependencies across different build directories?

I am trying to set up Xcode for a project which contains multiple executables and static libraries. I have created multiple targets and set up the linking and dependencies, and initially everything works great. The catch...
This is an existing project which already has Visual Studio and Makefile builds. Those builds put the libraries in a lib/Debug directory and the executables in bin/Debug. So in Xcode I changed the Build Products Path to "lib" and "bin" respectively (so we can use one set of documentation for all of the platforms). This puts the compiled targets in the right place, but completely breaks both the linking (Library not found) and the dependencies.
I can fix the linking by adding $(SRCROOT)/lib/Debug to the Library Search Paths for each executable (but it feels like Xcode should be able to figure this out on its own, which makes me think I'm doing something wrong).
But — I can't figure out how to get the dependencies working again. If I change a library source file, the library will rebuild but not the dependent executables. If I force a build of the executable Xcode returns success without doing anything; it thinks the target is up to date. If I clean the target and then rebuild it works.
So, any ideas here? Is Xcode being fundamentally stupid in this regard, or is it me (I'm leaning toward the latter)?
Update: I've posted a sample project to demonstrate the issue at http://share.industriousone.com/XcodeDepsIssue.zip. Build it once, then modify MyStaticLib.c and build it again. The executable will not relink (and it should). Many thanks for any help on this one.
starkos, thanks for publishing your conclusion. It validated my experience as well. This situation really screwed me, so it was nice to know I wasn't just missing something.
I did however discover a workaround that avoids creating multiple projects or keeping the library and its dependent in the same directory. It is a hack, but it does work here.
I know it's a bit late but better than never.
For the dependency library, add a "Copy Files Build Phase", with Absolute Path as the destination, and the path text field should be the directory where the DEPENDENT target lives. Then click on Products, find the dependency library (will end with .a), and drag it into the "Copy Files Build Phase." If you now build, this will put the library into its own directory like before and THEN also copy it into the dependent's target directory.
For the dependent, you can now remove the dependency's output directory from the Library Search Paths. This will cause it to find the library copy. If you do this, the dependent will indeed be relinked each time the dependency .a is relinked.
The negatives are, of course, the extra time for the copy, and the necessity to specify (in the Copy phase) the target directory for each dependent of your library. Beats the hell out of the alternatives though....
Xcode doesn't automatically set up dependencies based on use of build products; you have to set up explicit target dependencies yourself.
Project > Edit Target Settings, General tab, + button, add any targets that are prerequisites to building the selected target. That should get you going again.
I've researched this some more and the answer is no, Xcode 3.x doesn't track dependencies between targets that live in different directories. You can work around it by giving each library its own project, and adding each of those to a master project. Or you can keep all of your targets in one directory. Pick your poison.
Here is my solution for this weird behavior in xcode 4.3.1. You have to add build pre-action in scheme:
rm -f ${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}
and choose which build settings to use for this script. Each time before build, target executable will be removed and rebuild completely. It helped for me, and i hope it helps you.
NOTE: Have tried to put this script in project build phase, and result was negative - debugger could not connect process to start debugging.
Good luck!
OK, it would help to have the text of the Linking... build line that's failing. But a couple of things:
1) You shouldn't be linking to anything in $(SRCROOT). That's your project sources. The two places to find things to link are $(SYMROOT) (the Build Products directory) or $(DSTROOT) (the Installed Products directory).
One thing you could do is to have a common Build Directory, then use 'xcodebuild install' action to install the products in the Installation Directory. The other is to use a Copy Files build phase to copy them after building, so you can link against them in $(SYMROOT) but still have them where your Windows compatriots expect them.
THere is probably a way to set up the per-target build products directories correctly, but I'd really have to see the project itself to figure it out.

Resources