EddyVerbruggen / nativescript-localize

Internationalization plugin for NativeScript using native capabilities of each platform
MIT License
79 stars 31 forks source link

fix(ios): CFBundle plist properties are no longer modified via hooks #100

Closed NathanWalker closed 3 years ago

EddyVerbruggen commented 3 years ago

@NathanWalker Hmm, this kills the possibility to have a different app name (on your iOS Home screen) per language (by changing CFBundleDisplayName and CFBundleName). I know of a few folks (including myself) using that feature. Is there still a way to do so?

bmacdonald commented 3 years ago

@EddyVerbruggen @NathanWalker I think you might just be able to remove setting the CFBundleName and leave the display name. Otherwise, NS will hang during the build because the CFBundleName does not match the ${PRODUCT_NAME} deep down in the nativescript cli build process.

EddyVerbruggen commented 3 years ago

@bmacdonald That compromise would work for me.

bmacdonald commented 3 years ago

@EddyVerbruggen To give some background, the build process has broken in xcode 12. We use the localize plugin and found that when it sets the app.name in the plist, the .ipa name doesn't match what the nativescript build is expecting.

app.name = Example Name;

For example:

<key>CFBundleDisplayName</key>
<string>Example Name</string>
<key>CFBundleName</key>
<string>Example Name</string>

This will create an .ipa named "Example Name.ipa". However, I do believe the build process is expecting an ipa with the same name as the folder / project. If the folder name is myworkspace, the ipa it tries to push to the device is "myworkspace.ipa" and it is not found.

What I don't know is if this was a change by xcode to start recognizing the CFBundleName property or not. It does impact CLI 6.8, so I know it was not a nativescript change.

In this issue: https://github.com/NativeScript/NativeScript/issues/8867

@rigor789 - mention the physical device changes were a work in progress.

Maybe we wait and see what changes? I do not want to break any plugins. Especially with all of the hard work you have put into them.

Here is the trace info from the build:

No .ipa found in /xxxxxxx/platforms/ios/build/Debug-iphoneos directory.
Unable to apply changes on device: XXXXXXXXXXXXX. Error is: No .ipa found in /xxxxxxx/platforms/ios/build/Debug-iphoneos directory..
Error: No .ipa found in /xxxxxxx/platforms/ios/build/Debug-iphoneos directory.
    at Errors.failWithOptions (/usr/local/lib/node_modules/nativescript/lib/common/errors.js:157:27)
    at Errors.fail (/usr/local/lib/node_modules/nativescript/lib/common/errors.js:130:21)
    at BuildArtefactsService.getLatestApplicationPackage (/usr/local/lib/node_modules/nativescript/lib/services/build-artefacts-service.js:73:26)
    at BuildArtefactsService.<anonymous> (/usr/local/lib/node_modules/nativescript/lib/services/build-artefacts-service.js:26:45)

I do believe the code is failing at BuildArtefactsService.getLatestApplicationPackage.

One more thing, would changing the CFBundleName have an impact?

NathanWalker commented 3 years ago

@EddyVerbruggen @bmacdonald pushed up adjustment to only modify display name. It seems that modifying the CFBundlleName alone could be problematic so if no particular reason to modify anything other than just display name then this should be good here now.

NathanWalker commented 3 years ago

@bmacdonald possible to manually modify the hook in your app per the changeset here and determine if it resolves the issue specifically you had seen to be absolutely certain?

bmacdonald commented 3 years ago

@NathanWalker

I changed my CFBundleName to this:

    <key>CFBundleName</key>
    <string>${PRODUCT_NAME}</string>

Opened this file and changed it:

/node_modules/nativescript-localize/hooks/converter.ios.js

if (key === "app.name") {
    infoPlistStrings.set("CFBundleDisplayName", value);
    // infoPlistStrings.set("CFBundleName", value);
}
else if (key.startsWith("ios.info.plist.")) {
    infoPlistStrings.set(key.substr(15), value);
}

The .ipa not found does stop happening.

bmacdonald commented 3 years ago

One thing to note: If developers have manually changed their CFBundleName outside of the plugin, they will get the .ipa error.

NathanWalker commented 3 years ago

Excellent thanks for confirming @bmacdonald 🤗

bmacdonald commented 3 years ago

@NathanWalker @EddyVerbruggen

Thank you both for your time. My focus has been switched to helping out nativescript to work through the xcode 12 / iOS14 issues. Please reach out to me if you need more testing on various parts. Anything at all....

EddyVerbruggen commented 3 years ago

You guys are wonderful, thank you!

Version 4.2.2 has now been published to npm.