How do we manually fix "ResourceRules.plist: cannot read resources" error after xcode 6.1 upgrade? - xcode

We are having the same issue found here, here, here and here
Basically we upgraded to xcode 6.1 and our build are getting the "ResourceRules.plist: cannot read resources" error.
We have a Jenkins server that does our ios builds for us. We are using the Xcode plugin on Jenkins to do the actual build and signing. Any thoughts on how we can make this change without manually opening xcode and doing this solution found on the other answers:
Click on your project > Targets > Select your target > Build Settings >
Code Signing Resource Rules Path
and add :
$(SDKROOT)/ResourceRules.plist
I'm very new to Xcode and iOS build in general. I have found the project.pbxproj file inside the Unity-iPhone.xcodeproj file. It looks like this contains the build settings under the /* Begin XCBuildConfiguration section */ section it lists what looks like similar build properties foundin Xcode, however I do not see anything like "Code Signing Resource Rules Path".
Does anyone have experience manually editing this file? Is that a bad idea in general?
Thanks

If you're using Jenkins with the XCode plugin, you can modify the 'Code Signing Resource Rules Path' variable by adding:
"CODE_SIGN_RESOURCE_RULES_PATH=$(SDKROOT)/ResourceRules.plist"
to the
'Custom xcodebuild arguments' setting for the XCode plugin.
This fix does not require the XCode GUI.

I encountered the same problem. Nicks solution does work, but is requiring additional dependencies. You don't need the heavy-handed npm xcode module for this. Just add a line to this file:
$PROJECT_ROOT/platforms/ios/cordova/build.xcconfig
CODE_SIGN_RESOURCE_RULES_PATH=$(SDKROOT)/ResourceRules.plist
Note that before XCode 6.1.1, this needed to be specified as "$(SDKROOT)/ResourceRules.plist" (notice the quotes).
If you are running this inside automated build systems such as Jenkins and wont't/can't use any XCode GUI, just create a small Cordova hook, leveraging npm's fs.appendFile, at this location:
$PROJECT_ROOT/hooks/before_build/ios_resourcerules.js (make sure it has chmod +x)
#! /usr/local/bin/node
var fs = require("fs");
fs.appendFileSync('build.xcconfig', '\nCODE_SIGN_RESOURCE_RULES_PATH = $(SDKROOT)/ResourceRules.plist', function (err) {
if (err) throw err;
console.log('CODE_SIGN_RESOURCE_RULES_PATH added to Cordova iOS build configuration.');
});
This will might be merged in an upcoming Cordova release, so the hook will become unnecessary (i'm creating a see this PR for Cordova-iOS).
In case the above JavaScript snippet fails to execute due to a "wrong argument" failure, replace the file's content as follows:
#!/bin/bash
if [ ! -f ./build.xcconfig ]; then
echo "[ERROR] hook befor_build/ios_resourcerules.sh cannot execute, ./build/xcconfig not found in $PWD"
exit 1
fi
echo '// (CB-7872) Solution for XCode 6.1 signing errors related to resource envelope format deprecation' >> ./build.xcconfig
echo 'CODE_SIGN_RESOURCE_RULES_PATH=$(SDKROOT)/ResourceRules.plist' >> ./build.xcconfig
echo 'CODE_SIGN_RESOURCE_RULES_PATH added to Cordova iOS build configuration.'

If you want to get really crazy, you can directly update PackageApplication.
# In /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication
my #codesign_args = ("/usr/bin/codesign", "--force", "--preserve-metadata=identifier,entitlements,resource-rules",
"--sign", $opt{sign},
"--resource-rules=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/ResourceRules.plist");
# OLD: "--resource-rules=$destApp/ResourceRules.plist");
I was already hacking this script to accept a keychain arg, so it made sense for me. Note I'm not using the Xcode Jenkins plugin -- I'm using Jenkins but running all the build commands from a script.

After the new release of XCode 7 on 23rd Sept 2015, Apple started rejecting any application that is using CODE_SIGN_RESOURCE_RULES_PATH, making the Jenkins build automatically rejected. However, setting CODE_SIGN_RESOURCE_RULES_PATH=$(SDKROOT)/ResourceRules.plist into the Custom xcodebuild arguments causes a build failure.
This answer resolved the issue: https://stackoverflow.com/a/32762413/5373468
This is clearly a bug that Apple forgot to fix a while ago, as this article is also highlighting: http://cutting.io/posts/packaging-ios-apps-from-the-command-line/

