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

(ios) Fix setting of target-device to handset in combination with plugins and resource files #546

Merged
merged 1 commit into from
Mar 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions bin/templates/scripts/cordova/lib/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ var Q = require('q');
var fs = require('fs');
var path = require('path');
var shell = require('shelljs');
var xcode = require('xcode');
var unorm = require('unorm');
var plist = require('plist');
var URL = require('url');
Expand Down Expand Up @@ -282,15 +281,15 @@ function handleBuildSettings (platformConfig, locations, infoPlist) {
var needUpdatedBuildSettingsForLaunchStoryboard = checkIfBuildSettingsNeedUpdatedForLaunchStoryboard(platformConfig, infoPlist);
var swiftVersion = platformConfig.getPreference('SwiftVersion', 'ios');

var proj = new xcode.project(locations.pbxproj); /* eslint new-cap : 0 */
var project;

try {
proj.parseSync();
project = projectFile.parse(locations);
} catch (err) {
return Q.reject(new CordovaError('Could not parse ' + locations.pbxproj + ': ' + err));
}

var origPkg = proj.getBuildProperty('PRODUCT_BUNDLE_IDENTIFIER');
var origPkg = project.xcode.getBuildProperty('PRODUCT_BUNDLE_IDENTIFIER');

// no build settings provided and we don't need to update build settings for launch storyboards,
// then we don't need to parse and update .pbxproj file
Expand All @@ -300,27 +299,27 @@ function handleBuildSettings (platformConfig, locations, infoPlist) {

if (origPkg !== pkg) {
events.emit('verbose', 'Set PRODUCT_BUNDLE_IDENTIFIER to ' + pkg + '.');
proj.updateBuildProperty('PRODUCT_BUNDLE_IDENTIFIER', pkg);
project.xcode.updateBuildProperty('PRODUCT_BUNDLE_IDENTIFIER', pkg);
}

if (targetDevice) {
events.emit('verbose', 'Set TARGETED_DEVICE_FAMILY to ' + targetDevice + '.');
proj.updateBuildProperty('TARGETED_DEVICE_FAMILY', targetDevice);
project.xcode.updateBuildProperty('TARGETED_DEVICE_FAMILY', targetDevice);
}

if (deploymentTarget) {
events.emit('verbose', 'Set IPHONEOS_DEPLOYMENT_TARGET to "' + deploymentTarget + '".');
proj.updateBuildProperty('IPHONEOS_DEPLOYMENT_TARGET', deploymentTarget);
project.xcode.updateBuildProperty('IPHONEOS_DEPLOYMENT_TARGET', deploymentTarget);
}

if (swiftVersion) {
events.emit('verbose', 'Set SwiftVersion to "' + swiftVersion + '".');
proj.updateBuildProperty('SWIFT_VERSION', swiftVersion);
project.xcode.updateBuildProperty('SWIFT_VERSION', swiftVersion);
}

updateBuildSettingsForLaunchStoryboard(proj, platformConfig, infoPlist);
updateBuildSettingsForLaunchStoryboard(project.xcode, platformConfig, infoPlist);

fs.writeFileSync(locations.pbxproj, proj.writeSync(), 'utf-8');
project.write();

return Q();
}
Expand Down Expand Up @@ -962,7 +961,7 @@ function processAccessAndAllowNavigationEntries (config) {
var allow_navigations = config.getAllowNavigations();

return allow_navigations
// we concat allow_navigations and accesses, after processing accesses
// we concat allow_navigations and accesses, after processing accesses
.concat(accesses.map(function (obj) {
// map accesses to a common key interface using 'href', not origin
obj.href = obj.origin;
Expand Down