forked from MacPaw/XADMaster
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from iComics/dynamic-ios-library
Added support for iOS XCFramework builds
- Loading branch information
Showing
7 changed files
with
443 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
XADMaster.xcodeproj/xcshareddata/xcschemes/XADMaster-iOS.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1250" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "223F699D2643C3E400B9ABCA" | ||
BuildableName = "XADMaster.framework" | ||
BlueprintName = "XADMaster-iOS" | ||
ReferencedContainer = "container:XADMaster.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES"> | ||
<Testables> | ||
</Testables> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "223F699D2643C3E400B9ABCA" | ||
BuildableName = "XADMaster.framework" | ||
BlueprintName = "XADMaster-iOS" | ||
ReferencedContainer = "container:XADMaster.xcodeproj"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/bin/bash | ||
|
||
# BSD 3-Clause License | ||
# | ||
# Copyright (c) 2021, Tim Oliver | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# | ||
# 1. Redistributions of source code must retain the above copyright notice, this | ||
# list of conditions and the following disclaimer. | ||
# | ||
# 2. Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# | ||
# 3. Neither the name of the copyright holder nor the names of its | ||
# contributors may be used to endorse or promote products derived from | ||
# this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
set -e | ||
|
||
# Main Definitions | ||
UD_REPO="https://www.github.com/icomics/universal-detector.git" | ||
FRAMEWORK_NAME="XADMaster" | ||
BUILD_PATH="build/Build/Products" | ||
DEVICE_PATH="Release-iphoneos" | ||
SIMULATOR_PATH="Release-iphonesimulator" | ||
|
||
# Add a module map to a target directory | ||
add_module_map() { | ||
TARGET_DIR=$1 | ||
|
||
mkdir -p "${TARGET_DIR}/Modules" | ||
cat <<EOT >> ${TARGET_DIR}/Modules/module.modulemap | ||
framework module XADMaster { | ||
header "XADArchive.h" | ||
header "CSHandle.h" | ||
header "XADException.h" | ||
header "ClangAnalyser.h" | ||
export * | ||
} | ||
EOT | ||
} | ||
|
||
make_framework() { | ||
# If it doesn't exist, pull down the UniversalDetector repo | ||
if [ ! -d "../UniversalDetector" ]; then | ||
git clone ${UD_REPO} ../UniversalDetector | ||
fi | ||
|
||
# Delete the folder if present | ||
rm -r build | ||
mkdir -p build | ||
|
||
# Build the simulator slice (But only Intel since we need XCFramework to support Apple Silicon) | ||
xcodebuild -project XADMaster.xcodeproj -scheme XADMaster-iOS -sdk iphonesimulator -destination "generic/platform=iOS Simulator" \ | ||
-configuration Release BUILD_LIBRARY_FOR_DISTRIBUTION=YES -derivedDataPath build clean build | ||
|
||
# Add the module map for Swift compatibility | ||
add_module_map "${BUILD_PATH}/${SIMULATOR_PATH}/${FRAMEWORK_NAME}.framework" | ||
|
||
# Build all of the iOS slices of the framework | ||
xcodebuild -project XADMaster.xcodeproj -scheme XADMaster-iOS -sdk iphoneos -destination "generic/platform=iOS" \ | ||
-configuration Release BUILD_LIBRARY_FOR_DISTRIBUTION=YES -derivedDataPath build build | ||
|
||
# Add the module map for Swift compatibility | ||
add_module_map "${BUILD_PATH}/${DEVICE_PATH}/${FRAMEWORK_NAME}.framework" | ||
|
||
#Convert the library into an xcframework | ||
xcodebuild -create-xcframework \ | ||
-framework ${BUILD_PATH}/${DEVICE_PATH}/${FRAMEWORK_NAME}.framework \ | ||
-framework ${BUILD_PATH}/${SIMULATOR_PATH}/${FRAMEWORK_NAME}.framework \ | ||
-output build/${FRAMEWORK_NAME}.xcframework | ||
|
||
# Open the folder for us to see if | ||
open build | ||
} | ||
|
||
# Start the build process | ||
make_framework |