Skip to content

Commit

Permalink
feature #10: XCConfig 추가 및 암호화 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
0inn committed Jul 26, 2023
1 parent 8d111d4 commit 7c209cb
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 28 deletions.
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ Derived/
Tuist/Dependencies
Tuist/master.key

Targets/Keyme/Resources/Secrets/*
!Targets/Keyme/Resources/Secrets/.gitkeep
Projects/Keyme/Resources/Secrets/*
!Projects/Keyme/Resources/Secrets/.gitkeep

Secrets/*
Secrets/.gitkeep

Targets/Keyme/Encrypted/.DS_Store.encrypted

XCConfig/*
!*/.gitkeep
12 changes: 0 additions & 12 deletions Config.xcconfig

This file was deleted.

File renamed without changes.
File renamed without changes.
Binary file added Encrypted/XCConfig/App/DEV.xcconfig.encrypted
Binary file not shown.
1 change: 1 addition & 0 deletions Encrypted/XCConfig/App/PROD.xcconfig.encrypted
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�d��BJؠ���LH�8�v2c�����mH �"?^F1Xn�o^� |�т�2x>�SFgtmz \���Ԍ����uQ&uD�0�p>y�����|/�N&UcŞ�;RV��$�H�K����X6W]�nu.����i}�D�ş?��~Jod >�w���R
Expand Down
Binary file added Encrypted/XCConfig/App/shared.xcconfig.encrypted
Binary file not shown.
Empty file.
1 change: 1 addition & 0 deletions Encrypted/XCConfig/Target/Framework.xcconfig.encrypted
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�ѕ4��i�[�W����i��{�X7L�O�Ӎt��T��WB�Bl~P�j��J5��{���H7��
Binary file added Encrypted/XCConfig/Target/Tests.xcconfig.encrypted
Binary file not shown.
18 changes: 15 additions & 3 deletions Scripts/decrypt.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#!/bin/bash

KEY_PATH="Tuist/master.key"
SECRETS_DIR="Targets/Keyme/Encrypted"
OUTPUT_DIR="Targets/Keyme/Resources/Secrets"

SECRETS_DIR="Encrypted"
OUTPUT_DIR="Projects/Keyme/Resources/Secrets"

XCCONFIG_APP_DIR="XCConfig/App"
XCCONFIG_TARGET_DIR="XCConfig/Target"

# Find all encrypted files in the secrets directory
files=($(find ${SECRETS_DIR} -type f -name "*.encrypted"))
Expand All @@ -13,8 +17,16 @@ do
# Extract the filename from the file path
filename=$(basename $file .encrypted)

if [[ $file == *"$XCCONFIG_APP_DIR"* ]]; then
out_dir="${XCCONFIG_APP_DIR}"
elif [[ $file == *"$XCCONFIG_TARGET_DIR"* ]]; then
out_dir="${XCCONFIG_TARGET_DIR}"
else
out_dir="${OUTPUT_DIR}"
fi

# Create the output file path by appending the filename to the output directory
out_file="${OUTPUT_DIR}/${filename}"
out_file="${out_dir}/${filename}"

# Only decrypt if the normal file does not exist
if [ ! -f "$out_file" ]; then
Expand Down
25 changes: 21 additions & 4 deletions Scripts/encrypt.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@
#!/bin/bash

KEY_PATH="Tuist/master.key"
SECRETS_DIR="Targets/Keyme/Encrypted"
OUTPUT_DIR="Targets/Keyme/Resources/Secrets"

ENCRYPTED_DIR="Encrypted"
SECRET_DIR="Secrets"

OUTPUT_DIR="Projects/Keyme/Resources/Secrets"
XCCONFIG_APP_DIR="XCConfig/App"
XCCONFIG_TARGET_DIR="XCConfig/Target"

# Find all non-hidden files in the secrets directory that don't have the .encrypted extension
files=($(find ${OUTPUT_DIR} -type f ! -name ".*" ! -name "*.encrypted"))
xcconfigAppFiles=($(find ${XCCONFIG_APP_DIR} -type f ! -name ".*" ! -name "*.encrypted"))
xcconfigTargetFiles=($(find ${XCCONFIG_TARGET_DIR} -type f ! -name ".*" ! -name "*.encrypted"))

allFiles=("${files[@]}" "${xcconfigAppFiles[@]}" "${xcconfigTargetFiles[@]}" )

# Loop through the array and encrypt each file
for file in "${files[@]}"
for file in "${allFiles[@]}"
do
# Extract the filename from the file path
filename=$(basename $file)

if [[ $file == *"$XCCONFIG_APP_DIR"* ]]; then
out_dir="${XCCONFIG_APP_DIR}"
elif [[ $file == *"$XCCONFIG_TARGET_DIR"* ]]; then
out_dir="${XCCONFIG_TARGET_DIR}"
else
out_dir="${SECRET_DIR}"
fi

# Create the output file path by appending the filename to the output directory
out_file="${SECRETS_DIR}/${filename}.encrypted"
out_file="${ENCRYPTED_DIR}/${out_dir}/${filename}.encrypted"

openssl enc -aes-256-cbc -nosalt -in $file -out $out_file -pass file:${KEY_PATH}
done
18 changes: 11 additions & 7 deletions Tuist/Dependencies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
// Created by 이영빈 on 2023/07/14.
//

import Foundation

import ProjectDescription
import ProjectDescriptionHelpers

import ConfigPlugin

let dependencies = Dependencies(
swiftPackageManager: [
.remote(url: "https://github.com/firebase/firebase-ios-sdk", requirement: .upToNextMajor(from: "10.11.0")),
.remote(url: "https://github.com/Moya/Moya", requirement: .upToNextMajor(from: "15.0.3"))
],
platforms: [.iOS]
swiftPackageManager: SwiftPackageManagerDependencies(
[
.remote(url: "https://github.com/firebase/firebase-ios-sdk", requirement: .upToNextMajor(from: "10.11.0")),
.remote(url: "https://github.com/Moya/Moya", requirement: .upToNextMajor(from: "15.0.3"))
],
baseSettings: .settings(configurations: XCConfig.framework)
)
)
29 changes: 29 additions & 0 deletions Tuist/ProjectDescriptionHelpers/AppScheme.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// AppScheme.swift
// ProjectDescriptionHelpers
//
// Created by 김영인 on 2023/07/26.
//

import ProjectDescription

import EnvPlugin

extension Project {
static let appScheme: [Scheme] = [
.init(name: "\(Environment.appName)-DEV",
buildAction: .buildAction(targets: ["\(Environment.appName)"]),
runAction: .runAction(configuration: "DEV"),
archiveAction: .archiveAction(configuration: "DEV"),
profileAction: .profileAction(configuration: "DEV"),
analyzeAction: .analyzeAction(configuration: "DEV")
),
.init(name: "\(Environment.appName)-PROD",
buildAction: .buildAction(targets: ["\(Environment.appName)"]),
runAction: .runAction(configuration: "PROD"),
archiveAction: .archiveAction(configuration: "PROD"),
profileAction: .profileAction(configuration: "PROD"),
analyzeAction: .analyzeAction(configuration: "PROD")
)
]
}

0 comments on commit 7c209cb

Please sign in to comment.