Unable to find nib named error when trying to load nib from within a framework - objective-c

I've got a 'Main app' and a 'Helper app' (sandboxed, if that matters) that share a private framework including some resources, nib files, sound files etc.
The framework gets called and used by both apps without issues. However from within in the Framework code I have a NSViewController that loads a nib file which is included in its resource folder. This seems to work as long as its called by the 'Main app'. Doing the same with the Helper app (a login item) however does not work and fails with an "Unable to find nib named" error.
The actual 'Framework' is copied to the Main app's 'Frameworks' directory and I use a #rpath in the helper app to find the framework: #executable_path/../../../../Frameworks
This setup seems to work just fine however at runtime it seems the frameworks code tries to find the named Resource under the helper app's Resource folder and not under the Framework's resource folder. Is there a setting or some flag that I can set in xcode to make the framework's always look under the exact path where the framework's executable/library is installed?

It seems the only solution is to copy the framework to the 'Helper' app as well. Resources otherwise do not get loaded if the framework was just a symbolic link to the actual framework placed inside the main app.

What you can do is making your Framework dynamic or shared like described here Dynamic Library Programming Topics
Though it is a bit of a complex process, but a very nice feature.
What else can help you?
Perhaps editing the Library Search Paths or the Framework Search Paths under your Build Settings in Xcode. there you can specify additional search paths to look for.
Even though, I would not copy the Framework to the Main app's dir. I would leave it in one place on your disk, add them to your project (Main and helper) and add the specified search path.
By the way: How is your framework implemented? Is it a folder, is it compiled, or is it only code files?

Related

Why are some .h files missing when compiling wbrtc_ios as a framework?

I am new to WebRTC stuff. I cloned the webrtc_ios main branch, and I built the framework as instructed here with the python script for arm64. When I add this to my Xcode project as a framework, everything is fine. Project builds, I can import files using <WebRTC/...> syntax.
However, I need to use RTCMTLRendeder.h file. Building a framework with python script leaves some of the header files out. (When I take a look at WebRTC.h inside the built framework, I can see that this file is missing) How can I include all header files that actually exist inside /webrtc_ios/src/sdk/objc/components folder while building the framework? I can see RTCMTLRenderer.h and .mm files are in that folder before using the build script. When turned into a framework those files don't exist inside the framework anymore. Why? And is there any other way to actually copy those files into the project as well?
Turns out you need to create your own, long renderer class which does not inherit from RTCMTLRenderer at all if you want to render on Metal view manually in a Swift/ObjC hybrid project (at least this is how I solved it). That class does whatever RTCMTLRenderer does, and grabs pixel buffers from RTCVideoTrack through an RTCVideoView.

importing .less file from Razor Class Library

I have created a Razor Class Library to be able to distribute some global styles and views across projects, but I can't seem to import my .less files from the Razor Class Library.
In my RCL I have:
Styles
-Shared
-layout.less
-variables.less
In the project referencing the RCL I have:
Styles
-main.less
main.less only has:
#import "./Shared/variables.less";
When I run a build via webpack I get errors that it cannot resolve ./Shared/variables.less, but it works fine if I copy the Shared directory from the RCL into the project referencing it.
I have the BuildAction for the RCL .less files set to Content, is there anything I am missing, or is this something that is not possible?
It's some what possible, but not for specifically what you're trying to do here. An RCL is ultimately a DLL, so the only thing you can include in it, is things that can be "compiled" into that. I say compiled with quotes, because static files can be included as embedded resources, so while they're not themselves compiled, they are still literally being embedded into the resulting DLL. With the ManifestEmbeddedFileProvider, the app using your RCL can read from these embedded resources as if they were literally on the filesystem.
However, and importantly, they are not on the the filesystem, which means using things like webpack is a 100% no-go. What you'll need to do is actually do a webpack build as part of the RCL, and then embed the resulting static resources in the RCL. Your app, then, can have its own webpack build for it's own resources, but you won't be able to combine primitives from the RCL with primitives from your app.
You could possibly manually manage the build order and run a powershell script post build (making sure that the correct dll is building first) and interrogate the dll and extract the required files (?) into the correct folders in wwwroot, or wherever, before the webpack build. I think that happens after the projects are built, but I'm not an expert on webpack either and I haven't actually tried this.
Also technically if you want any static or view files to be embedded in the dll you would select "Embedded resource", well that is how I've done it in the past.

