forked from yapstudios/YapDatabase
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFastfile
61 lines (53 loc) · 2.53 KB
/
Fastfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
default_platform(:ios)
platform :ios do
desc "Creates a zip archive containing a compiled YapDatabase XCFramework with iOS, iOS Simulator, and Mac Catalyst slices."
lane :build_xcframework do
BUILD_DIR = "./build"
MODULE_NAME = "YapDatabase"
build_destinations = {
"iOS": "generic/platform=iOS",
"iOS Simulator": "generic/platform=iOS Simulator",
"Mac Catalyst": "generic/platform=macOS,variant=Mac Catalyst,name=Any Mac",
}
build_destinations.each do |platform, destination|
archive_for_xcframework(
destination: destination,
archive_path: "#{BUILD_DIR}/#{MODULE_NAME}-#{platform}.xcarchive",
)
end
# This is necessary due to a Swift compiler bug that emits an invalid interface when the module name shares a name
# with a public type. See https://github.com/apple/swift/issues/56573
shell_command =
# List paths of all .swiftinterface files containing <MODULE_NAME>.* prefix.
"grep -rli \"#{MODULE_NAME}.*\" ../#{BUILD_DIR}/#{MODULE_NAME}-*.xcarchive/Products/Library/Frameworks/#{MODULE_NAME}.framework/Modules/#{MODULE_NAME}.swiftmodule/*.swiftinterface" +
# Replace grep output newlines with NULL bytes
" | tr \\\\n \\\\0" +
# Remove <MODULE_NAME>. prefix from all identifiers. (using NULL byte as delimiter, for `xargs` to properly to handle paths with spaces).
" | xargs -0 sed -E -i '' \"s/#{MODULE_NAME}\\.([^ ]*)/\\1/g\""
# Note: `sh` function's working directory is [root]/fastlane.
# See https://docs.fastlane.tools/advanced/fastlane/#directory-behavior
sh(shell_command)
create_xcframework(
frameworks: build_destinations.keys.map { |platform|
"#{BUILD_DIR}/#{MODULE_NAME}-#{platform}.xcarchive/Products/Library/Frameworks/#{MODULE_NAME}.framework"
},
output: "#{BUILD_DIR}/#{MODULE_NAME}.xcframework"
)
zip(
path: "#{BUILD_DIR}/#{MODULE_NAME}.xcframework",
output_path: "#{BUILD_DIR}/#{MODULE_NAME}.xcframework.zip"
)
end
desc "Helper lane for creating an XCArchive for the specified destination."
private_lane :archive_for_xcframework do |options|
xcodebuild(
archive: true,
project: "YapDatabase.xcodeproj",
scheme: "YapDatabase-iOS",
configuration: "Release",
destination: options[:destination],
archive_path: options[:archive_path],
xcargs: "VALIDATE_WORKSPACE=NO SKIP_INSTALL=NO GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO STRIP_INSTALLED_PRODUCT=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES"
)
end
end