Skip to content

Instantly share code, notes, and snippets.

@sburlot
Created April 6, 2013 23:34
Show Gist options
  • Save sburlot/5328122 to your computer and use it in GitHub Desktop.
Save sburlot/5328122 to your computer and use it in GitHub Desktop.
Add a Run Script phase to your Xcode project and add this script to detect if you use autolayout in your 5.x target
#!/usr/bin/perl
#
# Check if we're running for 5.1 deployment and any .xib view has autolayout on.
#
use File::Find qw(find);
my $deployment = $ENV{'IPHONEOS_DEPLOYMENT_TARGET'};
my $project_dir = $ENV{'PROJECT_DIR'};
print "Deploy to $deployment\n";
print "Project is $project_dir\n";
# check if deployment target is 6.x
if ($deployment =~ "^6") {
exit 0;
}
my @xib_files;
# find all xib files
find ({ wanted => sub { /^.*\.xib\z/s && push @xib_files, $_ } , no_chdir => 1 }, $project_dir);
$has_error = 0;
for my $file (@xib_files) {
local $/=undef;
open FILE, $file || die "Cant open $file";
$data = <FILE>;
close FILE;
(($has_error = 1) && print "error: $file has autolayout\n") if ($data =~ /UseAutolayout\">YES/m);
}
if ($has_error) {
exit 1;
}
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment