Skip to content

Commit 9c9e14d

Browse files
Updated XCFramework script and added a scheme for building an XCFramework through Xcode
1 parent 45f1224 commit 9c9e14d

File tree

3 files changed

+172
-22
lines changed

3 files changed

+172
-22
lines changed

ProtocolProxy.xcodeproj/project.pbxproj

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@
66
objectVersion = 50;
77
objects = {
88

9+
/* Begin PBXAggregateTarget section */
10+
DD2FBC27258BE8BB00DB3211 /* XCFramework */ = {
11+
isa = PBXAggregateTarget;
12+
buildConfigurationList = DD2FBC2A258BE8BB00DB3211 /* Build configuration list for PBXAggregateTarget "XCFramework" */;
13+
buildPhases = (
14+
DD2FBC33258BE8C600DB3211 /* Build XCFramework */,
15+
);
16+
dependencies = (
17+
);
18+
name = XCFramework;
19+
productName = XCFramework;
20+
};
21+
/* End PBXAggregateTarget section */
22+
923
/* Begin PBXBuildFile section */
1024
DD391B012569BC8C001C99FA /* ProtocolProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD391B002569BC8C001C99FA /* ProtocolProxy.swift */; };
1125
DD391B022569BC8C001C99FA /* ProtocolProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD391B002569BC8C001C99FA /* ProtocolProxy.swift */; };
@@ -81,6 +95,7 @@
8195
/* End PBXContainerItemProxy section */
8296

8397
/* Begin PBXFileReference section */
98+
DD17A9F9257744BC00D30599 /* scripts */ = {isa = PBXFileReference; lastKnownFileType = folder; path = scripts; sourceTree = "<group>"; };
8499
DD391B002569BC8C001C99FA /* ProtocolProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProtocolProxy.swift; sourceTree = "<group>"; };
85100
DDA15D8A25644EEE0036D007 /* ProtocolProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProtocolProxy.h; sourceTree = "<group>"; };
86101
DDA15D8B25644EEE0036D007 /* module.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
@@ -100,7 +115,6 @@
100115
DDA15DEC25644F580036D007 /* ProtocolProxy-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; name = "ProtocolProxy-Info.plist"; path = "Plists/ProtocolProxy-Info.plist"; sourceTree = SOURCE_ROOT; };
101116
DDA15DED25644F580036D007 /* ProtocolProxyTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; name = "ProtocolProxyTests-Info.plist"; path = "Plists/ProtocolProxyTests-Info.plist"; sourceTree = SOURCE_ROOT; };
102117
DDA15DEE25644F680036D007 /* Package.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = SOURCE_ROOT; };
103-
DD17A9F9257744BC00D30599 /* scripts */ = {isa = PBXFileReference; lastKnownFileType = folder; path = scripts; sourceTree = "<group>"; };
104118
DDA26DBD256EA4D700E1C6D7 /* workflows */ = {isa = PBXFileReference; lastKnownFileType = folder; name = workflows; path = .github/workflows; sourceTree = "<group>"; };
105119
DDF7567322AA773D002E11D4 /* ProtocolProxy.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ProtocolProxy.framework; sourceTree = BUILT_PRODUCTS_DIR; };
106120
DDF7567C22AA773D002E11D4 /* ProtocolProxyTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ProtocolProxyTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -502,8 +516,11 @@
502516
isa = PBXProject;
503517
attributes = {
504518
LastUpgradeCheck = 1220;
505-
ORGANIZATIONNAME = "Some Random iOS Dev";
519+
ORGANIZATIONNAME = SomeRandomiOSDev;
506520
TargetAttributes = {
521+
DD2FBC27258BE8BB00DB3211 = {
522+
CreatedOnToolsVersion = 12.3;
523+
};
507524
DDF7567222AA773D002E11D4 = {
508525
CreatedOnToolsVersion = 10.2.1;
509526
LastSwiftMigration = 1220;
@@ -554,6 +571,7 @@
554571
DDF756CF22AA7841002E11D4 /* ProtocolProxy tvOS */,
555572
DDF756D722AA7841002E11D4 /* ProtocolProxy tvOS Tests */,
556573
DDF756EB22AA7854002E11D4 /* ProtocolProxy watchOS */,
574+
DD2FBC27258BE8BB00DB3211 /* XCFramework */,
557575
);
558576
};
559577
/* End PBXProject section */
@@ -610,6 +628,27 @@
610628
};
611629
/* End PBXResourcesBuildPhase section */
612630

