Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
#!/bin/sh
2
set -e
3
set -u
4
set -o pipefail
5
 
6
function on_error {
7
  echo "$(realpath -mq "${0}"):$1: error: Unexpected failure"
8
}
9
trap 'on_error $LINENO' ERR
10
 
11
if [ -z ${FRAMEWORKS_FOLDER_PATH+x} ]; then
12
  # If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy
13
  # frameworks to, so exit 0 (signalling the script phase was successful).
14
  exit 0
15
fi
16
 
17
echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
18
mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
19
 
20
COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}"
21
SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
22
BCSYMBOLMAP_DIR="BCSymbolMaps"
23
 
24
 
25
# This protects against multiple targets copying the same framework dependency at the same time. The solution
26
# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html
27
RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")
28
 
29
# Copies and strips a vendored framework
30
install_framework()
31
{
32
  if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
33
    local source="${BUILT_PRODUCTS_DIR}/$1"
34
  elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then
35
    local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"
36
  elif [ -r "$1" ]; then
37
    local source="$1"
38
  fi
39
 
40
  local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
41
 
42
  if [ -L "${source}" ]; then
43
    echo "Symlinked..."
44
    source="$(readlink "${source}")"
45
  fi
46
 
47
  if [ -d "${source}/${BCSYMBOLMAP_DIR}" ]; then
48
    # Locate and install any .bcsymbolmaps if present, and remove them from the .framework before the framework is copied
49
    find "${source}/${BCSYMBOLMAP_DIR}" -name "*.bcsymbolmap"|while read f; do
50
      echo "Installing $f"
51
      install_bcsymbolmap "$f" "$destination"
52
      rm "$f"
53
    done
54
    rmdir "${source}/${BCSYMBOLMAP_DIR}"
55
  fi
56
 
57
  # Use filter instead of exclude so missing patterns don't throw errors.
58
  echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\""
59
  rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"
60
 
61
  local basename
62
  basename="$(basename -s .framework "$1")"
63
  binary="${destination}/${basename}.framework/${basename}"
64
 
65
  if ! [ -r "$binary" ]; then
66
    binary="${destination}/${basename}"
67
  elif [ -L "${binary}" ]; then
68
    echo "Destination binary is symlinked..."
69
    dirname="$(dirname "${binary}")"
70
    binary="${dirname}/$(readlink "${binary}")"
71
  fi
72
 
73
  # Strip invalid architectures so "fat" simulator / device frameworks work on device
74
  if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then
75
    strip_invalid_archs "$binary"
76
  fi
77
 
78
  # Resign the code if required by the build settings to avoid unstable apps
79
  code_sign_if_enabled "${destination}/$(basename "$1")"
80
 
81
  # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
82
  if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
83
    local swift_runtime_libs
84
    swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u)
85
    for lib in $swift_runtime_libs; do
86
      echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
87
      rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
88
      code_sign_if_enabled "${destination}/${lib}"
89
    done
90
  fi
91
}
92
# Copies and strips a vendored dSYM
93
install_dsym() {
94
  local source="$1"
95
  warn_missing_arch=${2:-true}
96
  if [ -r "$source" ]; then
97
    # Copy the dSYM into the targets temp dir.
98
    echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DERIVED_FILES_DIR}\""
99
    rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}"
100
 
101
    local basename
102
    basename="$(basename -s .dSYM "$source")"
103
    binary_name="$(ls "$source/Contents/Resources/DWARF")"
104
    binary="${DERIVED_FILES_DIR}/${basename}.dSYM/Contents/Resources/DWARF/${binary_name}"
105
 
106
    # Strip invalid architectures from the dSYM.
107
    if [[ "$(file "$binary")" == *"Mach-O "*"dSYM companion"* ]]; then
108
      strip_invalid_archs "$binary" "$warn_missing_arch"
109
    fi
110
    if [[ $STRIP_BINARY_RETVAL == 0 ]]; then
111
      # Move the stripped file into its final destination.
112
      echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\""
113
      rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.dSYM" "${DWARF_DSYM_FOLDER_PATH}"
114
    else
115
      # The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing.
116
      mkdir -p "${DWARF_DSYM_FOLDER_PATH}"
117
      touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.dSYM"
118
    fi
119
  fi
120
}
121
 
122
# Used as a return value for each invocation of `strip_invalid_archs` function.
123
STRIP_BINARY_RETVAL=0
124
 
125
# Strip invalid architectures
126
strip_invalid_archs() {
127
  binary="$1"
128
  warn_missing_arch=${2:-true}
129
  # Get architectures for current target binary
130
  binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)"
131
  # Intersect them with the architectures we are building for
132
  intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)"
133
  # If there are no archs supported by this binary then warn the user
134
  if [[ -z "$intersected_archs" ]]; then
135
    if [[ "$warn_missing_arch" == "true" ]]; then
136
      echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)."
137
    fi
138
    STRIP_BINARY_RETVAL=1
139
    return
140
  fi
141
  stripped=""
142
  for arch in $binary_archs; do
143
    if ! [[ "${ARCHS}" == *"$arch"* ]]; then
144
      # Strip non-valid architectures in-place
145
      lipo -remove "$arch" -output "$binary" "$binary"
146
      stripped="$stripped $arch"
147
    fi
148
  done
149
  if [[ "$stripped" ]]; then
150
    echo "Stripped $binary of architectures:$stripped"
