Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-20557] Allow modules to use third party dynamic libraries #9346

Merged
merged 11 commits into from Aug 30, 2017

Conversation

janvennemann
Copy link
Contributor

@janvennemann janvennemann commented Aug 23, 2017

JIRA: https://jira.appcelerator.org/browse/TIMOB-20557

Optional Description:
This adds a fully automated framework configuration including support for dynamic frameworks

  • Scans for available frameworks and collects some metadata information about them which is used to integrate them in the Xcode project
  • No more need to manually add linker flags or framework search paths to a modules .xcconfig
  • Bundle a default script for stripping unused architectures for proper app store submissions. A user can provide his own script by droping it as platform/ios/strip-frameworks.sh in project.
  • Metabase collection is cached on subsequent builds and only rescans changed or added frameworks if necessary
  • Assure backwards compatibility (avoid duplicate linking due to manual -framework linker flags). Either by restricting the automated configuration of frameworks to a subdirectory, e.g. Frameworks so the new mechanism does not interfere with existing modules, or by intelligently skipping the automated Xcode project integration for frameworks that have a .xcconfig (checking only for the -framework linker flag should probably be sufficient). EDIT: This seems to be a non issue. Xcode has no problems with multiple -framework flags and the framework search path already has a dupe check.

* @param {frameworkInfo} frameworkInfo Framework metadata
* @param {string} fileRefUuid Uuid of the frameworks file reference inside the Xcode project
*/
addEmbeddFrameworkBuildPhase(frameworkInfo, fileRefUuid) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you either have an extra d or missing an ed.

* @param {Object} cli CLI instance
* @param {Object} config Project configuration
* @param {Object} logger Logger instance
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All class methods, including constructors, should have an @access jsdoc after all other jsdoc tokens. Possible values are @access public or @access private.

*/
detectBinaryTypeAndArchitectures(binaryPathAndFilename) {
return new Promise((resolve, reject) => {
exec('file -b "' + binaryPathAndFilename + '"', (error, stdout) => {
Copy link
Contributor

@cb1kenobi cb1kenobi Aug 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure this works fine. Generally I prefer spawn() or spawnSync() over exec(). It's more robust and you won't run into problems should binaryPathAndFilename contain a double quote.

return Promise.resolve();
}

let incrementalDirectory = path.join(this._builder.projectDir, 'build', 'incremental');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, you should always use const unless you need to use let. This also includes for loops.

/**
* Finds any .framework directories inside the project and its modules
*
* @return {Array} Array of available third-party framework directory paths
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function actually returns a Promise.

/**
* Add the framework as a new file reference to the Xcode project
*
* @param {frameworkInfo} frameworkInfo Framework metadata
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the type should be FrameworkInfo. There are a couple other places below with the same issue.

* Add the framework as a new file reference to the Xcode project
*
* @param {frameworkInfo} frameworkInfo Framework metadata
* @return {string} Uuid of the created file reference
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All built-in types should be capitalized: String.

this._xobjs.PBXFileReference[fileRefUuid] = {
isa: 'PBXFileReference',
lastKnownFileType: 'wrapper.framework',
name: '"' + frameworkPackageName + '"',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using ES6 template strings to make the code more readable:

name: `"${frameworkPackageName}"`,

* @return {Promise}
*/
detectFrameworks() {
return this.findFrameworkPaths().then((frameworkPaths) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, I recommend putting the .then() on the next line. This makes it a little more readable, especially if there's a .catch().

}

resolve({
type: type,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use shorthand properties here.

resolve({ type, architectures });

@janvennemann
Copy link
Contributor Author

Awesome input man, thanks! Addressed everything and updated the PR.

@ewieberappc ewieberappc self-requested a review August 30, 2017 15:40
Copy link
Contributor

@cb1kenobi cb1kenobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR'd and FR'd. Works as expected. Really good code! APPROVED!

@cb1kenobi cb1kenobi merged commit 9e9a0b5 into tidev:master Aug 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants