Skip to content

Commit

Permalink
port dpa99c#25
Browse files Browse the repository at this point in the history
  • Loading branch information
ewfian committed Jul 9, 2020
1 parent 901d3a2 commit f4029d8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
4 changes: 4 additions & 0 deletions scripts/after_prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ module.exports = function (context) {
if (platforms.indexOf('ios') !== -1 && utilities.directoryExists(IOS_DIR)) {
console.log('Preparing Firebase on iOS');
utilities.copyKey(PLATFORM.IOS);

var helper = require("./ios/helper");
var xcodeProjectPath = helper.getXcodeProjectPath();
helper.ensureRunpathSearchPath(context, xcodeProjectPath);
}
if (platforms.indexOf('android') !== -1 && utilities.directoryExists(ANDROID_DIR)) {
console.log('Preparing Firebase on Android');
Expand Down
41 changes: 40 additions & 1 deletion scripts/ios/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,44 @@ module.exports = {

// Finally, write the .pbxproj back out to disk.
fs.writeFileSync(xcodeProjectPath, xcodeProject.writeSync());
}
},

ensureRunpathSearchPath: function(context, xcodeProjectPath) {

function addRunpathSearchBuildProperty(proj, build) {
let LD_RUNPATH_SEARCH_PATHS = proj.getBuildProperty("LD_RUNPATH_SEARCH_PATHS", build);

if (!Array.isArray(LD_RUNPATH_SEARCH_PATHS)) {
LD_RUNPATH_SEARCH_PATHS = [LD_RUNPATH_SEARCH_PATHS];
}

LD_RUNPATH_SEARCH_PATHS.forEach(LD_RUNPATH_SEARCH_PATH => {
if (!LD_RUNPATH_SEARCH_PATH) {
proj.addBuildProperty("LD_RUNPATH_SEARCH_PATHS", "\"$(inherited) @executable_path/Frameworks\"", build);
}
if (LD_RUNPATH_SEARCH_PATH.indexOf("@executable_path/Frameworks") == -1) {
var newValue = LD_RUNPATH_SEARCH_PATH.substr(0, LD_RUNPATH_SEARCH_PATH.length - 1);
newValue += ' @executable_path/Frameworks\"';
proj.updateBuildProperty("LD_RUNPATH_SEARCH_PATHS", newValue, build);
}
if (LD_RUNPATH_SEARCH_PATH.indexOf("$(inherited)") == -1) {
var newValue = LD_RUNPATH_SEARCH_PATH.substr(0, LD_RUNPATH_SEARCH_PATH.length - 1);
newValue += ' $(inherited)\"';
proj.updateBuildProperty("LD_RUNPATH_SEARCH_PATHS", newValue, build);
}
});
}

// Read and parse the XCode project (.pxbproj) from disk.
// File format information: http://www.monobjc.net/xcode-project-file-format.html
var xcodeProject = xcode.project(xcodeProjectPath);
xcodeProject.parseSync();

// Add search paths build property
addRunpathSearchBuildProperty(xcodeProject, "Debug");
addRunpathSearchBuildProperty(xcodeProject, "Release");

// Finally, write the .pbxproj back out to disk.
fs.writeFileSync(path.resolve(xcodeProjectPath), xcodeProject.writeSync());
},
};

0 comments on commit f4029d8

Please sign in to comment.