I had EXACTLY the same problem, as you have. We are building our iOS app on Jenkins, so we couldn't manually set "Code Signing Resource Rules Path".
I have wrote a small NodeJS file which does the job for me (see the code below).
The script use a nice NodeJS package called xcode which helps me with the parsing of the xcode.xcodeproj file.
I don't know if you are using Cordova/Phonegap or what you are using, but if you are can just copy the code and make a Cordova hook. If not I'm sure you can execute the file from Jenkins, with some small changes.
Anyways, I hope this script will help you:
#!/usr/bin/env node
var CODE_SIGN_RESOURCE_RULES_PATH = '"$(SDKROOT)/ResourceRules.plist"';
var fs = require("fs");
var path = require("path");
var xcode = require('xcode');
var projectRoot = process.argv[2];
function getProjectName(protoPath) {
var cordovaConfigPath = path.join(protoPath, 'www', 'config.xml');
var content = fs.readFileSync(cordovaConfigPath, 'utf-8');
return /<name>([\s\S]*)<\/name>/mi.exec(content)[1].trim();
}
function run(projectRoot) {
var projectName = getProjectName(projectRoot);
var xcodeProjectName = projectName + '.xcodeproj';
var xcodeProjectPath = path.join(projectRoot, 'platforms', 'ios', xcodeProjectName, 'project.pbxproj');
var xcodeProject;
if (!fs.existsSync(xcodeProjectPath)) {
return;
}
xcodeProject = xcode.project(xcodeProjectPath);
console.log('Setting Code Sign Resource Rules Path for ' + projectName + ' to: [' + CODE_SIGN_RESOURCE_RULES_PATH + '] ...');
xcodeProject.parse(function(error){
if(error){
console.log('An error occured during parsing of [' + xcodeProjectPath + ']: ' + JSON.stringify(error));
}else{
var configurations = nonComments(xcodeProject.pbxXCBuildConfigurationSection());
for (config in configurations) {
var buildSettings = configurations[config].buildSettings;
buildSettings['CODE_SIGN_RESOURCE_RULES_PATH'] = CODE_SIGN_RESOURCE_RULES_PATH;
}
fs.writeFileSync(xcodeProjectPath, xcodeProject.writeSync(), 'utf-8');
console.log('[' + xcodeProjectPath + '] now has Code Signing Resource Rules Path set to:[' + CODE_SIGN_RESOURCE_RULES_PATH + '] ...');
}
});
}
var COMMENT_KEY = /_comment$/;
function nonComments(obj) {
var keys = Object.keys(obj),
newObj = {}, i = 0;
for (i; i < keys.length; i++) {
if (!COMMENT_KEY.test(keys[i])) {
newObj[keys[i]] = obj[keys[i]];
}
}
return newObj;
}
run(projectRoot);

We are using Unity + Jenkins for auto builds.
You can achieve with post process cs scripts; however; for quick (and dirty fix) you can apply following bash command after Unity but before xcode:
sed -i '' 's/CONFIGURATION_BUILD_DIR/CODE_SIGN_RESOURCE_RULES_PATH = "\$(SDKROOT)\/ResourceRules\.plist";\'$'\n CONFIGURATION_BUILD_DIR/g' /Users/admin/Jenkins/workspace/PROJECTNAME/Build/PROJECTNAME/Unity-iPhone.xcodeproj/project.pbxproj

Related

meanjs best practice to setup process evn for database

In my attempt to get a 'hello world' skill with meanjs.org product, I cloned 0.4.2 and setup a mongolab account.
I opened > config > env > development.js, to setup db URL, where I have this:
db: {
uri: process.env.MONGOHQ_URL || process.env.MONGOLAB_URI || 'mongodb://' + (process.env.DB_1_PORT_27017_TCP_ADDR || 'localhost') + '/mean-dev',
For trial, I simply replaced process.env.MONGOLAB_URI with my URL from mongolab and everthing worked for sure, but I doubt this is the way to go. I see a Procfile there, may be I should specify the process.env.MONGOLAB_URI there? Where I could specify it, so that if I upload it to Heroku, say, it will setup the process.env.MONGOLAB_URI and no edit will be needed here please?
p.s. I googled and searched SOF
Well just a small progress,
I got to my gulpfile.js and setup a task as:
gulp.task('setmydb', function () {
process.env.MONGOLAB_URI =
'mongodb://mylogin:mypassword#ds157479.mlab.com:57479/meantst1';
});
Then at the end of the file, added into the task sequence:
// Run the project in development mode
gulp.task('default', function (done) {
runSequence('env:dev', 'lint', ['setmydb','nodemon', 'watch'], done);
});
Well it worked, but I'm still not sure if this indeed is how it must be done! So please help me get sure.
Just in case if someone else also needed, this is how I solved my problem:
Setting configuration variables | Heroku
I first followed the Heroku getting started and edited their app there, added this root:
app.get('/envtst', function(request, response) {
var xterm = process.env.XVAR ==='yes' ? 'yes' : 'no';
response.send(xterm);
});
Then pushed the app to Heroku and also setup my test variable XVAR via command line:
heroku config:set XVAR=yes
finally, opened the root in browser and verified.

WebEssentials tslint custom rules

I have a tslint.json file in my solution directory and I'm trying to create a custom rule following the guidelines on https://www.npmjs.com/package/tslint
I have created a "nonImportsRule.ts", have copied the code from the link and have added "no-imports": true to my tslint.json file however the rule is not being picked up.
The guide says that a rulesDirectory needs to be specified, but I have no idea where this should be configured?
Also - is it possible to setup Web Essentials to break the build if tslint rules are violated?
I had a same kind of a problem. I wanted to use the TSLint extensions, tslint-microsoft-contrib and codelyzer, together with Web Analyzer. This did not work. The first step to figure out why was to make an adaptation in server.js which can be found in C:\Users\[User]\AppData\Local\Temp\WebAnalyzer1.7.75. I changed the TSLint function into:
tslint: function (configFile, files) {
// Try catch tslint errors
try {
var tslint = require("tslint");
var options = {
formatter: "json",
configuration: JSON.parse(fs.readFileSync(configFile, "utf8").trim())
};
var results = [];
for (var i = 0; i < files.length; i++) {
var file = files[i];
var ll = new tslint(file, fs.readFileSync(file, "utf8"), options);
results = results.concat(JSON.parse(ll.lint().output));
}
} catch(error) {
// Return tslint error to visual studio so we can get some ideas for counter measures.
var result = JSON.parse('[{"endPosition": {"character": 0,"line": 0,"position": 0},"failure": "INSTALL ERROR","name": "/","ruleName": "INSTALL ERROR","startPosition": {"character": 0,"line": 0,"position": 0}}]');
result[0].failure = error.message;
return result;
}
return results;
},
The alternation resulted in error feedback in the visual studio error list when I run the Web Analyzer. Do not forget to force a new instance of node.exe with the task manager after you have applied the alternation. The feedback leaded, for my particular situation, to the following installation of npm packages in the following directories:
Packages:
"codelyzer": "0.0.12"
"tslint": "^3.7.3"
"tslint-microsoft-contrib": "^2.0.2"
"typescript": "^1.8.9"
Directories:
C:\Users\[User]\AppData\Local\Temp\WebAnalyzer1.7.75
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
After this, Web Analyzer was able to use the same tslint rules as my grunt task. Hopefully a newer version of Web Analyzer will solve my problems more elegantly.
Okay, i'm not using Web Essentials extension but Web Analyzer : https://visualstudiogallery.msdn.microsoft.com/6edc26d4-47d8-4987-82ee-7c820d79be1d
So i won't be able to answer on this question 100%, but i want to summarize here my experience with custom tslint rules. First of all, what is not completely clear from documentation is that the whole thing depends on node.js.
So first of all you need to install node js. This will give you npm command to your command line.
After install with npm tslint and typescript. https://github.com/palantir/tslint here are examples. These will create files in : "c:\Users[Username]\AppData\Roaming\npm\node_modules"
Go into "c:\Users[Username]\AppData\Roaming\npm\node_modules\tslint\lib\rules\". Create here noImportRule.ts. Copy the following content:
import * as ts from "typescript";
import * as Lint from "../lint";
export class Rule extends Lint.Rules.AbstractRule {
public static FAILURE_STRING = "import statement forbidden EDE";
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
return this.applyWithWalker(new NoImportsWalker(sourceFile, this.getOptions()));
}
}
// The walker takes care of all the work.
class NoImportsWalker extends Lint.RuleWalker {
public visitImportDeclaration(node: ts.ImportDeclaration) {
// create a failure at the current position
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING));
// call the base version of this visitor to actually parse this node
super.visitImportDeclaration(node);
}
}
Note that in the example import lint is not given with relative path that won't work with this approach.
4. Fire the command : "tsc -m commonjs --noImplicitAny .\noImportsRule.ts". This will compile your custom rule's ts. You will get bunch of compilation errors, such as: ../enableDisableRules.d.ts(1,21): error TS2307: Cannot find module 'typescript'. That's a good question why are these thrown, but forget about them, js file will be generated anyway.
5. Put "no-imports": true to your tslint.json(for now this should be custom one). With this command from command line:
tslint -c 'sample.tslint.json' test.ts
you will get:
test.ts[1, 1]: import statement forbidden. So you made the custom rule working!!! :)
That's all for working from command line. In addition I made custom rules working with WebAnalyzer, at least temporary.
I needed to copy my custom rule's files here:
c:\Users[Username]\AppData\Local\Temp\WebAnalyzer1.6.65\node_modules\tslint\lib\rules\ and of course configure WebAnalyzer tslint.json to include custom rules.
I have no idea how Web Essentials extension makes this whole thing working with tslint, but i guess some way similar :). Somewhere there should be a folder (node_modules\tslint\lib\rules) with rules what tslint uses. There you need to copy your custom ones.
Of course the most elegant solution would be to modify Web Essentials extension itself and make the tslint's custom rules directory configurable from visual studio. (so my solution is just a workaround)
Here is my custom rule example in the visual studio warning's list:

