OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 |
| 3 # Copyright 2015 The WebRTC project authors. All Rights Reserved. |
| 4 # |
| 5 # Use of this source code is governed by a BSD-style license |
| 6 # that can be found in the LICENSE file in the root of the source |
| 7 # tree. An additional intellectual property rights grant can be found |
| 8 # in the file PATENTS. All contributing project authors may |
| 9 # be found in the AUTHORS file in the root of the source tree. |
| 10 |
| 11 # Generates dynamic FAT framework for iOS in out_ios_framework. |
| 12 |
| 13 # Check for Darwin. |
| 14 if [[ ! $(uname) = "Darwin" ]]; then |
| 15 echo "OS X required." >&2 |
| 16 fi |
| 17 |
| 18 # Check for iOS library build script. |
| 19 SCRIPT_DIR=$(dirname $0) |
| 20 WEBRTC_BASE_DIR=${SCRIPT_DIR}/../../.. |
| 21 BUILD_WEBRTC_SCRIPT=${WEBRTC_BASE_DIR}/webrtc/build/ios/build_ios_libs.sh |
| 22 if [[ ! -x ${BUILD_WEBRTC_SCRIPT} ]]; then |
| 23 echo "Failed to find iOS library build script." >&2 |
| 24 exit 1 |
| 25 fi |
| 26 # Check for flatten iOS headers script. |
| 27 FLATTEN_HEADERS_SCRIPT=${WEBRTC_BASE_DIR}/webrtc/build/ios/flatten_ios_headers |
| 28 if [[ ! -x ${FLATTEN_HEADERS_SCRIPT} ]]; then |
| 29 echo "Failed to find flatten iOS headers script." >&2 |
| 30 exit 1 |
| 31 fi |
| 32 |
| 33 pushd ${WEBRTC_BASE_DIR} |
| 34 LIB_BASE_DIR=out_ios_libs |
| 35 FRAMEWORK_BASE_DIR=out_ios_framework |
| 36 |
| 37 # Build static libraries for iOS. |
| 38 ${BUILD_WEBRTC_SCRIPT} |
| 39 if [ $? -ne 0 ]; then |
| 40 echo "Failed to build iOS static libraries." >&2 |
| 41 exit 1 |
| 42 fi |
| 43 |
| 44 # Flatten the directory structure for iOS headers. |
| 45 ${FLATTEN_HEADERS_SCRIPT} ${LIB_BASE_DIR} ${FRAMEWORK_BASE_DIR} |
| 46 if [ $? -ne 0 ]; then |
| 47 echo "Failed to flatten iOS headers." >&2 |
| 48 exit 1 |
| 49 fi |
| 50 |
| 51 # Replace full paths for headers with framework paths. |
| 52 SED_PATTERN=' |
| 53 s/(\#import )\"webrtc\/api\/objc\/(.*)\"/\1<WebRTC\/\2>/g; |
| 54 s/(\#import )\"webrtc\/base\/objc\/(.*)\"/\1<WebRTC\/\2>/g; |
| 55 s/(\#include )\"webrtc\/base\/objc\/(.*)\"/\1<WebRTC\/\2>/g; |
| 56 ' |
| 57 sed -E -i '' "$SED_PATTERN" ${FRAMEWORK_BASE_DIR}/include/*.h |
| 58 |
| 59 SDK_DIR=webrtc/build/ios/SDK |
| 60 PROJECT_DIR=${SDK_DIR}/Framework |
| 61 # Build the framework. |
| 62 pushd ${PROJECT_DIR} |
| 63 xcodebuild -project WebRTC.xcodeproj -scheme WebRTC -configuration Release \ |
| 64 build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO |
| 65 xcodebuild -project WebRTC.xcodeproj -scheme WebRTC -configuration Release \ |
| 66 build -destination 'platform=iOS Simulator,name=iPhone 6' |
| 67 popd |
| 68 |
| 69 # Copy podspec, framework, dSYM and LICENSE to FRAMEWORK_BASE_DIR |
| 70 DEVICE_BUILD_DIR=${PROJECT_DIR}/build/Release-iphoneos |
| 71 cp ${SDK_DIR}/WebRTC.podspec ${FRAMEWORK_BASE_DIR}/ |
| 72 cp -R ${DEVICE_BUILD_DIR}/WebRTC.framework ${FRAMEWORK_BASE_DIR}/ |
| 73 cp -R ${DEVICE_BUILD_DIR}/WebRTC.framework.dSYM ${FRAMEWORK_BASE_DIR}/ |
| 74 cp -R webrtc/LICENSE ${FRAMEWORK_BASE_DIR}/ |
| 75 |
| 76 # Combine multiple architectures |
| 77 SIMULATOR_BUILD_DIR=${PROJECT_DIR}/build/Release-iphonesimulator |
| 78 DYLIB_PATH=WebRTC.framework/WebRTC |
| 79 DWARF_PATH=WebRTC.framework.dSYM/Contents/Resources/DWARF/WebRTC |
| 80 lipo ${FRAMEWORK_BASE_DIR}/${DYLIB_PATH} ${SIMULATOR_BUILD_DIR}/${DYLIB_PATH} \ |
| 81 -create -output ${FRAMEWORK_BASE_DIR}/${DYLIB_PATH} |
| 82 lipo ${FRAMEWORK_BASE_DIR}/${DWARF_PATH} ${SIMULATOR_BUILD_DIR}/${DWARF_PATH} \ |
| 83 -create -output ${FRAMEWORK_BASE_DIR}/${DWARF_PATH} |
| 84 |
| 85 popd |
OLD | NEW |