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

Auto-run hook for Xcode project settings modifications #154

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# http://editorconfig.org
root = true

[*]
indent_style = tab
indent_size = 1
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you make these a separate commit? they have nothing to do with the commit they are currently bundled with

Copy link
Contributor Author

@derwaldgeist derwaldgeist Apr 26, 2016

Choose a reason for hiding this comment

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

Hm, TBH, I am not a Github expert (my private projects are using SVN), and I don't know how to take a commit out of an existing PR. If you don't like the additional .editorconfig, I recommend that you just delete it afterwards. It was just for the sake of convenience, to make life easier for upcoming contributors.

22 changes: 22 additions & 0 deletions .jsbeautifyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"indent_size": 1,
"indent_char": "\t",
"eol": "\n",
"indent_level": 0,
"indent_with_tabs": true,
"preserve_newlines": true,
"max_preserve_newlines": 10,
"jslint_happy": false,
"space_after_anon_function": true,
"brace_style": "collapse",
"keep_array_indentation": false,
"keep_function_indentation": false,
"space_before_conditional": true,
"break_chained_methods": false,
"eval_code": false,
"unescape_strings": false,
"wrap_line_length": 0,
"wrap_attributes": "auto",
"wrap_attributes_indent_size": 4,
"end_with_newline": true
}
42 changes: 17 additions & 25 deletions extra/hooks/iosrtc-swift-support.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
var
fs = require("fs"),
path = require("path"),
xcode = require('xcode'),

BUILD_VERSION = '9.2',
BUILD_VERSION = '9.0',
BUILD_VERSION_XCODE = '"' + BUILD_VERSION + '"',
RUNPATH_SEARCH_PATHS = '@executable_path/Frameworks',
RUNPATH_SEARCH_PATHS_XCODE = '"' + RUNPATH_SEARCH_PATHS + '"',
Expand Down Expand Up @@ -52,6 +51,7 @@ function nonComments(obj) {

module.exports = function (context) {
var
xcode = context.requireCordovaModule('xcode'),
projectRoot = context.opts.projectRoot,
projectName = getProjectName(projectRoot),
xcconfigPath = path.join(projectRoot, '/platforms/ios/cordova/build.xcconfig'),
Expand Down Expand Up @@ -101,30 +101,22 @@ module.exports = function (context) {

// "project.pbxproj"
// Parsing it
xcodeProject.parse(function (error) {
var configurations, buildSettings;

if (error) {
debugerror('an error occurred during the parsing of the project file');

return;
}


configurations = nonComments(xcodeProject.pbxXCBuildConfigurationSection());
// Adding or changing the parameters we need
Object.keys(configurations).forEach(function (config) {
buildSettings = configurations[config].buildSettings;
buildSettings.LD_RUNPATH_SEARCH_PATHS = RUNPATH_SEARCH_PATHS_XCODE;
buildSettings.SWIFT_OBJC_BRIDGING_HEADER = swiftBridgingHeadXcode;
buildSettings.IPHONEOS_DEPLOYMENT_TARGET = BUILD_VERSION_XCODE;
buildSettings.ENABLE_BITCODE = ENABLE_BITCODE_XCODE;
});

// Writing the file again
fs.writeFileSync(xcodeProjectPath, xcodeProject.writeSync(), 'utf-8');
debug('file correctly fixed: ' + xcodeProjectPath);
xcodeProject.parseSync();
var configurations, buildSettings;

configurations = nonComments(xcodeProject.pbxXCBuildConfigurationSection());
// Adding or changing the parameters we need
Object.keys(configurations).forEach(function (config) {
buildSettings = configurations[config].buildSettings;
buildSettings.LD_RUNPATH_SEARCH_PATHS = RUNPATH_SEARCH_PATHS_XCODE;
buildSettings.SWIFT_OBJC_BRIDGING_HEADER = swiftBridgingHeadXcode;
buildSettings.IPHONEOS_DEPLOYMENT_TARGET = BUILD_VERSION_XCODE;
buildSettings.ENABLE_BITCODE = ENABLE_BITCODE_XCODE;
});

// Writing the file again
fs.writeFileSync(xcodeProjectPath, xcodeProject.writeSync(), 'utf-8');
debug('file correctly fixed: ' + xcodeProjectPath);
};


Expand Down
3 changes: 3 additions & 0 deletions extra/ios-websocket-hack.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@
};

FakeWebSocket.prototype.close = function (code, reason) {
if (!this.ws) {
return;
}
if (!code && !reason) {
this.ws.close();
} else if (code && !reason) {
Expand Down
1 change: 1 addition & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</engines>

<platform name="ios">
<hook type="after_prepare" src="extra/hooks/iosrtc-swift-support.js" />
<config-file target="config.xml" parent="/*">
<feature name="iosrtcPlugin">
<param name="ios-package" value="iosrtcPlugin" />
Expand Down