Meteor and graphicsMagic on Windows

I'm trying to run meteor app developed under MacOS on Windows.
Have this problem:
WARNING: cfs:graphicsmagick could not find "graphicsMagic" or
"imageMagic" on the system.
I just checked PATH to see if I could find the GraphicsMagick or
ImageMagic unix/mac os/windows binaries on your system, I failed.
Why:
1. I may be blind or naive, help making me smarter
2. You havent added the path to the binaries
3. You havent actually installed GraphicsMagick or ImageMagick
* Make sure "$PATH" environment is configured "PATH:/path/to/binaries" *
Installation hints:
* Mac OS X "brew install graphicsmagick" or "brew install imagemagick"
* Linux download rpm or use packagemanager
* Centos "yum install GraphicsMagick"* Windows download the installer and run
I've installed GraphicsMagick and ImageMagic, checked PATH.
In cmd gm command runs GraphicsMagick, but still this problem remain in meteor.
The cfs:graphicsmagick module is designed to work on windows. This is the script that looks for graphicsmagick. I've modified it to work with node and increased the verbosity to help you debug the issue:
var graphicsmagick = false;
var imagemagick = false;
var fs = require("fs"); //or Npm.require("fs") if you're running this script with meteor
// Split the path by : for linux
// Split the path by ; for windows
var sep = /^win/.test(process.platform) ? ';' : ':';
var binaryPaths = process.env['PATH'].split(sep);
// XXX: we should properly check if we can access the os temp folder - since
// gm binaries are using this and therefore may fail?
// XXX: we could push extra paths if the `gm` library check stuff like:
// $MAGIC_HOME The current version does not check there
// $MAGICK_HOME (GraphicsMagick docs)
// We check to see if we can find binaries
for (var i = 0; i < binaryPaths.length; i++) {
var binPath = binaryPaths[i];
console.log("Looking in", binPath)
// If we have not found GraphicsMagic
if (!graphicsmagick) {
// Init
var gmPath = path.join(binPath, 'gm');
var gmExePath = path.join(binPath, 'gm.exe');
// Check to see if binary found
graphicsmagick = fs.existsSync(gmPath) || fs.existsSync(gmExePath);
// If GraphicsMagic we dont have to check for ImageMagic
// Since we prefer GrapicsMagic when selecting api
if (!graphicsmagick && !imagemagick) {
// Init paths to check
var imPath = path.join(binPath, 'convert');
var imExePath = path.join(binPath, 'convert.exe');
// Check to see if binary found
imagemagick = fs.existsSync(imPath) || fs.existsSync(imExePath);
}
}
}
console.log("Found GraphicsMagick", graphicsmagick)
console.log("Found ImageMagick", imagemagick)
When you run it it will give you a path that it is looking in, in the through all PATH variables from the environment variable.
Look for the imagemagick installation you have and check that it matches up. If you run the script with Meteor make sure to change Npm.require("fs") from require('fs').
The check is very thorough looking for the gm.exe or convert.exe, if you have it installed you will have to find out why it is not being detected.