631+
/* Begin PBXShellScriptBuildPhase section */
632+
DD2FBC33258BE8C600DB3211 /* Build XCFramework */ = {
633+
isa = PBXShellScriptBuildPhase;
634+
buildActionMask = 2147483647;
635+
files = (
636+
);
637+
inputFileListPaths = (
638+
);
639+
inputPaths = (
640+
);
641+
name = "Build XCFramework";
642+
outputFileListPaths = (
643+
);
644+
outputPaths = (
645+
);
646+
runOnlyForDeploymentPostprocessing = 0;
647+
shellPath = /bin/sh;
648+
shellScript = "${PROJECT_DIR}/scripts/xcframework.sh -configuration ${CONFIGURATION} -output \"${BUILD_DIR}/${CONFIGURATION}-universal/ProtocolProxy.xcframework\" \n";
649+
};
650+
/* End PBXShellScriptBuildPhase section */
651+
613652
/* Begin PBXSourcesBuildPhase section */
614653
DDF7566F22AA773D002E11D4 /* Sources */ = {
615654
isa = PBXSourcesBuildPhase;
@@ -717,6 +756,24 @@
717756
/* End PBXTargetDependency section */
718757

719758
/* Begin XCBuildConfiguration section */
759+
DD2FBC28258BE8BB00DB3211 /* Debug */ = {
760+
isa = XCBuildConfiguration;
761+
buildSettings = {
762+
CODE_SIGN_STYLE = Automatic;
763+
DEVELOPMENT_TEAM = PH26G7KHX9;
764+
PRODUCT_NAME = "$(TARGET_NAME)";
765+
};
766+
name = Debug;
767+
};
768+
DD2FBC29258BE8BB00DB3211 /* Release */ = {
769+
isa = XCBuildConfiguration;
770+
buildSettings = {
771+
CODE_SIGN_STYLE = Automatic;
772+
DEVELOPMENT_TEAM = PH26G7KHX9;
773+
PRODUCT_NAME = "$(TARGET_NAME)";
774+
};
775+
name = Release;
776+
};
720777
DDF7568522AA773D002E11D4 /* Debug */ = {
721778
isa = XCBuildConfiguration;
722779
buildSettings = {
@@ -1192,6 +1249,15 @@
11921249
/* End XCBuildConfiguration section */
11931250

11941251
/* Begin XCConfigurationList section */
1252+
DD2FBC2A258BE8BB00DB3211 /* Build configuration list for PBXAggregateTarget "XCFramework" */ = {
1253+
isa = XCConfigurationList;
1254+
buildConfigurations = (
1255+
DD2FBC28258BE8BB00DB3211 /* Debug */,
1256+
DD2FBC29258BE8BB00DB3211 /* Release */,
1257+
);
1258+
defaultConfigurationIsVisible = 0;
1259+
defaultConfigurationName = Release;
1260+
};
11951261
DDF7566D22AA773D002E11D4 /* Build configuration list for PBXProject "ProtocolProxy" */ = {
11961262
isa = XCConfigurationList;
11971263
buildConfigurations = (
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1230"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "DD2FBC27258BE8BB00DB3211"
18+
BuildableName = "XCFramework"
19+
BlueprintName = "XCFramework"
20+
ReferencedContainer = "container:ProtocolProxy.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Release"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
</LaunchAction>
44+
<ProfileAction
45+
buildConfiguration = "Release"
46+
shouldUseLaunchSchemeArgsEnv = "YES"
47+
savedToolIdentifier = ""
48+
useCustomWorkingDirectory = "NO"
49+
debugDocumentVersioning = "YES">
50+
<MacroExpansion>
51+
<BuildableReference
52+
BuildableIdentifier = "primary"
53+
BlueprintIdentifier = "DD2FBC27258BE8BB00DB3211"
54+
BuildableName = "XCFramework"
55+
BlueprintName = "XCFramework"
56+
ReferencedContainer = "container:ProtocolProxy.xcodeproj">
57+
</BuildableReference>
58+
</MacroExpansion>
59+
</ProfileAction>
60+
<AnalyzeAction
61+
buildConfiguration = "Debug">
62+
</AnalyzeAction>
63+
<ArchiveAction
64+
buildConfiguration = "Release"
65+
revealArchiveInOrganizer = "YES">
66+
</ArchiveAction>
67+
</Scheme>

scripts/xcframework.sh

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ while [[ $# -gt 0 ]]; do
1313
shift # <output_dir>
1414
;;
1515

16+
-configuration)
17+
CONFIGURATION="$2"
18+
shift # -configuration
19+
shift # <configuration>
20+
;;
21+
1622
*)
1723
echo "Unknown argument: $1"
1824
echo "./xcframework.sh [-output <output_xcframework>]"]
@@ -21,13 +27,17 @@ while [[ $# -gt 0 ]]; do
2127
done
2228

2329
if [ -z ${OUTPUT_DIR+x} ]; then
24-
OUTPUT_DIR="$(dirname $(realpath $0))/build/ProtocolProxy.xcframework"
30+
OUTPUT_DIR="$(dirname "$(realpath "$0")")/build/ProtocolProxy.xcframework"
31+
fi
32+
33+
if [ -z ${CONFIGURATION+x} ]; then
34+
CONFIGURATION="Release"
2535
fi
2636

2737
# Create Temporary Directory
2838

2939
TMPDIR=`mktemp -d /tmp/.protocolproxy.xcframework.build.XXXXXX`
30-
cd "$(dirname $(dirname $(realpath $0)))"
40+
cd "$(dirname "$(dirname "$(realpath "$0")")")"
3141

3242
check_result() {
3343
if [ $1 -ne 0 ]; then
@@ -37,35 +47,35 @@ check_result() {
3747
}
3848

3949
# Build iOS
40-
xcodebuild -project "ProtocolProxy.xcodeproj" -scheme "ProtocolProxy" -destination "generic/platform=iOS" -archivePath "${TMPDIR}/iphoneos.xcarchive" -configuration Release SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ONLY_ACTIVE_ARCH=NO ARCHS="armv7 armv7s arm64 arm64e" archive
50+
xcodebuild -project "ProtocolProxy.xcodeproj" -scheme "ProtocolProxy" -destination "generic/platform=iOS" -archivePath "${TMPDIR}/iphoneos.xcarchive" -configuration ${CONFIGURATION} SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ONLY_ACTIVE_ARCH=NO ARCHS="armv7 armv7s arm64 arm64e" archive
4151
check_result $?
4252

4353
# Build iOS Simulator
44-
xcodebuild -project "ProtocolProxy.xcodeproj" -scheme "ProtocolProxy" -destination "generic/platform=iOS Simulator" -archivePath "${TMPDIR}/iphonesimulator.xcarchive" -configuration Release SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ONLY_ACTIVE_ARCH=NO ARCHS="i386 x86_64 arm64" archive
54+
xcodebuild -project "ProtocolProxy.xcodeproj" -scheme "ProtocolProxy" -destination "generic/platform=iOS Simulator" -archivePath "${TMPDIR}/iphonesimulator.xcarchive" -configuration ${CONFIGURATION} SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ONLY_ACTIVE_ARCH=NO ARCHS="i386 x86_64 arm64" archive
4555
check_result $?
4656

4757
# Build Mac Catalyst
48-
xcodebuild -project "ProtocolProxy.xcodeproj" -scheme "ProtocolProxy" -destination "generic/platform=macOS,variant=Mac Catalyst" -archivePath "${TMPDIR}/maccatalyst.xcarchive" -configuration Release SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ONLY_ACTIVE_ARCH=NO ARCHS="x86_64 arm64 arm64e" archive
58+
xcodebuild -project "ProtocolProxy.xcodeproj" -scheme "ProtocolProxy" -destination "generic/platform=macOS,variant=Mac Catalyst" -archivePath "${TMPDIR}/maccatalyst.xcarchive" -configuration ${CONFIGURATION} SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ONLY_ACTIVE_ARCH=NO ARCHS="x86_64 arm64 arm64e" archive
4959
check_result $?
5060

5161
# Build Mac
52-
xcodebuild -project "ProtocolProxy.xcodeproj" -scheme "ProtocolProxy macOS" -destination "generic/platform=macOS" -archivePath "${TMPDIR}/macos.xcarchive" -configuration Release SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ONLY_ACTIVE_ARCH=NO ARCHS="x86_64 arm64 arm64e" archive
62+
xcodebuild -project "ProtocolProxy.xcodeproj" -scheme "ProtocolProxy macOS" -destination "generic/platform=macOS" -archivePath "${TMPDIR}/macos.xcarchive" -configuration ${CONFIGURATION} SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ONLY_ACTIVE_ARCH=NO ARCHS="x86_64 arm64 arm64e" archive
5363
check_result $?
5464

5565
# Build tvOS
56-
xcodebuild -project "ProtocolProxy.xcodeproj" -scheme "ProtocolProxy tvOS" -destination "generic/platform=tvOS" -archivePath "${TMPDIR}/appletvos.xcarchive" -configuration Release SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ONLY_ACTIVE_ARCH=NO ARCHS="arm64 arm64e" archive
66+
xcodebuild -project "ProtocolProxy.xcodeproj" -scheme "ProtocolProxy tvOS" -destination "generic/platform=tvOS" -archivePath "${TMPDIR}/appletvos.xcarchive" -configuration ${CONFIGURATION} SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ONLY_ACTIVE_ARCH=NO ARCHS="arm64 arm64e" archive
5767
check_result $?
5868

5969
# Build tvOS Simulator
60-
xcodebuild -project "ProtocolProxy.xcodeproj" -scheme "ProtocolProxy tvOS" -destination "generic/platform=tvOS Simulator" -archivePath "${TMPDIR}/appletvsimulator.xcarchive" -configuration Release SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ONLY_ACTIVE_ARCH=NO ARCHS="x86_64 arm64" archive
70+
xcodebuild -project "ProtocolProxy.xcodeproj" -scheme "ProtocolProxy tvOS" -destination "generic/platform=tvOS Simulator" -archivePath "${TMPDIR}/appletvsimulator.xcarchive" -configuration ${CONFIGURATION} SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ONLY_ACTIVE_ARCH=NO ARCHS="x86_64 arm64" archive
6171
check_result $?
6272

6373
# Build watchOS
64-
xcodebuild -project "ProtocolProxy.xcodeproj" -scheme "ProtocolProxy watchOS" -destination "generic/platform=watchOS" -archivePath "${TMPDIR}/watchos.xcarchive" -configuration Release SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ONLY_ACTIVE_ARCH=NO ARCHS="arm64_32 armv7k" archive
74+
xcodebuild -project "ProtocolProxy.xcodeproj" -scheme "ProtocolProxy watchOS" -destination "generic/platform=watchOS" -archivePath "${TMPDIR}/watchos.xcarchive" -configuration ${CONFIGURATION} SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ONLY_ACTIVE_ARCH=NO ARCHS="arm64_32 armv7k" archive
6575
check_result $?
6676

6777
# Build watchOS Simulator
68-
xcodebuild -project "ProtocolProxy.xcodeproj" -scheme "ProtocolProxy watchOS" -destination "generic/platform=watchOS Simulator" -archivePath "${TMPDIR}/watchsimulator.xcarchive" -configuration Release SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ONLY_ACTIVE_ARCH=NO ARCHS="i386 x86_64 arm64" archive
78+
xcodebuild -project "ProtocolProxy.xcodeproj" -scheme "ProtocolProxy watchOS" -destination "generic/platform=watchOS Simulator" -archivePath "${TMPDIR}/watchsimulator.xcarchive" -configuration ${CONFIGURATION} SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ONLY_ACTIVE_ARCH=NO ARCHS="i386 x86_64 arm64" archive
6979
check_result $?
7080

7181
# Make XCFramework
@@ -74,16 +84,23 @@ if [[ -d "${OUTPUT_DIR}" ]]; then
7484
rm -rf "${OUTPUT_DIR}"
7585
fi
7686

77-
xcodebuild -create-xcframework \
78-
-framework "${TMPDIR}/iphoneos.xcarchive/Products/Library/Frameworks/ProtocolProxy.framework" \
79-
-framework "${TMPDIR}/iphonesimulator.xcarchive/Products/Library/Frameworks/ProtocolProxy.framework" \
80-
-framework "${TMPDIR}/maccatalyst.xcarchive/Products/Library/Frameworks/ProtocolProxy.framework" \
81-
-framework "${TMPDIR}/macos.xcarchive/Products/Library/Frameworks/ProtocolProxy.framework" \
82-
-framework "${TMPDIR}/appletvos.xcarchive/Products/Library/Frameworks/ProtocolProxy.framework" \
83-
-framework "${TMPDIR}/appletvsimulator.xcarchive/Products/Library/Frameworks/ProtocolProxy.framework" \
84-
-framework "${TMPDIR}/watchos.xcarchive/Products/Library/Frameworks/ProtocolProxy.framework" \
85-
-framework "${TMPDIR}/watchsimulator.xcarchive/Products/Library/Frameworks/ProtocolProxy.framework" \
86-
-output "${OUTPUT_DIR}"
87+
ARGUMENTS=(-create-xcframework -output "${OUTPUT_DIR}")
88+
89+
for ARCHIVE in ${TMPDIR}/*.xcarchive; do
90+
ARGUMENTS=(${ARGUMENTS[@]} -framework "${ARCHIVE}/Products/Library/Frameworks/ProtocolProxy.framework")
91+
92+
if [[ -d "${ARCHIVE}/dSYMs/ProtocolProxy.framework.dSYM" ]]; then
93+
ARGUMENTS=(${ARGUMENTS[@]} -debug-symbols "${ARCHIVE}/dSYMs/ProtocolProxy.framework.dSYM")
94+
fi
95+
96+
if [[ -d "${ARCHIVE}/BCSymbolMaps" ]]; then
97+
for SYMBOLMAP in ${ARCHIVE}/BCSymbolMaps/*.bcsymbolmap; do
98+
ARGUMENTS=(${ARGUMENTS[@]} -debug-symbols "${SYMBOLMAP}")
99+
done
100+
fi
101+
done
102+
103+
xcodebuild "${ARGUMENTS[@]}"
87104
check_result $?
88105

89106
# Cleanup

0 commit comments

Comments
 (0)