-
Notifications
You must be signed in to change notification settings - Fork 98
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
Fix issues with pbxFile extension and addTargetDependency sections #12
Conversation
Offtopic:
Public repository somewhere? I remember some people asking about something like that... |
@janpio We are looking into moving to NativeScript (from Xamarin) with our app here: https://github.com/bitwarden/mobile/tree/ns2 . Though most of what is going on right now is just discovery so not all work is committed. |
Ah ok, let me know if this works out with |
What is the status of this proposal? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some comments, the overall functionality seems fine, but please us strict equal checks instead of the abstract equal checks
test/pbxFile.js
Outdated
@@ -278,5 +278,13 @@ exports['settings'] = { | |||
|
|||
test.deepEqual({COMPILER_FLAGS:'"-std=c++11 -fno-objc-arc"'}, sourceFile.settings); | |||
test.done(); | |||
}, | |||
|
|||
'should have extension if {explicitFileType:"blah"} specified': function (test) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the test name here does not match the actual content of the test
Thanks @n1ru4l for reviewing. It looks like we do want at least some of the proposed changes but I still don't really understand everything that is changed here. |
Co-Authored-By: kspearrin <[email protected]>
@n1ru4l Suggested changes applied. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Several changes in
lib/pbxFile.js
are not covered by testing. Reverting these proposed changes would not cause any test failures - None of the changes in
lib/pbxProject.js
are covered by testing. Reverting all of the proposed changes in this file would not cause any test failures.
I would favor merging the first few changes in lib/pbxFile.js
, which seem to be properly tested, and dealing with the other changes in one or more separate PRs.
Also +1 for changing !=
to !==
but I would favor making this kind of fix, throughout this project, in its own PR.
return extension; | ||
} | ||
} | ||
} | ||
|
||
function defaultEncoding(fileRef) { | ||
var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, | ||
var filetype = fileRef.lastKnownFileType && fileRef.lastKnownFileType != DEFAULT_FILETYPE ? | ||
fileRef.lastKnownFileType : fileRef.explicitFileType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not covered by testing.
@@ -119,7 +121,8 @@ function defaultEncoding(fileRef) { | |||
|
|||
function detectGroup(fileRef, opt) { | |||
var extension = path.extname(fileRef.basename).substring(1), | |||
filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, | |||
filetype = fileRef.lastKnownFileType && fileRef.lastKnownFileType != DEFAULT_FILETYPE ? | |||
fileRef.lastKnownFileType : fileRef.explicitFileType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not covered by testing.
@@ -139,7 +142,8 @@ function detectGroup(fileRef, opt) { | |||
|
|||
function detectSourcetree(fileRef) { | |||
|
|||
var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, | |||
var filetype = fileRef.lastKnownFileType && fileRef.lastKnownFileType != DEFAULT_FILETYPE ? | |||
fileRef.lastKnownFileType : fileRef.explicitFileType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not covered by testing.
@@ -158,7 +162,8 @@ function detectSourcetree(fileRef) { | |||
} | |||
|
|||
function defaultPath(fileRef, filePath) { | |||
var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, | |||
var filetype = fileRef.lastKnownFileType && fileRef.lastKnownFileType != DEFAULT_FILETYPE ? | |||
fileRef.lastKnownFileType : fileRef.explicitFileType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not covered by testing.
I would like to add one more tip that you should always make a new branch when proposing changes to keep your Thanks @kspearrin for your efforts. |
where pbxFile extension was being set to 'undefined' and add new test case to verify the bug fix NOTE: These changes were originally part of apache#12 (cordova-node-xcode PR apache#12), extracted here by @brodybits (Christopher J. Brody). Co-authored-by: Kyle Spearrin <[email protected]> Co-authored-by: Christopher J. Brody <[email protected]>
where pbxFile extension was being set to 'undefined' and add new test case to verify the bug fix with a quick test fix by @brodybits (Christopher J. Brody) for the sake of consistency with the other test cases NOTE: These changes were originally part of #12 (cordova-node-xcode PR #12), extracted here by @brodybits. Co-authored-by: Kyle Spearrin <[email protected]> Co-authored-by: Christopher J. Brody <[email protected]>
The changes to fix the pbxFiile extension issue were merged in PR #37, with due credit given to @kspearrin. I am closing this one, raised #37 to track the other issues that should be fixed. We really cannot make the other proposed fixes without test coverage, otherwise we risk things breaking at some random time in the future. The strict equality checks will be done when we introduce the eslint updates (#36). |
This PR fixes a few issues I discovered while using this library to add an app extension to a pbxproject.
new pbxFile('AppExtension', { explicitFileType: '"wrapper.app-extension"'})
gets indirectly called when usingproj.addTarget('AppExtension', 'app_extension')
. This results in an incorrect extension being added to the basename when trying to determine the extension fromdefaultExtension
(detectType
sets it to the literal string "unknown" which fails falsey checks). The result would end up beingAppExtension.undefined
instead of the correctAppExtension.appex
. Also corrected a missingunquoted()
call in thedefaultExtension()
function which also led to the same failure.addTargetDependency()
is indirectly called as well fromproj.addTarget('AppExtension', 'app_extension')
. In my project,PBXTargetDependency
andPBXContainerItemProxy
sections did not yet exist which results in the necessary dependencies not being set up properly for building the extension with the main app. Create these sections if they do not exist.In the various functions that build out
buildSettings
, it checks for thePRODUCT_NAME
to be the same as the project's product name. This never matches if you are using these functions on the app extension, since it has a differentPRODUCT_NAME
. Allow a product name to be passed as an option to these functions.Added
showEnvVarsInLog
option topbxShellScriptBuildPhaseObj
. Passing this a false will setshowEnvVarsInLog = 0
.All tests (and the newly added) pass.