self hosted vnext application

I was wondering if I could refactor a self-hosted app (console app that starts and displays the URL of the webservices it provides) for it to work on pure vnext instead of owin.
The owin code is the following
namespace Selfhostingtest
{
class Program
{
static void Main(string[] args)
{
String strHostName = string.Empty;
strHostName = Dns.GetHostName();
Console.WriteLine("Local Machine's Host Name: " + strHostName);
var options = new StartOptions();
IPHostEntry ipEntry = Dns.GetHostEntry(strHostName);
IPAddress[] addr = ipEntry.AddressList;
for (int i = 0; i < addr.Length; i++)
{
if (!addr[i].IsIPv6LinkLocal && addr[i].AddressFamily == AddressFamily.InterNetwork)
{
Console.WriteLine("IPv4 Address {0}: {1} ", i, addr[i].ToString());
options.Urls.Add(String.Format("http://{0}:5000/", addr[i].ToString()));
}
}
using (WebApp.Start<Startup>(options))
{
Console.WriteLine("Razor server is running. Press enter to shut down...");
Console.ReadLine();
}
}
}
}
For the record, I don't want to use the "k web" command line start. I want to fully package the vnext app as an executable file.
Instead of Microsoft.Owin.Hosting, the Microsoft.AspNet.Hosting should be used (same class as in the "k web" command definition. Keep in mind that Owin Startup expects IAppBuilder and the vnext expects IBuilder.
In ASP.NET vNext you cannot build an EXE file, but you can definitely package up an app to be self-contained. Check out the kpm pack command that you can run in your app's folder. It will package up all the dependencies as well as generate the command scripts that you can use (instead of using k web etc.). Ultimately if you look at what k web does, it's just some shell scripts that end up running klr.exe with various parameters to indicate what it should start.
The project wiki has some basic information on the kpm tool's various options: https://github.com/aspnet/Home/wiki/Package-Manager
Here is the command line help for kpm pack to give you an idea of what it can do.
Usage: kpm pack [arguments] [options]
Arguments:
[project] Path to project, default is current directory
Options:
-o|--out <PATH> Where does it go
--configuration <CONFIGURATION> The configuration to use for deployment
--overwrite Remove existing files in target folders
--no-source Don't include sources of project dependencies
--runtime <KRE> Names or paths to KRE files to include
--appfolder <NAME> Determine the name of the application primary folder
-?|-h|--help Show help information

JavaFX. How to run processing from terminal OSX

EDITED:----
I need to batch process a number of processing sketch files from my JavaFX application. The following code, below, works on Windows. I would like to get it running on a Mac, but not sure how.
My workflow is as follows:
//as the user for the processing-java.exe file
processingJavaProrgramFile = fileChooser.showOpenDialog(stage);
if (processingJavaProrgramFile != null) {
processingJavaProrgramPath = processingJavaProrgramFile.getPath();
}
//ask the user for the processing sketch folder
processingSketchDir = directoryChooser.showDialog(stage);
if (processingSketchDir != null) {
sketchPath = processingSketchDir.getPath();
}
//java run time exec method to compile sketch in user folder using through processing-java.exe
Runtime.getRuntime().exec(
processingJavaProrgramPath +
" --force --run --sketch=" +
sketchPath + " --output=" +
sketchPath+File.separator +
"temp"
);
How do I get it to run on Mac? For one, the Mac version does not have a processing-java.exe. Should it be a different workflow? If so, how do I let the application know whether it is running on a Windows or a Mac OS so that it runs the appropriate method?
Ok found the solution to both my questions.
To get the OS type, I used method here
To run processing with same code on the mac, I need to:
from processing, go to tools menu and install "processing-java". This install it into the system somehow. So in the Mac case, users do not need to select the path where processing-java is like in Windows (select the processing-java.exe). On the mac, users would only need to select the output folder.

Resources