alunny / node-xcode

tools and utilities for working with xcode/ios projects
Apache License 2.0
226 stars 105 forks source link

Support for the addition of Embedded Binaries #78

Open Compulsed opened 8 years ago

Compulsed commented 8 years ago

I need to be able to programmatically add embedded binaries (Cordova & a 3rd party dynamic framework being used), but I cannot see how I am able to do this using this XCode node module.

Is there plans on having this supported sometime in the future? Is this already supported and I am missing something?

Thanks!

image

aabluedragon commented 8 years ago

+1 Coming from the Cordova Plugins world, I need this as well in my custom plugin, would be nice if it was supported (and with an option in plugin.xml).

aabluedragon commented 8 years ago

For the time being, here's a workaround I implemented: http://stackoverflow.com/a/36723619/230637

jainpiyushb commented 7 years ago

@aabluedragon isn't your workaround for Embedded Framework and not Embedded binary?

aabluedragon commented 7 years ago

@jainpiyushb It is, however the Xcode section refers to it by the name "Embedded Binaries" (and The framework contains the binary itself) also note that the headers are removed upon build (as opposed to the binary).

shazron commented 7 years ago

Hi @aabluedragon , I thought it's supported here: https://github.com/alunny/node-xcode/blob/078625f16c102372965cc5a4f6a8f7a5145d36aa/lib/pbxProject.js#L300 already (embed option)? But I can't get it to work by implementing https://github.com/apache/cordova-ios/pull/299

shazron commented 7 years ago

Debugged this. The embed option will only add the framework if the "Copy Files" phase (that has to be named "Embed Frameworks") exists.

shazron commented 7 years ago

I believe this feature is already implemented. Here's some code that should work:

let embed = true,
    link = false,
    frameworkPath = '/Users/me/Desktop/MyFramework.framework',
    project; // the node-xcode pbxProject reference

let existsEmbedFrameworks = project.buildPhaseObject('PBXCopyFilesBuildPhase', 'Embed Frameworks');
if (!existsEmbedFrameworks && embed) {
    console.log('"Embed Frameworks" Build Phase (Embedded Binaries) does not exist, creating it.');
    project.addBuildPhase([], 'PBXCopyFilesBuildPhase', 'Embed Frameworks', null, 'frameworks');
}

let options = { customFramework: true, embed: embed, link: link, sign: true };
project.addFramework(frameworkPath, opt);