How can I install a yii extension, making it available to my whole web application?

Recently I decided to study php and I discovered yii framework. At first glance it seemed very easy to work with it but now I am struggling to configure my web application for installing an extension to work with Enums. I downloaded this extension from their web site and I put it within extensions folder. The issue is that I am not able to call the subclasses that I created in my code. I created a few classes that extend from this superclass (extension).
Which configuration I must do to make this extension class, available to my web application code?
As I said I just put that extension class in my extensions folder and I am just instantiating them, inside controller's methods. When I run the code I see the same error message no matter any configuration I make:
include (xxx.php): failed to open stream: No such file or directory
If anyone does want to know more about this extension this is the page that shows some information about that.
http://www.yiiframework.com/extension/enum/
in config/main.php you should add your extension details in the components array, something like:
return array(
// 'preload'=>array('xyz',...),
'components'=>array(
'xyz'=>array(
'class'=>'ext.xyz.XyzClass',
'property1'=>'value1',
'property2'=>'value2',
),
// other component configurations
),
);
where xyz is an extension
or just put it in the extensions folder and import it by Yii::import('application.extensions.extensionname.*');

NSTask setLaunchPath Objective-C Cocca

This is a very simple question. I have a script in the same folder as the Cocoa app. I can't seem to set the path to it properly for setLaunchPath for NSTask. Help please.
I have a folder called Project. Inside of it, exist multiple folders but only two we care about: Classes (the source files for the Cocoa app are here) and Ruby (which is a ruby server folder). I am trying to call Ruby/script/server. I assumed it would be something like ./Ruby/script/server or Ruby/script/server but both are wrong.
Thanks.
EDIT: I guess what I'm actually asking is if there is a way to access the folder where the source files or the project is by using a special character or shortcut because by default it goes to the /tmp folder.
The current directory (in the unix sense) in an app is not guaranteed to be anything. The path to the app itself can be obtained by getting the main app bundle by
NSBundle*mainBundle=[NSBundle mainBundle];
and then getting its path
NSString*path=[mainBundle bundlePath];
However please don't do that; you won't be able to distribute your app without extra instructions of putting files here and there.
Instead, put your Ruby code inside yourApp.app/Contents/Resources/. This can be done by including the Ruby code in the XCode, and making sure it's set to be copied into the app. The files inside this Resources directory can be obtained as follows:
NSString*path=[mainBundle pathForResource:#"rubyServer" ofType:#"rb"];
To learn more about the bundle structure, read Bundle Programming Guide.

Using MEF with exporting project that uses resources (xml) contained in the xap

I'm doing a proof of concept app in SL4 using MEF and as part of the app I am importing another xap from an existing Silverlight Project and displaying it in my host project.
The problem is that the existing app uses some .xml files (as content) and it uses linq2xml to load these files which are (assumed to be) bundled in the xap.
When I compose the application the initalization fails because the host app doesn't contain the xml files. If I copy these xml files into the host project and run it the composition works fine. However, I need to keep the xml files in the original project.
Is there a way that I can download a xap and look at it's contents for xml files and then load them into the host xap at runtime so that after the compostion takes place the xml resources that are required can be found?
Or should I work out some kind of contract with an import/export to pass the xml files to the host xap?
As the people developing the imported xaps (should the project go ahead) are from a different company, I would like to keep changes to the way they develop their apps to a minimum.
I assume you are using the DeploymentCatalog to download the second xap? Unfortunately there's no way to get at resources included in that xap. You could have the resources embedded in assemblies which are included in the xap, and then modify the way they are loaded.
If you really don't want to change the way the secondary xap is structured, you might be able to write your own DeploymentCatalog which would also allow you to load resources from the downloaded xap. The source code to DeploymentCatalog is available, so you could base it off of that.
I've managed to find a solution that I'm fairly happy with.
Instead of building the .xml files as 'content' to go within the xap, I have built them as 'resource' then used Application.ResourceStream() and loaded the xml using a stream.
It means the second xap developers will have to change the way they operate, but its only one extra line of code and changing the Build Action, I'm sure they can handle.