151
  fi
152
  STRIP_BINARY_RETVAL=0
153
}
154
 
155
# Copies the bcsymbolmap files of a vendored framework
156
install_bcsymbolmap() {
157
    local bcsymbolmap_path="$1"
158
    local destination="${BUILT_PRODUCTS_DIR}"
159
    echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}""
160
    rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}"
161
}
162
 
163
# Signs a framework with the provided identity
164
code_sign_if_enabled() {
165
  if [ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
166
    # Use the current code_sign_identity
167
    echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
168
    local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'"
169
 
170
    if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
171
      code_sign_cmd="$code_sign_cmd &"
172
    fi
173
    echo "$code_sign_cmd"
174
    eval "$code_sign_cmd"
175
  fi
176
}
177
 
178
if [[ "$CONFIGURATION" == "Debug" ]]; then
179
  install_framework "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework"
180
  install_framework "${BUILT_PRODUCTS_DIR}/AlamofireImage/AlamofireImage.framework"
181
  install_framework "${BUILT_PRODUCTS_DIR}/DeviceKit/DeviceKit.framework"
182
  install_framework "${BUILT_PRODUCTS_DIR}/FirebaseABTesting/FirebaseABTesting.framework"
183
  install_framework "${BUILT_PRODUCTS_DIR}/FirebaseCore/FirebaseCore.framework"
184
  install_framework "${BUILT_PRODUCTS_DIR}/FirebaseCoreDiagnostics/FirebaseCoreDiagnostics.framework"
185
  install_framework "${BUILT_PRODUCTS_DIR}/FirebaseCrashlytics/FirebaseCrashlytics.framework"
186
  install_framework "${BUILT_PRODUCTS_DIR}/FirebaseInAppMessaging/FirebaseInAppMessaging.framework"
187
  install_framework "${BUILT_PRODUCTS_DIR}/FirebaseInstallations/FirebaseInstallations.framework"
188
  install_framework "${BUILT_PRODUCTS_DIR}/FirebaseMessaging/FirebaseMessaging.framework"
189
  install_framework "${BUILT_PRODUCTS_DIR}/FirebasePerformance/FirebasePerformance.framework"
190
  install_framework "${BUILT_PRODUCTS_DIR}/FirebaseRemoteConfig/FirebaseRemoteConfig.framework"
191
  install_framework "${BUILT_PRODUCTS_DIR}/FloatingLabelTextFieldSwiftUI/FloatingLabelTextFieldSwiftUI.framework"
192
  install_framework "${BUILT_PRODUCTS_DIR}/GoogleDataTransport/GoogleDataTransport.framework"
193
  install_framework "${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework"
194
  install_framework "${BUILT_PRODUCTS_DIR}/Player/Player.framework"
195
  install_framework "${BUILT_PRODUCTS_DIR}/PromisesObjC/FBLPromises.framework"
196
  install_framework "${BUILT_PRODUCTS_DIR}/RNCryptor/RNCryptor.framework"
197
  install_framework "${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework"
198
  install_framework "${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework"
199
fi
200
if [[ "$CONFIGURATION" == "Release" ]]; then
201
  install_framework "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework"
202
  install_framework "${BUILT_PRODUCTS_DIR}/AlamofireImage/AlamofireImage.framework"
203
  install_framework "${BUILT_PRODUCTS_DIR}/DeviceKit/DeviceKit.framework"
204
  install_framework "${BUILT_PRODUCTS_DIR}/FirebaseABTesting/FirebaseABTesting.framework"
205
  install_framework "${BUILT_PRODUCTS_DIR}/FirebaseCore/FirebaseCore.framework"
206
  install_framework "${BUILT_PRODUCTS_DIR}/FirebaseCoreDiagnostics/FirebaseCoreDiagnostics.framework"
207
  install_framework "${BUILT_PRODUCTS_DIR}/FirebaseCrashlytics/FirebaseCrashlytics.framework"
208
  install_framework "${BUILT_PRODUCTS_DIR}/FirebaseInAppMessaging/FirebaseInAppMessaging.framework"
209
  install_framework "${BUILT_PRODUCTS_DIR}/FirebaseInstallations/FirebaseInstallations.framework"
210
  install_framework "${BUILT_PRODUCTS_DIR}/FirebaseMessaging/FirebaseMessaging.framework"
211
  install_framework "${BUILT_PRODUCTS_DIR}/FirebasePerformance/FirebasePerformance.framework"
212
  install_framework "${BUILT_PRODUCTS_DIR}/FirebaseRemoteConfig/FirebaseRemoteConfig.framework"
213
  install_framework "${BUILT_PRODUCTS_DIR}/FloatingLabelTextFieldSwiftUI/FloatingLabelTextFieldSwiftUI.framework"
214
  install_framework "${BUILT_PRODUCTS_DIR}/GoogleDataTransport/GoogleDataTransport.framework"
215
  install_framework "${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework"
216
  install_framework "${BUILT_PRODUCTS_DIR}/Player/Player.framework"
217
  install_framework "${BUILT_PRODUCTS_DIR}/PromisesObjC/FBLPromises.framework"
218
  install_framework "${BUILT_PRODUCTS_DIR}/RNCryptor/RNCryptor.framework"
219
  install_framework "${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework"
220
  install_framework "${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework"
221
fi
222
if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
223
  wait
224
fi