Command line --resources-dir-path is not working in MAC

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

Command line --resources-dir-path is not working in MAC

Postby tuma » Wed Sep 17, 2014 9:54 am

Hi,

I am facing issue when I tried to pass --resources-dir-path command line for my CEF application. It fails at CHECK in below function.

libcef/common/main_delegate.c
void CefMainDelegate::InitializeResourceBundle() {
.....
if (!content_client_.pack_loading_disabled()) {
CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale;
}

I am using Chromium Embedded Framework.framework from cefclient.app of CEF 1650. This framework is copied outside of my app folder and libcef.dylib is linked.

What could be the issue here?

Regards,
T. Umapathy
- tumapathy
tuma
Techie
 
Posts: 37
Joined: Fri May 11, 2012 3:26 am

Re: Command line --resources-dir-path is not working in MAC

Postby tuma » Wed Sep 17, 2014 9:57 am

Additional information:

It works fine if I bundle CEF framework inside my app Framework folder without command line. But due to MAC V2 code sign issue, I am trying to move out this framework folder from my app folder.
- tumapathy
tuma
Techie
 
Posts: 37
Joined: Fri May 11, 2012 3:26 am

Re: Command line --resources-dir-path is not working in MAC

Postby magreenblatt » Wed Sep 17, 2014 12:54 pm

tuma wrote:I am trying to move out this framework folder from my app folder.

I don't think that's going to work for you. The Chromium code expects the framework folder to exist inside of an app bundle and locates resources/libraries accordingly. For example you can debug the resource loading in CefMainDelegate::InitializeResourceBundle.
magreenblatt
Site Admin
 
Posts: 12383
Joined: Fri May 29, 2009 6:57 pm

Re: Command line --resources-dir-path is not working in MAC

Postby tuma » Thu Sep 18, 2014 8:43 am

I made following changes in main_delegate.cc. And it solves my issue. Now I am able to load CEF framework outside of my app.

Code: Select all
//
// The below function modified to locate Framework bundle related to libcef.dylib
//
/*// The framework bundle path is used for loading resources, libraries, etc.
base::FilePath GetFrameworkBundlePath() {
  return GetFrameworksPath().Append(
      FILE_PATH_LITERAL("Chromium Embedded Framework.framework"));
}*/

//
// Copied from GetAppBundlePath function in chromium/src/base/mac/foundation_util.mm
//
// Takes a path to an (executable) binary and tries to provide the path to an
// framework bundle containing it. It takes the outermost bundle that it can
// find (so for "/Foo/Bar.framework/.../Baz.framework/..." it produces "/Foo/Bar.framework").
//   |exec_name| - path to the binary
//   returns - path to the application bundle, or empty on error
base::FilePath GetFrameworkPath(const base::FilePath& exec_name) {
    const char kExt[] = ".framework";
    const size_t kExtLength = arraysize(kExt) - 1;
   
    // Split the path into components.
    std::vector<std::string> components;
    exec_name.GetComponents(&components);
   
    // It's an error if we don't get any components.
    if (!components.size())
        return base::FilePath();
   
    // Don't prepend '/' to the first component.
    std::vector<std::string>::const_iterator it = components.begin();
    std::string bundle_name = *it;
    DCHECK_GT(it->length(), 0U);
    // If the first component ends in ".app", we're already done.
    if (it->length() > kExtLength &&
        !it->compare(it->length() - kExtLength, kExtLength, kExt, kExtLength))
        return base::FilePath(bundle_name);
   
    // The first component may be "/" or "//", etc. Only append '/' if it doesn't
    // already end in '/'.
    if (bundle_name[bundle_name.length() - 1] != '/')
        bundle_name += '/';
   
    // Go through the remaining components.
    for (++it; it != components.end(); ++it) {
        DCHECK_GT(it->length(), 0U);
       
        bundle_name += *it;
       
        // If the current component ends in ".app", we're done.
        if (it->length() > kExtLength &&
            !it->compare(it->length() - kExtLength, kExtLength, kExt, kExtLength))
            return base::FilePath(bundle_name);
       
        // Separate this component from the next one.
        bundle_name += '/';
    }
   
    return base::FilePath();
}
   
// The framework bundle path is used for loading resources, libraries, etc.
base::FilePath GetFrameworkBundlePath() {
    base::FilePath modPath;
    PathService::Get(base::DIR_MODULE, &modPath);
   
    modPath = GetFrameworkPath(modPath);
   
    return modPath;
}
- tumapathy
tuma
Techie
 
Posts: 37
Joined: Fri May 11, 2012 3:26 am


Return to CEF Discussion

Who is online

Users browsing this forum: No registered users and 20 guests