Skip to content

Commit a3606ca

Browse files
committed
Add recommended workaround for broken carthage on Xcode 12
1 parent 392b171 commit a3606ca

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

repository_rules/framework_builder.bzl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,30 @@ def build_carthage_frameworks(
101101
verbose: if true, it will show the output of running carthage in the command line
102102
"""
103103

104+
# Workaround for carthage failing on Xcode 12
105+
# https://github.com/Carthage/Carthage/blob/master/Documentation/Xcode12Workaround.md
106+
#
107+
carthage_xc12_workaround = """
108+
xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX)
109+
trap 'rm -f "$xcconfig"' INT TERM HUP EXIT
110+
111+
# For Xcode 12 make sure EXCLUDED_ARCHS is set to arm architectures otherwise
112+
# the build will fail on lipo due to duplicate architectures.
113+
114+
CURRENT_XCODE_VERSION=$(xcodebuild -version | grep "Build version" | cut -d' ' -f3)
115+
echo "EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200__BUILD_$CURRENT_XCODE_VERSION = arm64 arm64e armv7 armv7s armv6 armv8" >> $xcconfig
116+
117+
echo 'EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200 = $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200__BUILD_$(XCODE_PRODUCT_BUILD_VERSION))' >> $xcconfig
118+
echo 'EXCLUDED_ARCHS = $(inherited) $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_$(EFFECTIVE_PLATFORM_SUFFIX)__NATIVE_ARCH_64_BIT_$(NATIVE_ARCH_64_BIT)__XCODE_$(XCODE_VERSION_MAJOR))' >> $xcconfig
119+
120+
export XCODE_XCCONFIG_FILE="$xcconfig"
121+
"""
104122
_prebuilt_frameworks_importer(
105123
implementation = _carthage_impl,
106124
name = name,
107125
directory = directory,
108126
files = files,
109-
cmd = cmd % (carthage_version, git_repository_url),
127+
cmd = (carthage_xc12_workaround + cmd) % (carthage_version, git_repository_url),
110128
timeout = timeout,
111129
verbose = verbose,
112130
)

tests/ios/unit-test/test-imports-app/BUILD.bazel

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ ios_application(
2020
"main.m",
2121
],
2222
bundle_id = "com.example.TestImports-App",
23-
families = ["ipad"],
23+
families = [
24+
"ipad",
25+
"iphone",
26+
],
2427
minimum_os_version = "12.0",
2528
module_name = "TestImports_App",
2629
resource_bundles = {"ResourceBundle": glob(

tests/ios/xcodeproj/Test-Imports-App-Project.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@
396396
PRODUCT_BUNDLE_IDENTIFIER = "com.example.TestImports-App";
397397
PRODUCT_NAME = "TestImports-App";
398398
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "\"$(inherited)\"";
399-
TARGETED_DEVICE_FAMILY = 2;
399+
TARGETED_DEVICE_FAMILY = "2,1";
400400
};
401401
name = Release;
402402
};
@@ -421,7 +421,7 @@
421421
PRODUCT_BUNDLE_IDENTIFIER = "com.example.TestImports-App";
422422
PRODUCT_NAME = "TestImports-App";
423423
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "\"$(inherited)\"";
424-
TARGETED_DEVICE_FAMILY = 2;
424+
TARGETED_DEVICE_FAMILY = "2,1";
425425
};
426426
name = Debug;
427427
};

tests/macos/xcodeproj/Test-Target-With-Test-Host-Project.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@
463463
PRODUCT_BUNDLE_IDENTIFIER = "com.example.TestImports-App";
464464
PRODUCT_NAME = "TestImports-App";
465465
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "\"$(inherited)\"";
466-
TARGETED_DEVICE_FAMILY = 2;
466+
TARGETED_DEVICE_FAMILY = "2,1";
467467
};
468468
name = Debug;
469469
};
@@ -536,7 +536,7 @@
536536
PRODUCT_BUNDLE_IDENTIFIER = "com.example.TestImports-App";
537537
PRODUCT_NAME = "TestImports-App";
538538
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "\"$(inherited)\"";
539-
TARGETED_DEVICE_FAMILY = 2;
539+
TARGETED_DEVICE_FAMILY = "2,1";
540540
};
541541
name = Release;
542542
};

0 commit comments

Comments
 (0)