XcodeSurgery is a swift XCode build phase CLI tool for copying compiled binaries between iOS app targets.
xcconfig
or preprocessor macros
to manage build variantsBuilding different build variants using configuration will trigger recompilation as the build processes do not share common $(TARGET_BUILD_DIR)
. Changing preprocessor macro values will trigger dependency graph reanalysis and recompilation of codes. Ideally there should not be recompilation if there's no change in the logic of the source codes.
XcodeSurgery is available through Mint 🌱.
mint install depoon/XcodeSurgery
Mint can be installed via Homebrew
brew install mint
Select VariantEncryption
and XcodeSurgeryKit
products and add them to your application target.
Don't worry, we will encrypt the files before using them in our application.
xcodesurgery express keygen
This will create a hidden .xcodesurgery/secret
folder in the root project folder and generate random password and salt file for use in the encrypt/decrypt process.
XcodeSurgery aims to eliminate unnecessary recompilation of source codes when building different flavours or variants of an iOS app target.
Destination Target
and the original target as the Source Target
Do note that you do not need to clone the Source Target
Source Target
over to Destination Target
.Source Target
using the following commandxcodesurgery prepare \
--workingDirectory "<WorkingDirectory>" \
--targetBuildDirectory ${TARGET_BUILD_DIR} \
--targetName "${TARGETNAME}"
Destination Target
using the following commandxcodesurgery transplant \
--action ${ACTION} \
--targetBuildDirectory ${TARGET_BUILD_DIR} \
--workingDirectory "<WorkingDirectory>" \
--sourceTarget "<SourceTargetName>" \
--destinationTarget ${TARGETNAME} \
--sdkName ${SDK_NAME}
Build the Source Target
Build the Destination Target
Run the Destination Target
and observe that you can deploy a clone app of the Source Target
You can modify the Destination Target
build settings with different bundle identifiers, code signing instructions and provisioning profiles to create different build variants.
Argument Name | Comments |
---|---|
workingDirectory |
Directory where target source app will be copied to |
targetBuildDirectory |
${TARGET_BUILD_DIR} environment argument of source target |
targetName |
${TARGETNAME} environment argument of source target |
Argument Name | Comments |
---|---|
action |
${ACTION} environment argument of destination target |
workingDirectory |
Directory where target source app will be copied to |
targetBuildDirectory |
${TARGET_BUILD_DIR} environment argument of destination target |
targetName |
${TARGETNAME} environment argument of destination target |
sourceTarget |
Name of the source target |
destinationTarget |
${TARGETNAME} environment argument of destination target |
sdkName |
${SDK_NAME} environment argument of destination target |
debugInformationFormat |
${DEBUG_INFORMATION_FORMAT} environment argument of destination target |
filesToRemove |
list of files in sourceTarget app to remove |
filesToInject |
list of files to copy into destinationTarget app |
If you are currently using user-defined-settings or preprocessor macros in your project, you may not be able to take advantage of time savings with having just one compile process.
Here's a quick adjustment you can make to prepare your project for XcodeSurgery
Create a new string-value entry in your target's Info.plist file to indiciate which variant you are building.
Read the custom entry from Info.plist and use the corresponding value to create your variant values for your app.
let env = Bundle.main.infoDictionary?["MY_ENVIRONMENT"] as! String
Do take note that this is trade off between having extra code in your application and improvments on build time. If you encounter any issues or difficulties to integrate XcodeSurgery into your project, do help to raise an issue.
Support for Extensions. Help raise an issue for one. I welcome contributions to help grow the capabilities of this repository.
link |
Stars: 33 |
Last commit: 5 days ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics