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

Give a carthage workaround for Xcode 12 #30

Merged
merged 4 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProj
}

PrepareCartfile();
// Copy the bundle Xcode 12 carthage script workaround to work path.
PrepareCarthageScriptWorkaround();
CarthageUpdate();
ConfigureXcodeForCarthage();
AddCarthageCopyPhase();
Expand Down Expand Up @@ -79,6 +81,12 @@ static void PrepareCartfile() {
file.Save();
}

static void PrepareCarthageScriptWorkaround() {
var currentDirectory = Directory.GetCurrentDirectory();
var carthageScript = Path.Combine(currentDirectory, "Assets/LineSDK/Editor/Carthage/carthage.sh");
File.Copy(carthageScript, Path.Combine(projectRoot, "carthage.sh"), true);
}

static string BundledCartfilePath {
get {
var currentDirectory = Directory.GetCurrentDirectory();
Expand All @@ -93,7 +101,7 @@ static Cartfile bundledCartfile() {
static void CarthageUpdate() {
var currentDirectory = Directory.GetCurrentDirectory();
Directory.SetCurrentDirectory(projectRoot);
var log = ShellCommand.Run("carthage", "update --cache-builds");
var log = ShellCommand.Run("sh", "carthage.sh update --platform iOS --cache-builds");
UnityEngine.Debug.Log(log);
Directory.SetCurrentDirectory(currentDirectory);
}
Expand All @@ -114,7 +122,7 @@ static void ConfigureXcodeForCarthage() {
PBXSourceTree.Source));
project.AddFileToBuild(
target,
project.AddFile("Carthage/Build/iOS/LineSDKObjC.framework", "Frameworks/LineSDKObjC.framework.framework",
project.AddFile("Carthage/Build/iOS/LineSDKObjC.framework", "Frameworks/LineSDKObjC.framework",
PBXSourceTree.Source));

project.SetBuildProperty(target, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
Expand All @@ -134,7 +142,8 @@ static void AddCarthageCopyPhase() {

Directory.SetCurrentDirectory(projectRoot);
ShellCommand.Run("gem", "install bundler --no-document");
ShellCommand.Run("bundle", "install --path vendor/bundle");
ShellCommand.Run("bundle", "config set --local path 'vendor/bundle'");
ShellCommand.Run("bundle", "install");
ShellCommand.Run("bundle", "exec ruby copy_carthage_framework.rb");
Directory.SetCurrentDirectory(currentDirectory);
}
Expand Down
19 changes: 19 additions & 0 deletions LINE_SDK_Unity/Assets/LineSDK/Editor/Carthage/carthage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# carthage.sh
# Usage example: ./carthage.sh build --platform iOS

set -euo pipefail

xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX)
trap 'rm -f "$xcconfig"' INT TERM HUP EXIT

# For Xcode 12 make sure EXCLUDED_ARCHS is set to arm architectures otherwise
# the build will fail on lipo due to duplicate architectures.

CURRENT_XCODE_VERSION=$(xcodebuild -version | grep "Build version" | cut -d' ' -f3)
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

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
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

export XCODE_XCCONFIG_FILE="$xcconfig"
carthage "$@"

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions LINE_SDK_Unity/Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
"dependencies": {
"com.unity.2d.sprite": "1.0.0",
"com.unity.2d.tilemap": "1.0.0",
"com.unity.collab-proxy": "1.2.16",
"com.unity.ide.rider": "1.1.4",
"com.unity.ide.vscode": "1.1.4",
"com.unity.multiplayer-hlapi": "1.0.4",
"com.unity.test-framework": "1.1.13",
"com.unity.timeline": "1.2.6",
"com.unity.ide.vscode": "1.2.3",
"com.unity.test-framework": "1.1.20",
"com.unity.textmeshpro": "2.0.1",
"com.unity.ugui": "1.0.0",
"com.unity.xr.legacyinputhelpers": "2.1.7",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",
Expand Down
Loading