├── .babelrc ├── .eslintignore ├── .eslintrc ├── .gitignore ├── .gitmodules ├── .rustfmt.toml ├── .travis.yml ├── Cargo.toml ├── README.md ├── build-jemalloc.sh ├── fixtures ├── fonts │ ├── FiraMono-Regular.ttf │ └── FreeSans.ttf ├── images │ ├── Firefox.jpg │ └── Quantum.png ├── ios │ ├── Example │ │ ├── Example.xcodeproj │ │ │ ├── project.pbxproj │ │ │ └── project.xcworkspace │ │ │ │ └── contents.xcworkspacedata │ │ ├── Example.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ ├── Example │ │ │ ├── AppDelegate.swift │ │ │ ├── Assets.xcassets │ │ │ │ └── AppIcon.appiconset │ │ │ │ │ └── Contents.json │ │ │ ├── Base.lproj │ │ │ │ ├── LaunchScreen.storyboard │ │ │ │ └── Main.storyboard │ │ │ ├── Bridge.swift │ │ │ ├── Info.plist │ │ │ └── ViewController.swift │ │ ├── Podfile │ │ ├── Podfile.lock │ │ └── Pods │ │ │ ├── Manifest.lock │ │ │ ├── Pods.xcodeproj │ │ │ └── project.pbxproj │ │ │ ├── SwiftyJSON │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ └── Source │ │ │ │ └── SwiftyJSON.swift │ │ │ └── Target Support Files │ │ │ ├── Pods-Example │ │ │ ├── Info.plist │ │ │ ├── Pods-Example-acknowledgements.markdown │ │ │ ├── Pods-Example-acknowledgements.plist │ │ │ ├── Pods-Example-dummy.m │ │ │ ├── Pods-Example-frameworks.sh │ │ │ ├── Pods-Example-resources.sh │ │ │ ├── Pods-Example-umbrella.h │ │ │ ├── Pods-Example.debug.xcconfig │ │ │ ├── Pods-Example.modulemap │ │ │ └── Pods-Example.release.xcconfig │ │ │ └── SwiftyJSON │ │ │ ├── Info.plist │ │ │ ├── SwiftyJSON-dummy.m │ │ │ ├── SwiftyJSON-prefix.pch │ │ │ ├── SwiftyJSON-umbrella.h │ │ │ ├── SwiftyJSON.modulemap │ │ │ └── SwiftyJSON.xcconfig │ ├── bridging-header.h │ └── externals.h └── web │ ├── example-canvas.html │ ├── example-dom.html │ ├── example-webgl.html │ └── index.html ├── gulpfile.babel.js ├── package-lock.json ├── package.json ├── rust-toolchain └── src ├── example.css └── main.rs /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "targets": { 7 | "node": "current" 8 | } 9 | } 10 | ] 11 | ], 12 | "plugins": [] 13 | } 14 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/** 2 | dist/** 3 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "plugins": [ 4 | "import", 5 | "babel" 6 | ], 7 | "extends": [ 8 | "airbnb-base", 9 | "plugin:import/errors", 10 | "plugin:import/warnings" 11 | ], 12 | "rules": { 13 | "no-console": "off", 14 | "no-restricted-syntax": "off" 15 | }, 16 | "globals": { 17 | "cwrap": true 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | Cargo.lock 3 | **/*.rs.bk 4 | node_modules 5 | dist 6 | jemalloc 7 | .vscode 8 | xcuserdata/ 9 | *.xcscmblueprint 10 | *.xccheckout 11 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "rsx-renderers"] 2 | path = rsx-renderers 3 | url = https://github.com/victorporof/rsx-renderers.git 4 | -------------------------------------------------------------------------------- /.rustfmt.toml: -------------------------------------------------------------------------------- 1 | error_on_line_overflow = false 2 | format_strings = true 3 | imports_indent = "Block" 4 | imports_layout = "HorizontalVertical" 5 | max_width = 140 6 | reorder_extern_crates = true 7 | reorder_extern_crates_in_group = true 8 | reorder_imported_names = true 9 | reorder_imports = true 10 | reorder_imports_in_group = true 11 | trailing_comma = "Never" 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: rust 2 | os: 3 | - linux 4 | # - osx 5 | rust: 6 | - nightly 7 | notifications: 8 | email: false 9 | before_script: 10 | - cargo +nightly install rustfmt-nightly --force 11 | # - cargo +nightly install clippy --force 12 | - export PATH=$PATH:~/.cargo/bin 13 | script: 14 | - cargo build --verbose 15 | - cargo test --verbose 16 | - cargo +nightly fmt -- --write-mode=diff 17 | # - cargo +nightly clippy -- --deny warnings 18 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rsx-demo" 3 | version = "0.1.0" 4 | authors = ["Victor Porof "] 5 | 6 | # [lib] 7 | # name = "rsx_demo" 8 | # path = "src/main.rs" 9 | # crate-type = ["staticlib", "cdylib"] 10 | 11 | [features] 12 | default = ["target-native"] 13 | 14 | target-native = ["rsx-embedding/native-embedding"] 15 | target-web = ["rsx-embedding/web-embedding"] 16 | target-ios = ["rsx-embedding/ios-embedding"] 17 | 18 | [profile.dev] 19 | codegen-units = 4 20 | 21 | [profile.release] 22 | opt-level = 3 23 | lto = true 24 | 25 | [dependencies] 26 | rsx = { git = "https://github.com/victorporof/rsx.git", default-features = false } 27 | # rsx-embedding = { git = "https://github.com/victorporof/rsx-embedding.git", default-features = false } 28 | rsx-embedding = { path = "../reactenstein/rsx-embedding/rsx-targets", default-features = false } 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **Under heavy research and development, please don't use this yet!** 2 | 3 | # rsx-demo 4 | [![License: MPL 2.0](https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0) 5 | 6 | Several demos for embedding [RSX](https://github.com/victorporof/rsx) and rendering display lists generated by the [RSX Primitives](https://github.com/victorporof/rsx-primitives) library. 7 | 8 | ## Purpose 9 | Quick and easy example code. For much more in-depth walkthroughs and documentation on how to build your own projects from scratch, see [this](https://github.com/victorporof/rsx-renderers). 10 | 11 | ## How to build 12 | First, clone this repository recursively: 13 | ``` 14 | git clone git@github.com:victorporof/rsx-demo.git --recursive 15 | ``` 16 | 17 | Finally, edit the `Cargo.toml` file to specify which target you want to build for. The default target is [WebRender](https://github.com/servo/webrender), so you don't need to edit the file for that target. 18 | 19 | ### Building for native targets with WebRender 20 | Edit the `Cargo.toml` file to specify a native target and make sure the project isn't set up to compile as a library. 21 | 22 | #### Cargo.toml 23 | ```toml 24 | [features] 25 | default = ["target-native"] 26 | ``` 27 | 28 | Then, simply 29 | ``` 30 | cargo run 31 | ``` 32 | 33 | ### Building for web targets 34 | Edit the `Cargo.toml` file to specify a web target and make sure the project isn't set up to compile as a library. 35 | 36 | #### Cargo.toml 37 | ```toml 38 | [features] 39 | default = ["target-web"] 40 | ``` 41 | 42 | As prerequisites, you need to install [Emscripten](https://kripken.github.io/emscripten-site/docs/getting_started/index.html), a couple of Rust targets, as well as some `npm` development dependencies. 43 | 44 | #### Installing Rust targets 45 | 46 | ``` 47 | rustup target add asmjs-unknown-emscripten 48 | rustup target add wasm32-unknown-emscripten 49 | ``` 50 | 51 | #### Installing Emscripten 52 | 53 | Follow the steps outlined in the [official docs](https://kripken.github.io/emscripten-site/docs/getting_started/index.html), or build from source from the [Github repo](https://github.com/juj/emsdk). If you're using [fish](https://fishshell.com) as your shell, the `emsdk_env.sh` script won't add the necessary entries to your $PATH, so either run it under `sh` or add the paths yourself. 54 | 55 | ``` 56 | ./emsdk update 57 | ./emsdk install latest 58 | ./emsdk activate latest 59 | source ./emsdk_env.sh 60 | ``` 61 | 62 | #### Installing NPM dependencies 63 | 64 | ``` 65 | npm install 66 | ``` 67 | 68 | #### Building and running 69 | 70 | ``` 71 | cargo build --target=asmjs-unknown-emscripten 72 | npm start 73 | ``` 74 | 75 | First time builds can take a very long time! Be patient. 76 | 77 | ### Building for iOS targets 78 | Edit the `Cargo.toml` file to specify an iOS target and make this crate a library. As prerequisites, you need to install the appropriate architectures, as well as `cargo-lipo` and build [jemalloc](https://github.com/jemalloc/jemalloc). 79 | 80 | #### Cargo.toml 81 | ```toml 82 | [lib] 83 | name = "rsx_demo" 84 | path = "src/main.rs" 85 | crate-type = ["staticlib", "cdylib"] 86 | 87 | [features] 88 | default = ["target-ios"] 89 | ``` 90 | 91 | Then, install the appropriate architectures, as well as `cargo-lipo`: 92 | ``` 93 | rustup target add aarch64-apple-ios armv7-apple-ios armv7s-apple-ios x86_64-apple-ios i386-apple-ios 94 | cargo install cargo-lipo 95 | ``` 96 | 97 | Then simply: 98 | ``` 99 | cargo lipo --release 100 | ``` 101 | 102 | Then open XCode project, first installing the [CocoaPods](https://cocoapods.org) dependencies: 103 | ``` 104 | cd fixtures/ios/Example/ 105 | pod install 106 | open Example.xcworkspace 107 | ``` 108 | 109 | ## Write your own frontend 110 | To make changes to the underlying Rust code, simply edit `main.rs` and `example.css` files inside the [src](https://github.com/victorporof/rsx-demo/tree/master/src) directory. For more examples and syntax, see the [RSX](https://github.com/victorporof/rsx) compiler plugin crate. 111 | 112 | ### Caveats 113 | 1. Editing CSS files require Rust files to be re-saved before building. This is because `cargo build` tries really hard not to rebuild if not necessary, and CSS files aren't on its radar. 114 | 2. Mutation and user input isn't fully supported yet. Although support is trivial to add, there's no implementation or example code yet. Stay tuned. -------------------------------------------------------------------------------- /build-jemalloc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright 2016 Mozilla 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | # this file except in compliance with the License. You may obtain a copy of the 5 | # License at http://www.apache.org/licenses/LICENSE-2.0 6 | # Unless required by applicable law or agreed to in writing, software distributed 7 | # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 8 | # CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | # specific language governing permissions and limitations under the License. 10 | 11 | ROOT_DIR=`pwd` 12 | WORK_DIR="jemalloc" 13 | 14 | JEMALLOC_VERSION="5.0.1" 15 | ARCHS=("i386" "armv7" "armv7s" "arm64" "x86_64") 16 | IOS_SDK_VERSION="11.0" 17 | 18 | if [ -d "${WORK_DIR}/download" ]; then 19 | rm -rf "${WORK_DIR}/download" 20 | fi 21 | 22 | if [ -d "${WORK_DIR}/src" ]; then 23 | rm -rf "${WORK_DIR}/src" 24 | fi 25 | 26 | mkdir -p "${WORK_DIR}/download" 27 | mkdir -p "${WORK_DIR}/src" 28 | 29 | JEMALLOC_DOWNLOAD_SRC="https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/jemalloc-${JEMALLOC_VERSION}.tar.bz2" 30 | JEMALLOC_DOWNLOAD_DST="${WORK_DIR}/download/jemalloc-${JEMALLOC_VERSION}.tar.bz2" 31 | curl -Lo ${JEMALLOC_DOWNLOAD_DST} ${JEMALLOC_DOWNLOAD_SRC} 32 | 33 | if [ $? -eq 0 ]; then 34 | tar xjf ${JEMALLOC_DOWNLOAD_DST} -C ${WORK_DIR}/src 35 | 36 | if [ $? -eq 0 ]; then 37 | for ARCH in "${ARCHS[@]}"; do 38 | cd "${ROOT_DIR}" 39 | 40 | if [ -d "${WORK_DIR}/output/${ARCH}" ]; then 41 | rm -rf "${WORK_DIR}/output/${ARCH}" 42 | fi 43 | mkdir -p "${WORK_DIR}/output/${ARCH}" 44 | cp -R "${WORK_DIR}/src/jemalloc-${JEMALLOC_VERSION}/" "${WORK_DIR}/output/${ARCH}" 45 | 46 | if [ -d "${WORK_DIR}/install/${ARCH}" ]; then 47 | rm -rf "${WORK_DIR}/install/${ARCH}" 48 | fi 49 | mkdir -p "${WORK_DIR}/install/${ARCH}" 50 | 51 | if [ $ARCH == "i386" ] || [ $ARCH == "x86_64" ]; then 52 | PLATFORM="iPhoneSimulator" 53 | else 54 | PLATFORM="iPhoneOS" 55 | fi 56 | 57 | BUILD_SDKROOT="/Applications/Xcode.app/Contents/Developer/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${IOS_SDK_VERSION}.sdk" 58 | 59 | export LDFLAGS="-arch ${ARCH} -pipe -isysroot ${BUILD_SDKROOT} -miphoneos-version-min=10.0 -Os" 60 | export CFLAGS=${LDFLAGS} 61 | 62 | export CPPFLAGS="${CFLAGS} -w" 63 | export CXXFLAGS=${CXXFLAGS} 64 | 65 | export CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" 66 | export CCXX="${CC}++" 67 | 68 | cd "${ROOT_DIR}/${WORK_DIR}/output/${ARCH}" 69 | 70 | if [ -d "${WORK_DIR}/download" ]; then 71 | rm -rf "${WORK_DIR}/download" 72 | fi 73 | 74 | if [ $ARCH == "arm64" ]; then 75 | HOST="aarch64" 76 | else 77 | HOST="${ARCH}" 78 | fi 79 | 80 | ./configure --host="${HOST}-apple-darwin" \ 81 | --prefix="${ROOT_DIR}/${WORK_DIR}/install/${ARCH}" \ 82 | --disable-zone-allocator \ 83 | --disable-utrace \ 84 | --disable-debug 85 | 86 | if [ $? -eq 0 ]; then 87 | make 88 | 89 | if [ $? -eq 0 ]; then 90 | make install 91 | 92 | if [ $? -ne 0 ]; then 93 | echo "Error installing: ${ARCH}" 94 | fi 95 | else 96 | echo "Error compiling: ${ARCH}" 97 | fi 98 | else 99 | echo "Error configuring: ${ARCH}" 100 | fi 101 | done 102 | 103 | cd "${ROOT_DIR}/${WORK_DIR}" 104 | if [ -f "libjemalloc.a" ]; then 105 | rm -f "libjemalloc.a" 106 | fi 107 | 108 | LIPO_CMD="lipo -create" 109 | for ARCH in "${ARCHS[@]}"; do 110 | if [ -f "${ROOT_DIR}/${WORK_DIR}/install/${ARCH}/lib/libjemalloc.a" ]; then 111 | LIPO_CMD="$LIPO_CMD ${ROOT_DIR}/${WORK_DIR}/install/${ARCH}/lib/libjemalloc.a" 112 | fi 113 | done 114 | 115 | LIPO_CMD="$LIPO_CMD -output libjemalloc.a" 116 | eval $LIPO_CMD 117 | 118 | if [ $? -ne 0 ]; then 119 | echo "Error creating flat library" 120 | fi 121 | else 122 | echo "Error uncompressing" 123 | fi 124 | else 125 | echo "Error downloading" 126 | fi 127 | -------------------------------------------------------------------------------- /fixtures/fonts/FiraMono-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victorporof/rsx-demo/3f8a7a254bb2c62f7864c808691e658ff51366fe/fixtures/fonts/FiraMono-Regular.ttf -------------------------------------------------------------------------------- /fixtures/fonts/FreeSans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victorporof/rsx-demo/3f8a7a254bb2c62f7864c808691e658ff51366fe/fixtures/fonts/FreeSans.ttf -------------------------------------------------------------------------------- /fixtures/images/Firefox.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victorporof/rsx-demo/3f8a7a254bb2c62f7864c808691e658ff51366fe/fixtures/images/Firefox.jpg -------------------------------------------------------------------------------- /fixtures/images/Quantum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victorporof/rsx-demo/3f8a7a254bb2c62f7864c808691e658ff51366fe/fixtures/images/Quantum.png -------------------------------------------------------------------------------- /fixtures/ios/Example/Example.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1611E3AC04F1CD0A3CDF2F9C /* Pods_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2FCB8F1EB6DD61B1B0AE438E /* Pods_Example.framework */; }; 11 | 570383FB1F9091B000F37BD0 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 570383FA1F9091B000F37BD0 /* AppDelegate.swift */; }; 12 | 570383FD1F9091B000F37BD0 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 570383FC1F9091B000F37BD0 /* ViewController.swift */; }; 13 | 570384001F9091B000F37BD0 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 570383FE1F9091B000F37BD0 /* Main.storyboard */; }; 14 | 570384021F9091B000F37BD0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 570384011F9091B000F37BD0 /* Assets.xcassets */; }; 15 | 570384051F9091B000F37BD0 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 570384031F9091B000F37BD0 /* LaunchScreen.storyboard */; }; 16 | 5703840F1F9092AD00F37BD0 /* Bridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5703840E1F9092AD00F37BD0 /* Bridge.swift */; }; 17 | 570384141F9093FA00F37BD0 /* libresolv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 570384131F9093FA00F37BD0 /* libresolv.tbd */; }; 18 | 570384161F90940900F37BD0 /* libjemalloc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 570384151F90940900F37BD0 /* libjemalloc.a */; }; 19 | 570384181F9098B200F37BD0 /* librsx_demo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 570384171F9098B200F37BD0 /* librsx_demo.a */; }; 20 | 578CF67F1F909A6A005482B5 /* UIViewRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 578CF67E1F909A6A005482B5 /* UIViewRenderer.swift */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | 2FCB8F1EB6DD61B1B0AE438E /* Pods_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 25 | 570383F71F9091B000F37BD0 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 26 | 570383FA1F9091B000F37BD0 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 27 | 570383FC1F9091B000F37BD0 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 28 | 570383FF1F9091B000F37BD0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 29 | 570384011F9091B000F37BD0 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 30 | 570384041F9091B000F37BD0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 31 | 570384061F9091B000F37BD0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | 5703840E1F9092AD00F37BD0 /* Bridge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Bridge.swift; sourceTree = ""; }; 33 | 570384101F9092C200F37BD0 /* bridging-header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "bridging-header.h"; path = "../bridging-header.h"; sourceTree = ""; }; 34 | 570384111F9092C200F37BD0 /* externals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = externals.h; path = ../externals.h; sourceTree = ""; }; 35 | 570384131F9093FA00F37BD0 /* libresolv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libresolv.tbd; path = usr/lib/libresolv.tbd; sourceTree = SDKROOT; }; 36 | 570384151F90940900F37BD0 /* libjemalloc.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libjemalloc.a; path = ../../../jemalloc/libjemalloc.a; sourceTree = ""; }; 37 | 570384171F9098B200F37BD0 /* librsx_demo.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = librsx_demo.a; path = ../../../target/universal/release/librsx_demo.a; sourceTree = ""; }; 38 | 578CF67E1F909A6A005482B5 /* UIViewRenderer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UIViewRenderer.swift; path = "../../../rsx-renderers/src/target-ios/UIViewRenderer.swift"; sourceTree = ""; }; 39 | 85D0C89F570D22823053246B /* Pods-Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Example/Pods-Example.debug.xcconfig"; sourceTree = ""; }; 40 | C36ECBB4322E7C5C609F3C48 /* Pods-Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-Example/Pods-Example.release.xcconfig"; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | 570383F41F9091B000F37BD0 /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | 570384181F9098B200F37BD0 /* librsx_demo.a in Frameworks */, 49 | 570384161F90940900F37BD0 /* libjemalloc.a in Frameworks */, 50 | 570384141F9093FA00F37BD0 /* libresolv.tbd in Frameworks */, 51 | 1611E3AC04F1CD0A3CDF2F9C /* Pods_Example.framework in Frameworks */, 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXFrameworksBuildPhase section */ 56 | 57 | /* Begin PBXGroup section */ 58 | 570383EE1F9091B000F37BD0 = { 59 | isa = PBXGroup; 60 | children = ( 61 | 578CF67E1F909A6A005482B5 /* UIViewRenderer.swift */, 62 | 570384101F9092C200F37BD0 /* bridging-header.h */, 63 | 570384111F9092C200F37BD0 /* externals.h */, 64 | 570383F91F9091B000F37BD0 /* Example */, 65 | 570383F81F9091B000F37BD0 /* Products */, 66 | 570384121F9093FA00F37BD0 /* Frameworks */, 67 | FE78045FBF9AF876AB745A28 /* Pods */, 68 | ); 69 | sourceTree = ""; 70 | }; 71 | 570383F81F9091B000F37BD0 /* Products */ = { 72 | isa = PBXGroup; 73 | children = ( 74 | 570383F71F9091B000F37BD0 /* Example.app */, 75 | ); 76 | name = Products; 77 | sourceTree = ""; 78 | }; 79 | 570383F91F9091B000F37BD0 /* Example */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | 570383FA1F9091B000F37BD0 /* AppDelegate.swift */, 83 | 570383FC1F9091B000F37BD0 /* ViewController.swift */, 84 | 570383FE1F9091B000F37BD0 /* Main.storyboard */, 85 | 570384011F9091B000F37BD0 /* Assets.xcassets */, 86 | 570384031F9091B000F37BD0 /* LaunchScreen.storyboard */, 87 | 570384061F9091B000F37BD0 /* Info.plist */, 88 | 5703840E1F9092AD00F37BD0 /* Bridge.swift */, 89 | ); 90 | path = Example; 91 | sourceTree = ""; 92 | }; 93 | 570384121F9093FA00F37BD0 /* Frameworks */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | 570384171F9098B200F37BD0 /* librsx_demo.a */, 97 | 570384151F90940900F37BD0 /* libjemalloc.a */, 98 | 570384131F9093FA00F37BD0 /* libresolv.tbd */, 99 | 2FCB8F1EB6DD61B1B0AE438E /* Pods_Example.framework */, 100 | ); 101 | name = Frameworks; 102 | sourceTree = ""; 103 | }; 104 | FE78045FBF9AF876AB745A28 /* Pods */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | 85D0C89F570D22823053246B /* Pods-Example.debug.xcconfig */, 108 | C36ECBB4322E7C5C609F3C48 /* Pods-Example.release.xcconfig */, 109 | ); 110 | name = Pods; 111 | sourceTree = ""; 112 | }; 113 | /* End PBXGroup section */ 114 | 115 | /* Begin PBXNativeTarget section */ 116 | 570383F61F9091B000F37BD0 /* Example */ = { 117 | isa = PBXNativeTarget; 118 | buildConfigurationList = 570384091F9091B000F37BD0 /* Build configuration list for PBXNativeTarget "Example" */; 119 | buildPhases = ( 120 | 520207E94F8129C96C75E3A1 /* [CP] Check Pods Manifest.lock */, 121 | 570383F31F9091B000F37BD0 /* Sources */, 122 | 570383F41F9091B000F37BD0 /* Frameworks */, 123 | 570383F51F9091B000F37BD0 /* Resources */, 124 | 3C361249240CB87A32679883 /* [CP] Embed Pods Frameworks */, 125 | 2051548307A9876AE9DCF758 /* [CP] Copy Pods Resources */, 126 | ); 127 | buildRules = ( 128 | ); 129 | dependencies = ( 130 | ); 131 | name = Example; 132 | productName = Example; 133 | productReference = 570383F71F9091B000F37BD0 /* Example.app */; 134 | productType = "com.apple.product-type.application"; 135 | }; 136 | /* End PBXNativeTarget section */ 137 | 138 | /* Begin PBXProject section */ 139 | 570383EF1F9091B000F37BD0 /* Project object */ = { 140 | isa = PBXProject; 141 | attributes = { 142 | LastSwiftUpdateCheck = 0900; 143 | LastUpgradeCheck = 0900; 144 | ORGANIZATIONNAME = "Victor Porof"; 145 | TargetAttributes = { 146 | 570383F61F9091B000F37BD0 = { 147 | CreatedOnToolsVersion = 9.0; 148 | ProvisioningStyle = Automatic; 149 | }; 150 | }; 151 | }; 152 | buildConfigurationList = 570383F21F9091B000F37BD0 /* Build configuration list for PBXProject "Example" */; 153 | compatibilityVersion = "Xcode 8.0"; 154 | developmentRegion = en; 155 | hasScannedForEncodings = 0; 156 | knownRegions = ( 157 | en, 158 | Base, 159 | ); 160 | mainGroup = 570383EE1F9091B000F37BD0; 161 | productRefGroup = 570383F81F9091B000F37BD0 /* Products */; 162 | projectDirPath = ""; 163 | projectRoot = ""; 164 | targets = ( 165 | 570383F61F9091B000F37BD0 /* Example */, 166 | ); 167 | }; 168 | /* End PBXProject section */ 169 | 170 | /* Begin PBXResourcesBuildPhase section */ 171 | 570383F51F9091B000F37BD0 /* Resources */ = { 172 | isa = PBXResourcesBuildPhase; 173 | buildActionMask = 2147483647; 174 | files = ( 175 | 570384051F9091B000F37BD0 /* LaunchScreen.storyboard in Resources */, 176 | 570384021F9091B000F37BD0 /* Assets.xcassets in Resources */, 177 | 570384001F9091B000F37BD0 /* Main.storyboard in Resources */, 178 | ); 179 | runOnlyForDeploymentPostprocessing = 0; 180 | }; 181 | /* End PBXResourcesBuildPhase section */ 182 | 183 | /* Begin PBXShellScriptBuildPhase section */ 184 | 2051548307A9876AE9DCF758 /* [CP] Copy Pods Resources */ = { 185 | isa = PBXShellScriptBuildPhase; 186 | buildActionMask = 2147483647; 187 | files = ( 188 | ); 189 | inputPaths = ( 190 | ); 191 | name = "[CP] Copy Pods Resources"; 192 | outputPaths = ( 193 | ); 194 | runOnlyForDeploymentPostprocessing = 0; 195 | shellPath = /bin/sh; 196 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Example/Pods-Example-resources.sh\"\n"; 197 | showEnvVarsInLog = 0; 198 | }; 199 | 3C361249240CB87A32679883 /* [CP] Embed Pods Frameworks */ = { 200 | isa = PBXShellScriptBuildPhase; 201 | buildActionMask = 2147483647; 202 | files = ( 203 | ); 204 | inputPaths = ( 205 | "${SRCROOT}/Pods/Target Support Files/Pods-Example/Pods-Example-frameworks.sh", 206 | "${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework", 207 | ); 208 | name = "[CP] Embed Pods Frameworks"; 209 | outputPaths = ( 210 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyJSON.framework", 211 | ); 212 | runOnlyForDeploymentPostprocessing = 0; 213 | shellPath = /bin/sh; 214 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Example/Pods-Example-frameworks.sh\"\n"; 215 | showEnvVarsInLog = 0; 216 | }; 217 | 520207E94F8129C96C75E3A1 /* [CP] Check Pods Manifest.lock */ = { 218 | isa = PBXShellScriptBuildPhase; 219 | buildActionMask = 2147483647; 220 | files = ( 221 | ); 222 | inputPaths = ( 223 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 224 | "${PODS_ROOT}/Manifest.lock", 225 | ); 226 | name = "[CP] Check Pods Manifest.lock"; 227 | outputPaths = ( 228 | "$(DERIVED_FILE_DIR)/Pods-Example-checkManifestLockResult.txt", 229 | ); 230 | runOnlyForDeploymentPostprocessing = 0; 231 | shellPath = /bin/sh; 232 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 233 | showEnvVarsInLog = 0; 234 | }; 235 | /* End PBXShellScriptBuildPhase section */ 236 | 237 | /* Begin PBXSourcesBuildPhase section */ 238 | 570383F31F9091B000F37BD0 /* Sources */ = { 239 | isa = PBXSourcesBuildPhase; 240 | buildActionMask = 2147483647; 241 | files = ( 242 | 570383FD1F9091B000F37BD0 /* ViewController.swift in Sources */, 243 | 570383FB1F9091B000F37BD0 /* AppDelegate.swift in Sources */, 244 | 5703840F1F9092AD00F37BD0 /* Bridge.swift in Sources */, 245 | 578CF67F1F909A6A005482B5 /* UIViewRenderer.swift in Sources */, 246 | ); 247 | runOnlyForDeploymentPostprocessing = 0; 248 | }; 249 | /* End PBXSourcesBuildPhase section */ 250 | 251 | /* Begin PBXVariantGroup section */ 252 | 570383FE1F9091B000F37BD0 /* Main.storyboard */ = { 253 | isa = PBXVariantGroup; 254 | children = ( 255 | 570383FF1F9091B000F37BD0 /* Base */, 256 | ); 257 | name = Main.storyboard; 258 | sourceTree = ""; 259 | }; 260 | 570384031F9091B000F37BD0 /* LaunchScreen.storyboard */ = { 261 | isa = PBXVariantGroup; 262 | children = ( 263 | 570384041F9091B000F37BD0 /* Base */, 264 | ); 265 | name = LaunchScreen.storyboard; 266 | sourceTree = ""; 267 | }; 268 | /* End PBXVariantGroup section */ 269 | 270 | /* Begin XCBuildConfiguration section */ 271 | 570384071F9091B000F37BD0 /* Debug */ = { 272 | isa = XCBuildConfiguration; 273 | buildSettings = { 274 | ALWAYS_SEARCH_USER_PATHS = NO; 275 | CLANG_ANALYZER_NONNULL = YES; 276 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 277 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 278 | CLANG_CXX_LIBRARY = "libc++"; 279 | CLANG_ENABLE_MODULES = YES; 280 | CLANG_ENABLE_OBJC_ARC = YES; 281 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 282 | CLANG_WARN_BOOL_CONVERSION = YES; 283 | CLANG_WARN_COMMA = YES; 284 | CLANG_WARN_CONSTANT_CONVERSION = YES; 285 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 286 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 287 | CLANG_WARN_EMPTY_BODY = YES; 288 | CLANG_WARN_ENUM_CONVERSION = YES; 289 | CLANG_WARN_INFINITE_RECURSION = YES; 290 | CLANG_WARN_INT_CONVERSION = YES; 291 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 292 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 293 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 294 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 295 | CLANG_WARN_STRICT_PROTOTYPES = YES; 296 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 297 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 298 | CLANG_WARN_UNREACHABLE_CODE = YES; 299 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 300 | CODE_SIGN_IDENTITY = "iPhone Developer"; 301 | COPY_PHASE_STRIP = NO; 302 | DEBUG_INFORMATION_FORMAT = dwarf; 303 | ENABLE_STRICT_OBJC_MSGSEND = YES; 304 | ENABLE_TESTABILITY = YES; 305 | GCC_C_LANGUAGE_STANDARD = gnu11; 306 | GCC_DYNAMIC_NO_PIC = NO; 307 | GCC_NO_COMMON_BLOCKS = YES; 308 | GCC_OPTIMIZATION_LEVEL = 0; 309 | GCC_PREPROCESSOR_DEFINITIONS = ( 310 | "DEBUG=1", 311 | "$(inherited)", 312 | ); 313 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 314 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 315 | GCC_WARN_UNDECLARED_SELECTOR = YES; 316 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 317 | GCC_WARN_UNUSED_FUNCTION = YES; 318 | GCC_WARN_UNUSED_VARIABLE = YES; 319 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 320 | MTL_ENABLE_DEBUG_INFO = YES; 321 | ONLY_ACTIVE_ARCH = YES; 322 | SDKROOT = iphoneos; 323 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 324 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 325 | }; 326 | name = Debug; 327 | }; 328 | 570384081F9091B000F37BD0 /* Release */ = { 329 | isa = XCBuildConfiguration; 330 | buildSettings = { 331 | ALWAYS_SEARCH_USER_PATHS = NO; 332 | CLANG_ANALYZER_NONNULL = YES; 333 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 334 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 335 | CLANG_CXX_LIBRARY = "libc++"; 336 | CLANG_ENABLE_MODULES = YES; 337 | CLANG_ENABLE_OBJC_ARC = YES; 338 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 339 | CLANG_WARN_BOOL_CONVERSION = YES; 340 | CLANG_WARN_COMMA = YES; 341 | CLANG_WARN_CONSTANT_CONVERSION = YES; 342 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 343 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 344 | CLANG_WARN_EMPTY_BODY = YES; 345 | CLANG_WARN_ENUM_CONVERSION = YES; 346 | CLANG_WARN_INFINITE_RECURSION = YES; 347 | CLANG_WARN_INT_CONVERSION = YES; 348 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 349 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 350 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 351 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 352 | CLANG_WARN_STRICT_PROTOTYPES = YES; 353 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 354 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 355 | CLANG_WARN_UNREACHABLE_CODE = YES; 356 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 357 | CODE_SIGN_IDENTITY = "iPhone Developer"; 358 | COPY_PHASE_STRIP = NO; 359 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 360 | ENABLE_NS_ASSERTIONS = NO; 361 | ENABLE_STRICT_OBJC_MSGSEND = YES; 362 | GCC_C_LANGUAGE_STANDARD = gnu11; 363 | GCC_NO_COMMON_BLOCKS = YES; 364 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 365 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 366 | GCC_WARN_UNDECLARED_SELECTOR = YES; 367 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 368 | GCC_WARN_UNUSED_FUNCTION = YES; 369 | GCC_WARN_UNUSED_VARIABLE = YES; 370 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 371 | MTL_ENABLE_DEBUG_INFO = NO; 372 | SDKROOT = iphoneos; 373 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 374 | VALIDATE_PRODUCT = YES; 375 | }; 376 | name = Release; 377 | }; 378 | 5703840A1F9091B000F37BD0 /* Debug */ = { 379 | isa = XCBuildConfiguration; 380 | baseConfigurationReference = 85D0C89F570D22823053246B /* Pods-Example.debug.xcconfig */; 381 | buildSettings = { 382 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 383 | CODE_SIGN_STYLE = Automatic; 384 | INFOPLIST_FILE = Example/Info.plist; 385 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 386 | LIBRARY_SEARCH_PATHS = ( 387 | "$(PROJECT_DIR)/../../../jemalloc", 388 | "$(PROJECT_DIR)/../../../target/universal/release", 389 | ); 390 | PRODUCT_BUNDLE_IDENTIFIER = com.victorporof.Example; 391 | PRODUCT_NAME = "$(TARGET_NAME)"; 392 | SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/../bridging-header.h"; 393 | SWIFT_VERSION = 4.0; 394 | TARGETED_DEVICE_FAMILY = "1,2"; 395 | }; 396 | name = Debug; 397 | }; 398 | 5703840B1F9091B000F37BD0 /* Release */ = { 399 | isa = XCBuildConfiguration; 400 | baseConfigurationReference = C36ECBB4322E7C5C609F3C48 /* Pods-Example.release.xcconfig */; 401 | buildSettings = { 402 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 403 | CODE_SIGN_STYLE = Automatic; 404 | INFOPLIST_FILE = Example/Info.plist; 405 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 406 | LIBRARY_SEARCH_PATHS = ( 407 | "$(PROJECT_DIR)/../../../jemalloc", 408 | "$(PROJECT_DIR)/../../../target/universal/release", 409 | ); 410 | PRODUCT_BUNDLE_IDENTIFIER = com.victorporof.Example; 411 | PRODUCT_NAME = "$(TARGET_NAME)"; 412 | SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/../bridging-header.h"; 413 | SWIFT_VERSION = 4.0; 414 | TARGETED_DEVICE_FAMILY = "1,2"; 415 | }; 416 | name = Release; 417 | }; 418 | /* End XCBuildConfiguration section */ 419 | 420 | /* Begin XCConfigurationList section */ 421 | 570383F21F9091B000F37BD0 /* Build configuration list for PBXProject "Example" */ = { 422 | isa = XCConfigurationList; 423 | buildConfigurations = ( 424 | 570384071F9091B000F37BD0 /* Debug */, 425 | 570384081F9091B000F37BD0 /* Release */, 426 | ); 427 | defaultConfigurationIsVisible = 0; 428 | defaultConfigurationName = Release; 429 | }; 430 | 570384091F9091B000F37BD0 /* Build configuration list for PBXNativeTarget "Example" */ = { 431 | isa = XCConfigurationList; 432 | buildConfigurations = ( 433 | 5703840A1F9091B000F37BD0 /* Debug */, 434 | 5703840B1F9091B000F37BD0 /* Release */, 435 | ); 436 | defaultConfigurationIsVisible = 0; 437 | defaultConfigurationName = Release; 438 | }; 439 | /* End XCConfigurationList section */ 440 | }; 441 | rootObject = 570383EF1F9091B000F37BD0 /* Project object */; 442 | } 443 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Example.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Example/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Mozilla 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | this file except in compliance with the License. You may obtain a copy of the 5 | License at http://www.apache.org/licenses/LICENSE-2.0 6 | Unless required by applicable law or agreed to in writing, software distributed 7 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 8 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | import UIKit 13 | 14 | @UIApplicationMain 15 | class AppDelegate: UIResponder, UIApplicationDelegate { 16 | 17 | var window: UIWindow? 18 | 19 | 20 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 21 | // Override point for customization after application launch. 22 | return true 23 | } 24 | 25 | func applicationWillResignActive(_ application: UIApplication) { 26 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 27 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 28 | } 29 | 30 | func applicationDidEnterBackground(_ application: UIApplication) { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | func applicationWillEnterForeground(_ application: UIApplication) { 36 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 37 | } 38 | 39 | func applicationDidBecomeActive(_ application: UIApplication) { 40 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 41 | } 42 | 43 | func applicationWillTerminate(_ application: UIApplication) { 44 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 45 | } 46 | 47 | 48 | } 49 | 50 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /fixtures/ios/Example/Example/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Example/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Example/Bridge.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Mozilla 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | this file except in compliance with the License. You may obtain a copy of the 5 | License at http://www.apache.org/licenses/LICENSE-2.0 6 | Unless required by applicable law or agreed to in writing, software distributed 7 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 8 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | import Foundation 13 | import SwiftyJSON 14 | 15 | class Bridge { 16 | func getDisplayList(width: Float, height: Float) -> JSON { 17 | let result = __get_display_list(width, height) 18 | let swift_result = String(cString: result!) 19 | let json = JSON(data: swift_result.data(using: .utf8)!) 20 | __free_display_list(UnsafeMutablePointer(mutating: result)) 21 | return json 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | NSAppTransportSecurity 24 | 25 | NSAllowsArbitraryLoads 26 | 27 | 28 | UILaunchStoryboardName 29 | LaunchScreen 30 | UIMainStoryboardFile 31 | Main 32 | UIRequiredDeviceCapabilities 33 | 34 | armv7 35 | 36 | UISupportedInterfaceOrientations 37 | 38 | UIInterfaceOrientationPortrait 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UISupportedInterfaceOrientations~ipad 43 | 44 | UIInterfaceOrientationPortrait 45 | UIInterfaceOrientationPortraitUpsideDown 46 | UIInterfaceOrientationLandscapeLeft 47 | UIInterfaceOrientationLandscapeRight 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Example/ViewController.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Mozilla 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | this file except in compliance with the License. You may obtain a copy of the 5 | License at http://www.apache.org/licenses/LICENSE-2.0 6 | Unless required by applicable law or agreed to in writing, software distributed 7 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 8 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | import UIKit 13 | 14 | class ViewController: UIViewController { 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | // Do any additional setup after loading the view, typically from a nib. 19 | 20 | let sizeRect = self.view.frame.size 21 | let width = Float(sizeRect.width) 22 | let height = Float(sizeRect.height) 23 | 24 | let bridge = Bridge() 25 | let displayList = bridge.getDisplayList(width: width, height: height) 26 | 27 | let renderer = UIViewRenderer(deviceWidth: width, deviceHeight: height) 28 | renderer.mount(parentView: self.view) 29 | renderer.draw(displayList: displayList) 30 | } 31 | 32 | override func didReceiveMemoryWarning() { 33 | super.didReceiveMemoryWarning() 34 | // Dispose of any resources that can be recreated. 35 | } 36 | 37 | 38 | } 39 | 40 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '11.0' 2 | 3 | target 'Example' do 4 | use_frameworks! 5 | 6 | pod 'SwiftyJSON' 7 | 8 | end 9 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - SwiftyJSON (3.1.4) 3 | 4 | DEPENDENCIES: 5 | - SwiftyJSON 6 | 7 | SPEC CHECKSUMS: 8 | SwiftyJSON: c2842d878f95482ffceec5709abc3d05680c0220 9 | 10 | PODFILE CHECKSUM: 9c089e7c8b2e71bfbded12a7083847e5fdf55639 11 | 12 | COCOAPODS: 1.3.1 13 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - SwiftyJSON (3.1.4) 3 | 4 | DEPENDENCIES: 5 | - SwiftyJSON 6 | 7 | SPEC CHECKSUMS: 8 | SwiftyJSON: c2842d878f95482ffceec5709abc3d05680c0220 9 | 10 | PODFILE CHECKSUM: 9c089e7c8b2e71bfbded12a7083847e5fdf55639 11 | 12 | COCOAPODS: 1.3.1 13 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/Pods.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1536DD0A2D0BC01C739FFBFFCC2CE424 /* SwiftyJSON-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 32B9BBA8F5B33E56C38F5546432F66B7 /* SwiftyJSON-dummy.m */; }; 11 | 15441E35D9E4818952F7B19B88249681 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6604A7D69453B4569E4E4827FB9155A9 /* Foundation.framework */; }; 12 | 16D442A2455B91355FEC0F1872C2DBEE /* SwiftyJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDE506ECE97701EBA44FDBFF401C1A04 /* SwiftyJSON.swift */; }; 13 | 55C62BFC8DD0DF7231695AE9B28E1B4D /* SwiftyJSON-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 05CA09B061E193906653AC21FD3A94F1 /* SwiftyJSON-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; 14 | 680B9FAEBC32C69E2772503D95397274 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6604A7D69453B4569E4E4827FB9155A9 /* Foundation.framework */; }; 15 | C402474C1F1FA57E73335B9D4FC07119 /* Pods-Example-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 699118D7DDD5F335E4FB8B17DC0F12D2 /* Pods-Example-dummy.m */; }; 16 | D6C9B526977E077DE22460235F6E6000 /* Pods-Example-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = C9BDE82371C83FA9AE91B05F77ACAA36 /* Pods-Example-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | 8CA0CC8C58194BD1C80DB0A33CD05058 /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = 2EF2763772B3AD8C7CD93AF1AFA132D5; 25 | remoteInfo = SwiftyJSON; 26 | }; 27 | /* End PBXContainerItemProxy section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | 01E6907CF2644EB1CF8E23F708A3DA0B /* Pods-Example-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-Example-resources.sh"; sourceTree = ""; }; 31 | 05CA09B061E193906653AC21FD3A94F1 /* SwiftyJSON-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SwiftyJSON-umbrella.h"; sourceTree = ""; }; 32 | 119072C64A19799964E1620D83F514FB /* Pods-Example.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; path = "Pods-Example.modulemap"; sourceTree = ""; }; 33 | 149054C495E8EC590CAB4C524133016F /* Pods-Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-Example.debug.xcconfig"; sourceTree = ""; }; 34 | 2E7F7C62EE34D2D271E6E1234A2002B2 /* SwiftyJSON.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = SwiftyJSON.xcconfig; sourceTree = ""; }; 35 | 30456D60236547AB19E53CCA0D534404 /* Pods_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Pods_Example.framework; path = "Pods-Example.framework"; sourceTree = BUILT_PRODUCTS_DIR; }; 36 | 32B9BBA8F5B33E56C38F5546432F66B7 /* SwiftyJSON-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "SwiftyJSON-dummy.m"; sourceTree = ""; }; 37 | 552550F3F912264E5D073F8893691F88 /* Pods-Example-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-Example-frameworks.sh"; sourceTree = ""; }; 38 | 6604A7D69453B4569E4E4827FB9155A9 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; 39 | 699118D7DDD5F335E4FB8B17DC0F12D2 /* Pods-Example-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-Example-dummy.m"; sourceTree = ""; }; 40 | 764D33E23CE6C1111110B04F5CBADADB /* Pods-Example-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-Example-acknowledgements.plist"; sourceTree = ""; }; 41 | 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; 42 | 9AD078E4F802E71C911721F58D0657A0 /* SwiftyJSON.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = SwiftyJSON.framework; path = SwiftyJSON.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | A661FECCEBFF9D01869EE3B29C4C1EFF /* Pods-Example-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-Example-acknowledgements.markdown"; sourceTree = ""; }; 44 | BBF610E40BDF6E542FA21FF7E5491205 /* SwiftyJSON-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SwiftyJSON-prefix.pch"; sourceTree = ""; }; 45 | BDE506ECE97701EBA44FDBFF401C1A04 /* SwiftyJSON.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SwiftyJSON.swift; path = Source/SwiftyJSON.swift; sourceTree = ""; }; 46 | C4A9A658C966F6BB111BEDBDEA1F874A /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 47 | C9BDE82371C83FA9AE91B05F77ACAA36 /* Pods-Example-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-Example-umbrella.h"; sourceTree = ""; }; 48 | D032A29E584B77AE187E586922267CF5 /* SwiftyJSON.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; path = SwiftyJSON.modulemap; sourceTree = ""; }; 49 | E512A5F985F876750237FD237C3AEEDA /* Pods-Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-Example.release.xcconfig"; sourceTree = ""; }; 50 | EFFB74AAA6B2AE8DABF0E88E61E09178 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 51 | /* End PBXFileReference section */ 52 | 53 | /* Begin PBXFrameworksBuildPhase section */ 54 | D2695D5E806C576BB89E3FD5324708E3 /* Frameworks */ = { 55 | isa = PBXFrameworksBuildPhase; 56 | buildActionMask = 2147483647; 57 | files = ( 58 | 15441E35D9E4818952F7B19B88249681 /* Foundation.framework in Frameworks */, 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | E4130F238FFFCC9CE491B5581811E4F2 /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | 680B9FAEBC32C69E2772503D95397274 /* Foundation.framework in Frameworks */, 67 | ); 68 | runOnlyForDeploymentPostprocessing = 0; 69 | }; 70 | /* End PBXFrameworksBuildPhase section */ 71 | 72 | /* Begin PBXGroup section */ 73 | 6A4F6A14E3FB951290E4531728B7A461 /* Targets Support Files */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | FE9811ABEB5931E154211FCA14B78350 /* Pods-Example */, 77 | ); 78 | name = "Targets Support Files"; 79 | sourceTree = ""; 80 | }; 81 | 70A8E4D3C62B6C203D238581DA091C21 /* SwiftyJSON */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | BDE506ECE97701EBA44FDBFF401C1A04 /* SwiftyJSON.swift */, 85 | 8EC39E1DC11846207722B71AAFE40F98 /* Support Files */, 86 | ); 87 | name = SwiftyJSON; 88 | path = SwiftyJSON; 89 | sourceTree = ""; 90 | }; 91 | 7DB346D0F39D3F0E887471402A8071AB = { 92 | isa = PBXGroup; 93 | children = ( 94 | 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */, 95 | BC3CA7F9E30CC8F7E2DD044DD34432FC /* Frameworks */, 96 | BD1E3C710F12F4B4C092FC8E2AD22110 /* Pods */, 97 | AC24F3551A26AA106B444AB711352500 /* Products */, 98 | 6A4F6A14E3FB951290E4531728B7A461 /* Targets Support Files */, 99 | ); 100 | sourceTree = ""; 101 | }; 102 | 8EC39E1DC11846207722B71AAFE40F98 /* Support Files */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | C4A9A658C966F6BB111BEDBDEA1F874A /* Info.plist */, 106 | D032A29E584B77AE187E586922267CF5 /* SwiftyJSON.modulemap */, 107 | 2E7F7C62EE34D2D271E6E1234A2002B2 /* SwiftyJSON.xcconfig */, 108 | 32B9BBA8F5B33E56C38F5546432F66B7 /* SwiftyJSON-dummy.m */, 109 | BBF610E40BDF6E542FA21FF7E5491205 /* SwiftyJSON-prefix.pch */, 110 | 05CA09B061E193906653AC21FD3A94F1 /* SwiftyJSON-umbrella.h */, 111 | ); 112 | name = "Support Files"; 113 | path = "../Target Support Files/SwiftyJSON"; 114 | sourceTree = ""; 115 | }; 116 | AC24F3551A26AA106B444AB711352500 /* Products */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | 30456D60236547AB19E53CCA0D534404 /* Pods_Example.framework */, 120 | 9AD078E4F802E71C911721F58D0657A0 /* SwiftyJSON.framework */, 121 | ); 122 | name = Products; 123 | sourceTree = ""; 124 | }; 125 | BC3CA7F9E30CC8F7E2DD044DD34432FC /* Frameworks */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | D35AF013A5F0BAD4F32504907A52519E /* iOS */, 129 | ); 130 | name = Frameworks; 131 | sourceTree = ""; 132 | }; 133 | BD1E3C710F12F4B4C092FC8E2AD22110 /* Pods */ = { 134 | isa = PBXGroup; 135 | children = ( 136 | 70A8E4D3C62B6C203D238581DA091C21 /* SwiftyJSON */, 137 | ); 138 | name = Pods; 139 | sourceTree = ""; 140 | }; 141 | D35AF013A5F0BAD4F32504907A52519E /* iOS */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | 6604A7D69453B4569E4E4827FB9155A9 /* Foundation.framework */, 145 | ); 146 | name = iOS; 147 | sourceTree = ""; 148 | }; 149 | FE9811ABEB5931E154211FCA14B78350 /* Pods-Example */ = { 150 | isa = PBXGroup; 151 | children = ( 152 | EFFB74AAA6B2AE8DABF0E88E61E09178 /* Info.plist */, 153 | 119072C64A19799964E1620D83F514FB /* Pods-Example.modulemap */, 154 | A661FECCEBFF9D01869EE3B29C4C1EFF /* Pods-Example-acknowledgements.markdown */, 155 | 764D33E23CE6C1111110B04F5CBADADB /* Pods-Example-acknowledgements.plist */, 156 | 699118D7DDD5F335E4FB8B17DC0F12D2 /* Pods-Example-dummy.m */, 157 | 552550F3F912264E5D073F8893691F88 /* Pods-Example-frameworks.sh */, 158 | 01E6907CF2644EB1CF8E23F708A3DA0B /* Pods-Example-resources.sh */, 159 | C9BDE82371C83FA9AE91B05F77ACAA36 /* Pods-Example-umbrella.h */, 160 | 149054C495E8EC590CAB4C524133016F /* Pods-Example.debug.xcconfig */, 161 | E512A5F985F876750237FD237C3AEEDA /* Pods-Example.release.xcconfig */, 162 | ); 163 | name = "Pods-Example"; 164 | path = "Target Support Files/Pods-Example"; 165 | sourceTree = ""; 166 | }; 167 | /* End PBXGroup section */ 168 | 169 | /* Begin PBXHeadersBuildPhase section */ 170 | 165F56393932D12D4F47D084A81D3FD2 /* Headers */ = { 171 | isa = PBXHeadersBuildPhase; 172 | buildActionMask = 2147483647; 173 | files = ( 174 | D6C9B526977E077DE22460235F6E6000 /* Pods-Example-umbrella.h in Headers */, 175 | ); 176 | runOnlyForDeploymentPostprocessing = 0; 177 | }; 178 | A101AB8DB935A2DF2364CF9BEA7FEBE6 /* Headers */ = { 179 | isa = PBXHeadersBuildPhase; 180 | buildActionMask = 2147483647; 181 | files = ( 182 | 55C62BFC8DD0DF7231695AE9B28E1B4D /* SwiftyJSON-umbrella.h in Headers */, 183 | ); 184 | runOnlyForDeploymentPostprocessing = 0; 185 | }; 186 | /* End PBXHeadersBuildPhase section */ 187 | 188 | /* Begin PBXNativeTarget section */ 189 | 2EF2763772B3AD8C7CD93AF1AFA132D5 /* SwiftyJSON */ = { 190 | isa = PBXNativeTarget; 191 | buildConfigurationList = DDD72550E295CD7C416CC2F972B0F4A4 /* Build configuration list for PBXNativeTarget "SwiftyJSON" */; 192 | buildPhases = ( 193 | 70133205CCD575B0FE5C4C63A3BA4A31 /* Sources */, 194 | D2695D5E806C576BB89E3FD5324708E3 /* Frameworks */, 195 | A101AB8DB935A2DF2364CF9BEA7FEBE6 /* Headers */, 196 | ); 197 | buildRules = ( 198 | ); 199 | dependencies = ( 200 | ); 201 | name = SwiftyJSON; 202 | productName = SwiftyJSON; 203 | productReference = 9AD078E4F802E71C911721F58D0657A0 /* SwiftyJSON.framework */; 204 | productType = "com.apple.product-type.framework"; 205 | }; 206 | 6AF8A112ED63A3AA7215C1BDA9B14152 /* Pods-Example */ = { 207 | isa = PBXNativeTarget; 208 | buildConfigurationList = 282EDB859404BAABFC6CD47226644EF6 /* Build configuration list for PBXNativeTarget "Pods-Example" */; 209 | buildPhases = ( 210 | 2D631D30FB2273725D403245CA7EBD33 /* Sources */, 211 | E4130F238FFFCC9CE491B5581811E4F2 /* Frameworks */, 212 | 165F56393932D12D4F47D084A81D3FD2 /* Headers */, 213 | ); 214 | buildRules = ( 215 | ); 216 | dependencies = ( 217 | FB1634D5F89E3872DF70ACCC83B1129B /* PBXTargetDependency */, 218 | ); 219 | name = "Pods-Example"; 220 | productName = "Pods-Example"; 221 | productReference = 30456D60236547AB19E53CCA0D534404 /* Pods_Example.framework */; 222 | productType = "com.apple.product-type.framework"; 223 | }; 224 | /* End PBXNativeTarget section */ 225 | 226 | /* Begin PBXProject section */ 227 | D41D8CD98F00B204E9800998ECF8427E /* Project object */ = { 228 | isa = PBXProject; 229 | attributes = { 230 | LastSwiftUpdateCheck = 0830; 231 | LastUpgradeCheck = 0700; 232 | }; 233 | buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */; 234 | compatibilityVersion = "Xcode 3.2"; 235 | developmentRegion = English; 236 | hasScannedForEncodings = 0; 237 | knownRegions = ( 238 | en, 239 | ); 240 | mainGroup = 7DB346D0F39D3F0E887471402A8071AB; 241 | productRefGroup = AC24F3551A26AA106B444AB711352500 /* Products */; 242 | projectDirPath = ""; 243 | projectRoot = ""; 244 | targets = ( 245 | 6AF8A112ED63A3AA7215C1BDA9B14152 /* Pods-Example */, 246 | 2EF2763772B3AD8C7CD93AF1AFA132D5 /* SwiftyJSON */, 247 | ); 248 | }; 249 | /* End PBXProject section */ 250 | 251 | /* Begin PBXSourcesBuildPhase section */ 252 | 2D631D30FB2273725D403245CA7EBD33 /* Sources */ = { 253 | isa = PBXSourcesBuildPhase; 254 | buildActionMask = 2147483647; 255 | files = ( 256 | C402474C1F1FA57E73335B9D4FC07119 /* Pods-Example-dummy.m in Sources */, 257 | ); 258 | runOnlyForDeploymentPostprocessing = 0; 259 | }; 260 | 70133205CCD575B0FE5C4C63A3BA4A31 /* Sources */ = { 261 | isa = PBXSourcesBuildPhase; 262 | buildActionMask = 2147483647; 263 | files = ( 264 | 1536DD0A2D0BC01C739FFBFFCC2CE424 /* SwiftyJSON-dummy.m in Sources */, 265 | 16D442A2455B91355FEC0F1872C2DBEE /* SwiftyJSON.swift in Sources */, 266 | ); 267 | runOnlyForDeploymentPostprocessing = 0; 268 | }; 269 | /* End PBXSourcesBuildPhase section */ 270 | 271 | /* Begin PBXTargetDependency section */ 272 | FB1634D5F89E3872DF70ACCC83B1129B /* PBXTargetDependency */ = { 273 | isa = PBXTargetDependency; 274 | name = SwiftyJSON; 275 | target = 2EF2763772B3AD8C7CD93AF1AFA132D5 /* SwiftyJSON */; 276 | targetProxy = 8CA0CC8C58194BD1C80DB0A33CD05058 /* PBXContainerItemProxy */; 277 | }; 278 | /* End PBXTargetDependency section */ 279 | 280 | /* Begin XCBuildConfiguration section */ 281 | 12C4B864767C59600DBFA238F1E2F8BC /* Release */ = { 282 | isa = XCBuildConfiguration; 283 | buildSettings = { 284 | ALWAYS_SEARCH_USER_PATHS = NO; 285 | CLANG_ANALYZER_NONNULL = YES; 286 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 287 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 288 | CLANG_CXX_LIBRARY = "libc++"; 289 | CLANG_ENABLE_MODULES = YES; 290 | CLANG_ENABLE_OBJC_ARC = YES; 291 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 292 | CLANG_WARN_BOOL_CONVERSION = YES; 293 | CLANG_WARN_COMMA = YES; 294 | CLANG_WARN_CONSTANT_CONVERSION = YES; 295 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 296 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 297 | CLANG_WARN_EMPTY_BODY = YES; 298 | CLANG_WARN_ENUM_CONVERSION = YES; 299 | CLANG_WARN_INFINITE_RECURSION = YES; 300 | CLANG_WARN_INT_CONVERSION = YES; 301 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 302 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 303 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 304 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 305 | CLANG_WARN_STRICT_PROTOTYPES = YES; 306 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 307 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 308 | CLANG_WARN_UNREACHABLE_CODE = YES; 309 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 310 | CODE_SIGNING_REQUIRED = NO; 311 | COPY_PHASE_STRIP = NO; 312 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 313 | ENABLE_NS_ASSERTIONS = NO; 314 | ENABLE_STRICT_OBJC_MSGSEND = YES; 315 | GCC_C_LANGUAGE_STANDARD = gnu11; 316 | GCC_NO_COMMON_BLOCKS = YES; 317 | GCC_PREPROCESSOR_DEFINITIONS = ( 318 | "POD_CONFIGURATION_RELEASE=1", 319 | "$(inherited)", 320 | ); 321 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 322 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 323 | GCC_WARN_UNDECLARED_SELECTOR = YES; 324 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 325 | GCC_WARN_UNUSED_FUNCTION = YES; 326 | GCC_WARN_UNUSED_VARIABLE = YES; 327 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 328 | MTL_ENABLE_DEBUG_INFO = NO; 329 | PRODUCT_NAME = "$(TARGET_NAME)"; 330 | PROVISIONING_PROFILE_SPECIFIER = NO_SIGNING/; 331 | STRIP_INSTALLED_PRODUCT = NO; 332 | SYMROOT = "${SRCROOT}/../build"; 333 | }; 334 | name = Release; 335 | }; 336 | 2FADECB6D553B1BA3764E87ED650A9F1 /* Release */ = { 337 | isa = XCBuildConfiguration; 338 | baseConfigurationReference = E512A5F985F876750237FD237C3AEEDA /* Pods-Example.release.xcconfig */; 339 | buildSettings = { 340 | CODE_SIGN_IDENTITY = ""; 341 | "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; 342 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 343 | "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; 344 | CURRENT_PROJECT_VERSION = 1; 345 | DEFINES_MODULE = YES; 346 | DYLIB_COMPATIBILITY_VERSION = 1; 347 | DYLIB_CURRENT_VERSION = 1; 348 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 349 | INFOPLIST_FILE = "Target Support Files/Pods-Example/Info.plist"; 350 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 351 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 352 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 353 | MACH_O_TYPE = staticlib; 354 | MODULEMAP_FILE = "Target Support Files/Pods-Example/Pods-Example.modulemap"; 355 | OTHER_LDFLAGS = ""; 356 | OTHER_LIBTOOLFLAGS = ""; 357 | PODS_ROOT = "$(SRCROOT)"; 358 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; 359 | PRODUCT_NAME = Pods_Example; 360 | SDKROOT = iphoneos; 361 | SKIP_INSTALL = YES; 362 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 363 | TARGETED_DEVICE_FAMILY = "1,2"; 364 | VALIDATE_PRODUCT = YES; 365 | VERSIONING_SYSTEM = "apple-generic"; 366 | VERSION_INFO_PREFIX = ""; 367 | }; 368 | name = Release; 369 | }; 370 | 434864FC9BAEB2BB50BC79F6C36F37B5 /* Debug */ = { 371 | isa = XCBuildConfiguration; 372 | baseConfigurationReference = 149054C495E8EC590CAB4C524133016F /* Pods-Example.debug.xcconfig */; 373 | buildSettings = { 374 | CODE_SIGN_IDENTITY = ""; 375 | "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; 376 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 377 | "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; 378 | CURRENT_PROJECT_VERSION = 1; 379 | DEFINES_MODULE = YES; 380 | DYLIB_COMPATIBILITY_VERSION = 1; 381 | DYLIB_CURRENT_VERSION = 1; 382 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 383 | INFOPLIST_FILE = "Target Support Files/Pods-Example/Info.plist"; 384 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 385 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 386 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 387 | MACH_O_TYPE = staticlib; 388 | MODULEMAP_FILE = "Target Support Files/Pods-Example/Pods-Example.modulemap"; 389 | OTHER_LDFLAGS = ""; 390 | OTHER_LIBTOOLFLAGS = ""; 391 | PODS_ROOT = "$(SRCROOT)"; 392 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; 393 | PRODUCT_NAME = Pods_Example; 394 | SDKROOT = iphoneos; 395 | SKIP_INSTALL = YES; 396 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 397 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 398 | TARGETED_DEVICE_FAMILY = "1,2"; 399 | VERSIONING_SYSTEM = "apple-generic"; 400 | VERSION_INFO_PREFIX = ""; 401 | }; 402 | name = Debug; 403 | }; 404 | 59F0302F2371FCC6B73EF0A418D40734 /* Debug */ = { 405 | isa = XCBuildConfiguration; 406 | buildSettings = { 407 | ALWAYS_SEARCH_USER_PATHS = NO; 408 | CLANG_ANALYZER_NONNULL = YES; 409 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 410 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 411 | CLANG_CXX_LIBRARY = "libc++"; 412 | CLANG_ENABLE_MODULES = YES; 413 | CLANG_ENABLE_OBJC_ARC = YES; 414 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 415 | CLANG_WARN_BOOL_CONVERSION = YES; 416 | CLANG_WARN_COMMA = YES; 417 | CLANG_WARN_CONSTANT_CONVERSION = YES; 418 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 419 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 420 | CLANG_WARN_EMPTY_BODY = YES; 421 | CLANG_WARN_ENUM_CONVERSION = YES; 422 | CLANG_WARN_INFINITE_RECURSION = YES; 423 | CLANG_WARN_INT_CONVERSION = YES; 424 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 425 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 426 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 427 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 428 | CLANG_WARN_STRICT_PROTOTYPES = YES; 429 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 430 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 431 | CLANG_WARN_UNREACHABLE_CODE = YES; 432 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 433 | CODE_SIGNING_REQUIRED = NO; 434 | COPY_PHASE_STRIP = NO; 435 | DEBUG_INFORMATION_FORMAT = dwarf; 436 | ENABLE_STRICT_OBJC_MSGSEND = YES; 437 | ENABLE_TESTABILITY = YES; 438 | GCC_C_LANGUAGE_STANDARD = gnu11; 439 | GCC_DYNAMIC_NO_PIC = NO; 440 | GCC_NO_COMMON_BLOCKS = YES; 441 | GCC_OPTIMIZATION_LEVEL = 0; 442 | GCC_PREPROCESSOR_DEFINITIONS = ( 443 | "POD_CONFIGURATION_DEBUG=1", 444 | "DEBUG=1", 445 | "$(inherited)", 446 | ); 447 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 448 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 449 | GCC_WARN_UNDECLARED_SELECTOR = YES; 450 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 451 | GCC_WARN_UNUSED_FUNCTION = YES; 452 | GCC_WARN_UNUSED_VARIABLE = YES; 453 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 454 | MTL_ENABLE_DEBUG_INFO = YES; 455 | ONLY_ACTIVE_ARCH = YES; 456 | PRODUCT_NAME = "$(TARGET_NAME)"; 457 | PROVISIONING_PROFILE_SPECIFIER = NO_SIGNING/; 458 | STRIP_INSTALLED_PRODUCT = NO; 459 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 460 | SYMROOT = "${SRCROOT}/../build"; 461 | }; 462 | name = Debug; 463 | }; 464 | 7E30C6A9AB6634B809FEB8F73114902D /* Release */ = { 465 | isa = XCBuildConfiguration; 466 | baseConfigurationReference = 2E7F7C62EE34D2D271E6E1234A2002B2 /* SwiftyJSON.xcconfig */; 467 | buildSettings = { 468 | CODE_SIGN_IDENTITY = ""; 469 | "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; 470 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 471 | "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; 472 | CURRENT_PROJECT_VERSION = 1; 473 | DEFINES_MODULE = YES; 474 | DYLIB_COMPATIBILITY_VERSION = 1; 475 | DYLIB_CURRENT_VERSION = 1; 476 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 477 | GCC_PREFIX_HEADER = "Target Support Files/SwiftyJSON/SwiftyJSON-prefix.pch"; 478 | INFOPLIST_FILE = "Target Support Files/SwiftyJSON/Info.plist"; 479 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 480 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 481 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 482 | MODULEMAP_FILE = "Target Support Files/SwiftyJSON/SwiftyJSON.modulemap"; 483 | PRODUCT_NAME = SwiftyJSON; 484 | SDKROOT = iphoneos; 485 | SKIP_INSTALL = YES; 486 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; 487 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 488 | SWIFT_VERSION = 4.0; 489 | TARGETED_DEVICE_FAMILY = "1,2"; 490 | VALIDATE_PRODUCT = YES; 491 | VERSIONING_SYSTEM = "apple-generic"; 492 | VERSION_INFO_PREFIX = ""; 493 | }; 494 | name = Release; 495 | }; 496 | A59F9E11722606F452CA1311B0AC1223 /* Debug */ = { 497 | isa = XCBuildConfiguration; 498 | baseConfigurationReference = 2E7F7C62EE34D2D271E6E1234A2002B2 /* SwiftyJSON.xcconfig */; 499 | buildSettings = { 500 | CODE_SIGN_IDENTITY = ""; 501 | "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; 502 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 503 | "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; 504 | CURRENT_PROJECT_VERSION = 1; 505 | DEFINES_MODULE = YES; 506 | DYLIB_COMPATIBILITY_VERSION = 1; 507 | DYLIB_CURRENT_VERSION = 1; 508 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 509 | GCC_PREFIX_HEADER = "Target Support Files/SwiftyJSON/SwiftyJSON-prefix.pch"; 510 | INFOPLIST_FILE = "Target Support Files/SwiftyJSON/Info.plist"; 511 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 512 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 513 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 514 | MODULEMAP_FILE = "Target Support Files/SwiftyJSON/SwiftyJSON.modulemap"; 515 | PRODUCT_NAME = SwiftyJSON; 516 | SDKROOT = iphoneos; 517 | SKIP_INSTALL = YES; 518 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; 519 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 520 | SWIFT_VERSION = 4.0; 521 | TARGETED_DEVICE_FAMILY = "1,2"; 522 | VERSIONING_SYSTEM = "apple-generic"; 523 | VERSION_INFO_PREFIX = ""; 524 | }; 525 | name = Debug; 526 | }; 527 | /* End XCBuildConfiguration section */ 528 | 529 | /* Begin XCConfigurationList section */ 530 | 282EDB859404BAABFC6CD47226644EF6 /* Build configuration list for PBXNativeTarget "Pods-Example" */ = { 531 | isa = XCConfigurationList; 532 | buildConfigurations = ( 533 | 434864FC9BAEB2BB50BC79F6C36F37B5 /* Debug */, 534 | 2FADECB6D553B1BA3764E87ED650A9F1 /* Release */, 535 | ); 536 | defaultConfigurationIsVisible = 0; 537 | defaultConfigurationName = Release; 538 | }; 539 | 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */ = { 540 | isa = XCConfigurationList; 541 | buildConfigurations = ( 542 | 59F0302F2371FCC6B73EF0A418D40734 /* Debug */, 543 | 12C4B864767C59600DBFA238F1E2F8BC /* Release */, 544 | ); 545 | defaultConfigurationIsVisible = 0; 546 | defaultConfigurationName = Release; 547 | }; 548 | DDD72550E295CD7C416CC2F972B0F4A4 /* Build configuration list for PBXNativeTarget "SwiftyJSON" */ = { 549 | isa = XCConfigurationList; 550 | buildConfigurations = ( 551 | A59F9E11722606F452CA1311B0AC1223 /* Debug */, 552 | 7E30C6A9AB6634B809FEB8F73114902D /* Release */, 553 | ); 554 | defaultConfigurationIsVisible = 0; 555 | defaultConfigurationName = Release; 556 | }; 557 | /* End XCConfigurationList section */ 558 | }; 559 | rootObject = D41D8CD98F00B204E9800998ECF8427E /* Project object */; 560 | } 561 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/SwiftyJSON/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Ruoyu Fu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/SwiftyJSON/README.md: -------------------------------------------------------------------------------- 1 | # SwiftyJSON 2 | 3 | [![Travis CI](https://travis-ci.org/SwiftyJSON/SwiftyJSON.svg?branch=master)](https://travis-ci.org/SwiftyJSON/SwiftyJSON) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) ![CocoaPods](https://img.shields.io/cocoapods/v/SwiftyJSON.svg) ![Platform](https://img.shields.io/badge/platforms-iOS%208.0+%20%7C%20macOS%2010.10+%20%7C%20tvOS%209.0+%20%7C%20watchOS%202.0+-333333.svg) 4 | 5 | SwiftyJSON makes it easy to deal with JSON data in Swift. 6 | 7 | 1. [Why is the typical JSON handling in Swift NOT good](#why-is-the-typical-json-handling-in-swift-not-good) 8 | 2. [Requirements](#requirements) 9 | 3. [Integration](#integration) 10 | 4. [Usage](#usage) 11 | - [Initialization](#initialization) 12 | - [Subscript](#subscript) 13 | - [Loop](#loop) 14 | - [Error](#error) 15 | - [Optional getter](#optional-getter) 16 | - [Non-optional getter](#non-optional-getter) 17 | - [Setter](#setter) 18 | - [Raw object](#raw-object) 19 | - [Literal convertibles](#literal-convertibles) 20 | - [Merging](#merging) 21 | 5. [Work with Alamofire](#work-with-alamofire) 22 | 23 | > For Legacy Swift support, take a look at the [swift2 branch](https://github.com/SwiftyJSON/SwiftyJSON/tree/swift2) 24 | 25 | > [中文介绍](http://tangplin.github.io/swiftyjson/) 26 | 27 | 28 | ## Why is the typical JSON handling in Swift NOT good? 29 | 30 | Swift is very strict about types. But although explicit typing is good for saving us from mistakes, it becomes painful when dealing with JSON and other areas that are, by nature, implicit about types. 31 | 32 | Take the Twitter API for example. Say we want to retrieve a user's "name" value of some tweet in Swift (according to Twitter's API https://dev.twitter.com/docs/api/1.1/get/statuses/home_timeline). 33 | 34 | The code would look like this: 35 | 36 | ```swift 37 | if let statusesArray = try? JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [[String: Any]], 38 | let user = statusesArray[0]["user"] as? [String: Any], 39 | let username = user["name"] as? String { 40 | // Finally we got the username 41 | } 42 | ``` 43 | 44 | It's not good. 45 | 46 | Even if we use optional chaining, it would be messy: 47 | 48 | ```swift 49 | if let JSONObject = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [[String: Any]], 50 | let username = (JSONObject[0]["user"] as? [String: Any])?["name"] as? String { 51 | // There's our username 52 | } 53 | ``` 54 | 55 | An unreadable mess--for something that should really be simple! 56 | 57 | With SwiftyJSON all you have to do is: 58 | 59 | ```swift 60 | let json = JSON(data: dataFromNetworking) 61 | if let userName = json[0]["user"]["name"].string { 62 | //Now you got your value 63 | } 64 | ``` 65 | 66 | And don't worry about the Optional Wrapping thing. It's done for you automatically. 67 | 68 | ```swift 69 | let json = JSON(data: dataFromNetworking) 70 | if let userName = json[999999]["wrong_key"]["wrong_name"].string { 71 | //Calm down, take it easy, the ".string" property still produces the correct Optional String type with safety 72 | } else { 73 | //Print the error 74 | print(json[999999]["wrong_key"]["wrong_name"]) 75 | } 76 | ``` 77 | 78 | ## Requirements 79 | 80 | - iOS 8.0+ | macOS 10.10+ | tvOS 9.0+ | watchOS 2.0+ 81 | - Xcode 8 82 | 83 | ## Integration 84 | 85 | #### CocoaPods (iOS 8+, OS X 10.9+) 86 | 87 | You can use [CocoaPods](http://cocoapods.org/) to install `SwiftyJSON`by adding it to your `Podfile`: 88 | 89 | ```ruby 90 | platform :ios, '8.0' 91 | use_frameworks! 92 | 93 | target 'MyApp' do 94 | pod 'SwiftyJSON' 95 | end 96 | ``` 97 | 98 | Note that this requires CocoaPods version 36, and your iOS deployment target to be at least 8.0: 99 | 100 | 101 | #### Carthage (iOS 8+, OS X 10.9+) 102 | 103 | You can use [Carthage](https://github.com/Carthage/Carthage) to install `SwiftyJSON` by adding it to your `Cartfile`: 104 | 105 | ``` 106 | github "SwiftyJSON/SwiftyJSON" 107 | ``` 108 | 109 | #### Swift Package Manager 110 | 111 | You can use [The Swift Package Manager](https://swift.org/package-manager) to install `SwiftyJSON` by adding the proper description to your `Package.swift` file: 112 | 113 | ```swift 114 | import PackageDescription 115 | 116 | let package = Package( 117 | name: "YOUR_PROJECT_NAME", 118 | targets: [], 119 | dependencies: [ 120 | .Package(url: "https://github.com/SwiftyJSON/SwiftyJSON.git", versions: Version(1,0,0).. = json["list"].arrayValue 319 | ``` 320 | 321 | ```swift 322 | //If not a Dictionary or nil, return [:] 323 | let user: Dictionary = json["user"].dictionaryValue 324 | ``` 325 | 326 | #### Setter 327 | 328 | ```swift 329 | json["name"] = JSON("new-name") 330 | json[0] = JSON(1) 331 | ``` 332 | 333 | ```swift 334 | json["id"].int = 1234567890 335 | json["coordinate"].double = 8766.766 336 | json["name"].string = "Jack" 337 | json.arrayObject = [1,2,3,4] 338 | json.dictionaryObject = ["name":"Jack", "age":25] 339 | ``` 340 | 341 | #### Raw object 342 | 343 | ```swift 344 | let jsonObject: Any = json.object 345 | ``` 346 | 347 | ```swift 348 | if let jsonObject: Any = json.rawValue 349 | ``` 350 | 351 | ```swift 352 | //convert the JSON to raw NSData 353 | if let data = json.rawData() { 354 | //Do something you want 355 | } 356 | ``` 357 | 358 | ```swift 359 | //convert the JSON to a raw String 360 | if let string = json.rawString() { 361 | //Do something you want 362 | } 363 | ``` 364 | 365 | #### Existence 366 | 367 | ```swift 368 | //shows you whether value specified in JSON or not 369 | if json["name"].exists() 370 | ``` 371 | 372 | #### Literal convertibles 373 | 374 | For more info about literal convertibles: [Swift Literal Convertibles](http://nshipster.com/swift-literal-convertible/) 375 | 376 | ```swift 377 | //StringLiteralConvertible 378 | let json: JSON = "I'm a json" 379 | ``` 380 | 381 | ```swift 382 | //IntegerLiteralConvertible 383 | let json: JSON = 12345 384 | ``` 385 | 386 | ```swift 387 | //BooleanLiteralConvertible 388 | let json: JSON = true 389 | ``` 390 | 391 | ```swift 392 | //FloatLiteralConvertible 393 | let json: JSON = 2.8765 394 | ``` 395 | 396 | ```swift 397 | //DictionaryLiteralConvertible 398 | let json: JSON = ["I":"am", "a":"json"] 399 | ``` 400 | 401 | ```swift 402 | //ArrayLiteralConvertible 403 | let json: JSON = ["I", "am", "a", "json"] 404 | ``` 405 | 406 | ```swift 407 | //NilLiteralConvertible 408 | let json: JSON = nil 409 | ``` 410 | 411 | ```swift 412 | //With subscript in array 413 | var json: JSON = [1,2,3] 414 | json[0] = 100 415 | json[1] = 200 416 | json[2] = 300 417 | json[999] = 300 //Don't worry, nothing will happen 418 | ``` 419 | 420 | ```swift 421 | //With subscript in dictionary 422 | var json: JSON = ["name": "Jack", "age": 25] 423 | json["name"] = "Mike" 424 | json["age"] = "25" //It's OK to set String 425 | json["address"] = "L.A." // Add the "address": "L.A." in json 426 | ``` 427 | 428 | ```swift 429 | //Array & Dictionary 430 | var json: JSON = ["name": "Jack", "age": 25, "list": ["a", "b", "c", ["what": "this"]]] 431 | json["list"][3]["what"] = "that" 432 | json["list",3,"what"] = "that" 433 | let path: [JSONSubscriptType] = ["list",3,"what"] 434 | json[path] = "that" 435 | ``` 436 | 437 | ```swift 438 | //With other JSON objects 439 | let user: JSON = ["username" : "Steve", "password": "supersecurepassword"] 440 | let auth: JSON = [ 441 | "user": user.object //use user.object instead of just user 442 | "apikey": "supersecretapitoken" 443 | ] 444 | ``` 445 | 446 | #### Merging 447 | 448 | It is possible to merge one JSON into another JSON. Merging a JSON into another JSON adds all non existing values to the original JSON which are only present in the `other` JSON. 449 | 450 | If both JSONs contain a value for the same key, _mostly_ this value gets overwritten in the original JSON, but there are two cases where it provides some special treatment: 451 | 452 | - In case of both values being a `JSON.Type.array` the values form the array found in the `other` JSON getting appended to the original JSON's array value. 453 | - In case of both values being a `JSON.Type.dictionary` both JSON-values are getting merged the same way the encapsulating JSON is merged. 454 | 455 | In case, where two fields in a JSON have a different types, the value will get always overwritten. 456 | 457 | There are two different fashions for merging: `merge` modifies the original JSON, whereas `merged` works non-destructively on a copy. 458 | 459 | ```swift 460 | let original: JSON = [ 461 | "first_name": "John", 462 | "age": 20, 463 | "skills": ["Coding", "Reading"], 464 | "address": [ 465 | "street": "Front St", 466 | "zip": "12345", 467 | ] 468 | ] 469 | 470 | let update: JSON = [ 471 | "last_name": "Doe", 472 | "age": 21, 473 | "skills": ["Writing"], 474 | "address": [ 475 | "zip": "12342", 476 | "city": "New York City" 477 | ] 478 | ] 479 | 480 | let updated = original.merge(with: update) 481 | // [ 482 | // "first_name": "John", 483 | // "last_name": "Doe", 484 | // "age": 21, 485 | // "skills": ["Coding", "Reading", "Writing"], 486 | // "address": [ 487 | // "street": "Front St", 488 | // "zip": "12342", 489 | // "city": "New York City" 490 | // ] 491 | // ] 492 | ``` 493 | 494 | ## String representation 495 | There are two options available: 496 | - use the default Swift one 497 | - use a custom one that will handle optionals well and represent `nil` as `"null"`: 498 | ```swift 499 | let dict = ["1":2, "2":"two", "3": nil] as [String: Any?] 500 | let json = JSON(dict) 501 | let representation = json.rawString(options: [.castNilToNSNull: true]) 502 | // representation is "{\"1\":2,\"2\":\"two\",\"3\":null}", which represents {"1":2,"2":"two","3":null} 503 | ``` 504 | 505 | ## Work with Alamofire 506 | 507 | SwiftyJSON nicely wraps the result of the Alamofire JSON response handler: 508 | 509 | ```swift 510 | Alamofire.request(url, method: .get).validate().responseJSON { response in 511 | switch response.result { 512 | case .success(let value): 513 | let json = JSON(value) 514 | print("JSON: \(json)") 515 | case .failure(let error): 516 | print(error) 517 | } 518 | } 519 | ``` 520 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/SwiftyJSON/Source/SwiftyJSON.swift: -------------------------------------------------------------------------------- 1 | // SwiftyJSON.swift 2 | // 3 | // Copyright (c) 2014 - 2017 Ruoyu Fu, Pinglin Tang 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | import Foundation 24 | 25 | // MARK: - Error 26 | 27 | ///Error domain 28 | public let ErrorDomain: String = "SwiftyJSONErrorDomain" 29 | 30 | ///Error code 31 | public let ErrorUnsupportedType: Int = 999 32 | public let ErrorIndexOutOfBounds: Int = 900 33 | public let ErrorWrongType: Int = 901 34 | public let ErrorNotExist: Int = 500 35 | public let ErrorInvalidJSON: Int = 490 36 | 37 | // MARK: - JSON Type 38 | 39 | /** 40 | JSON's type definitions. 41 | 42 | See http://www.json.org 43 | */ 44 | public enum Type :Int{ 45 | 46 | case number 47 | case string 48 | case bool 49 | case array 50 | case dictionary 51 | case null 52 | case unknown 53 | } 54 | 55 | // MARK: - JSON Base 56 | public struct JSON { 57 | 58 | /** 59 | Creates a JSON using the data. 60 | 61 | - parameter data: The NSData used to convert to json.Top level object in data is an NSArray or NSDictionary 62 | - parameter opt: The JSON serialization reading options. `.AllowFragments` by default. 63 | - parameter error: The NSErrorPointer used to return the error. `nil` by default. 64 | 65 | - returns: The created JSON 66 | */ 67 | public init(data: Data, options opt: JSONSerialization.ReadingOptions = .allowFragments, error: NSErrorPointer = nil) { 68 | do { 69 | let object: Any = try JSONSerialization.jsonObject(with: data, options: opt) 70 | self.init(jsonObject: object) 71 | } catch let aError as NSError { 72 | if error != nil { 73 | error?.pointee = aError 74 | } 75 | self.init(jsonObject: NSNull()) 76 | } 77 | } 78 | 79 | /** 80 | Creates a JSON object 81 | - parameter object: the object 82 | - note: this does not parse a `String` into JSON, instead use `init(parseJSON: String)` 83 | - returns: the created JSON object 84 | */ 85 | public init(_ object: Any) { 86 | switch object { 87 | case let object as [JSON] where object.count > 0: 88 | self.init(array: object) 89 | case let object as [String: JSON] where object.count > 0: 90 | self.init(dictionary: object) 91 | case let object as Data: 92 | self.init(data: object) 93 | default: 94 | self.init(jsonObject: object) 95 | } 96 | } 97 | 98 | /** 99 | Parses the JSON string into a JSON object 100 | - parameter json: the JSON string 101 | - returns: the created JSON object 102 | */ 103 | public init(parseJSON jsonString: String) { 104 | if let data = jsonString.data(using: .utf8) { 105 | self.init(data) 106 | } else { 107 | self.init(NSNull()) 108 | } 109 | } 110 | 111 | /** 112 | Creates a JSON from JSON string 113 | - parameter string: Normal json string like '{"a":"b"}' 114 | 115 | - returns: The created JSON 116 | */ 117 | @available(*, deprecated: 3.2, message: "Use instead `init(parseJSON: )`") 118 | public static func parse(_ json: String) -> JSON { 119 | return json.data(using: String.Encoding.utf8) 120 | .flatMap{ JSON(data: $0) } ?? JSON(NSNull()) 121 | } 122 | 123 | /** 124 | Creates a JSON using the object. 125 | 126 | - parameter object: The object must have the following properties: All objects are NSString/String, NSNumber/Int/Float/Double/Bool, NSArray/Array, NSDictionary/Dictionary, or NSNull; All dictionary keys are NSStrings/String; NSNumbers are not NaN or infinity. 127 | 128 | - returns: The created JSON 129 | */ 130 | fileprivate init(jsonObject: Any) { 131 | self.object = jsonObject 132 | } 133 | 134 | /** 135 | Creates a JSON from a [JSON] 136 | 137 | - parameter jsonArray: A Swift array of JSON objects 138 | 139 | - returns: The created JSON 140 | */ 141 | fileprivate init(array: [JSON]) { 142 | self.init(array.map { $0.object }) 143 | } 144 | 145 | /** 146 | Creates a JSON from a [String: JSON] 147 | 148 | - parameter jsonDictionary: A Swift dictionary of JSON objects 149 | 150 | - returns: The created JSON 151 | */ 152 | fileprivate init(dictionary: [String: JSON]) { 153 | var newDictionary = [String: Any](minimumCapacity: dictionary.count) 154 | for (key, json) in dictionary { 155 | newDictionary[key] = json.object 156 | } 157 | 158 | self.init(newDictionary) 159 | } 160 | 161 | /** 162 | Merges another JSON into this JSON, whereas primitive values which are not present in this JSON are getting added, 163 | present values getting overwritten, array values getting appended and nested JSONs getting merged the same way. 164 | 165 | - parameter other: The JSON which gets merged into this JSON 166 | - throws `ErrorWrongType` if the other JSONs differs in type on the top level. 167 | */ 168 | public mutating func merge(with other: JSON) throws { 169 | try self.merge(with: other, typecheck: true) 170 | } 171 | 172 | /** 173 | Merges another JSON into this JSON and returns a new JSON, whereas primitive values which are not present in this JSON are getting added, 174 | present values getting overwritten, array values getting appended and nested JSONS getting merged the same way. 175 | 176 | - parameter other: The JSON which gets merged into this JSON 177 | - returns: New merged JSON 178 | - throws `ErrorWrongType` if the other JSONs differs in type on the top level. 179 | */ 180 | public func merged(with other: JSON) throws -> JSON { 181 | var merged = self 182 | try merged.merge(with: other, typecheck: true) 183 | return merged 184 | } 185 | 186 | // Private woker function which does the actual merging 187 | // Typecheck is set to true for the first recursion level to prevent total override of the source JSON 188 | fileprivate mutating func merge(with other: JSON, typecheck: Bool) throws { 189 | if self.type == other.type { 190 | switch self.type { 191 | case .dictionary: 192 | for (key, _) in other { 193 | try self[key].merge(with: other[key], typecheck: false) 194 | } 195 | case .array: 196 | self = JSON(self.arrayValue + other.arrayValue) 197 | default: 198 | self = other 199 | } 200 | } else { 201 | if typecheck { 202 | throw NSError(domain: ErrorDomain, code: ErrorWrongType, userInfo: [NSLocalizedDescriptionKey: "Couldn't merge, because the JSONs differ in type on top level."]) 203 | } else { 204 | self = other 205 | } 206 | } 207 | } 208 | 209 | /// Private object 210 | fileprivate var rawArray: [Any] = [] 211 | fileprivate var rawDictionary: [String : Any] = [:] 212 | fileprivate var rawString: String = "" 213 | fileprivate var rawNumber: NSNumber = 0 214 | fileprivate var rawNull: NSNull = NSNull() 215 | fileprivate var rawBool: Bool = false 216 | /// Private type 217 | fileprivate var _type: Type = .null 218 | /// prviate error 219 | fileprivate var _error: NSError? = nil 220 | 221 | /// Object in JSON 222 | public var object: Any { 223 | get { 224 | switch self.type { 225 | case .array: 226 | return self.rawArray 227 | case .dictionary: 228 | return self.rawDictionary 229 | case .string: 230 | return self.rawString 231 | case .number: 232 | return self.rawNumber 233 | case .bool: 234 | return self.rawBool 235 | default: 236 | return self.rawNull 237 | } 238 | } 239 | set { 240 | _error = nil 241 | switch newValue { 242 | case let number as NSNumber: 243 | if number.isBool { 244 | _type = .bool 245 | self.rawBool = number.boolValue 246 | } else { 247 | _type = .number 248 | self.rawNumber = number 249 | } 250 | case let string as String: 251 | _type = .string 252 | self.rawString = string 253 | case _ as NSNull: 254 | _type = .null 255 | case _ as [JSON]: 256 | _type = .array 257 | case nil: 258 | _type = .null 259 | case let array as [Any]: 260 | _type = .array 261 | self.rawArray = array 262 | case let dictionary as [String : Any]: 263 | _type = .dictionary 264 | self.rawDictionary = dictionary 265 | default: 266 | _type = .unknown 267 | _error = NSError(domain: ErrorDomain, code: ErrorUnsupportedType, userInfo: [NSLocalizedDescriptionKey: "It is a unsupported type"]) 268 | } 269 | } 270 | } 271 | 272 | /// JSON type 273 | public var type: Type { get { return _type } } 274 | 275 | /// Error in JSON 276 | public var error: NSError? { get { return self._error } } 277 | 278 | /// The static null JSON 279 | @available(*, unavailable, renamed:"null") 280 | public static var nullJSON: JSON { get { return null } } 281 | public static var null: JSON { get { return JSON(NSNull()) } } 282 | } 283 | 284 | public enum Index: Comparable 285 | { 286 | case array(Int) 287 | case dictionary(DictionaryIndex) 288 | case null 289 | 290 | static public func ==(lhs: Index, rhs: Index) -> Bool { 291 | switch (lhs, rhs) { 292 | case (.array(let left), .array(let right)): 293 | return left == right 294 | case (.dictionary(let left), .dictionary(let right)): 295 | return left == right 296 | case (.null, .null): return true 297 | default: 298 | return false 299 | } 300 | } 301 | 302 | static public func <(lhs: Index, rhs: Index) -> Bool { 303 | switch (lhs, rhs) { 304 | case (.array(let left), .array(let right)): 305 | return left < right 306 | case (.dictionary(let left), .dictionary(let right)): 307 | return left < right 308 | default: 309 | return false 310 | } 311 | } 312 | } 313 | 314 | public typealias JSONIndex = Index 315 | public typealias JSONRawIndex = Index 316 | 317 | 318 | extension JSON: Collection 319 | { 320 | 321 | public typealias Index = JSONRawIndex 322 | 323 | public var startIndex: Index 324 | { 325 | switch type 326 | { 327 | case .array: 328 | return .array(rawArray.startIndex) 329 | case .dictionary: 330 | return .dictionary(rawDictionary.startIndex) 331 | default: 332 | return .null 333 | } 334 | } 335 | 336 | public var endIndex: Index 337 | { 338 | switch type 339 | { 340 | case .array: 341 | return .array(rawArray.endIndex) 342 | case .dictionary: 343 | return .dictionary(rawDictionary.endIndex) 344 | default: 345 | return .null 346 | } 347 | } 348 | 349 | public func index(after i: Index) -> Index 350 | { 351 | switch i 352 | { 353 | case .array(let idx): 354 | return .array(rawArray.index(after: idx)) 355 | case .dictionary(let idx): 356 | return .dictionary(rawDictionary.index(after: idx)) 357 | default: 358 | return .null 359 | } 360 | 361 | } 362 | 363 | public subscript (position: Index) -> (String, JSON) 364 | { 365 | switch position 366 | { 367 | case .array(let idx): 368 | return (String(idx), JSON(self.rawArray[idx])) 369 | case .dictionary(let idx): 370 | let (key, value) = self.rawDictionary[idx] 371 | return (key, JSON(value)) 372 | default: 373 | return ("", JSON.null) 374 | } 375 | } 376 | 377 | 378 | } 379 | 380 | // MARK: - Subscript 381 | 382 | /** 383 | * To mark both String and Int can be used in subscript. 384 | */ 385 | public enum JSONKey 386 | { 387 | case index(Int) 388 | case key(String) 389 | } 390 | 391 | public protocol JSONSubscriptType { 392 | var jsonKey:JSONKey { get } 393 | } 394 | 395 | extension Int: JSONSubscriptType { 396 | public var jsonKey:JSONKey { 397 | return JSONKey.index(self) 398 | } 399 | } 400 | 401 | extension String: JSONSubscriptType { 402 | public var jsonKey:JSONKey { 403 | return JSONKey.key(self) 404 | } 405 | } 406 | 407 | extension JSON { 408 | 409 | /// If `type` is `.Array`, return json whose object is `array[index]`, otherwise return null json with error. 410 | fileprivate subscript(index index: Int) -> JSON { 411 | get { 412 | if self.type != .array { 413 | var r = JSON.null 414 | r._error = self._error ?? NSError(domain: ErrorDomain, code: ErrorWrongType, userInfo: [NSLocalizedDescriptionKey: "Array[\(index)] failure, It is not an array"]) 415 | return r 416 | } else if index >= 0 && index < self.rawArray.count { 417 | return JSON(self.rawArray[index]) 418 | } else { 419 | var r = JSON.null 420 | r._error = NSError(domain: ErrorDomain, code:ErrorIndexOutOfBounds , userInfo: [NSLocalizedDescriptionKey: "Array[\(index)] is out of bounds"]) 421 | return r 422 | } 423 | } 424 | set { 425 | if self.type == .array { 426 | if self.rawArray.count > index && newValue.error == nil { 427 | self.rawArray[index] = newValue.object 428 | } 429 | } 430 | } 431 | } 432 | 433 | /// If `type` is `.Dictionary`, return json whose object is `dictionary[key]` , otherwise return null json with error. 434 | fileprivate subscript(key key: String) -> JSON { 435 | get { 436 | var r = JSON.null 437 | if self.type == .dictionary { 438 | if let o = self.rawDictionary[key] { 439 | r = JSON(o) 440 | } else { 441 | r._error = NSError(domain: ErrorDomain, code: ErrorNotExist, userInfo: [NSLocalizedDescriptionKey: "Dictionary[\"\(key)\"] does not exist"]) 442 | } 443 | } else { 444 | r._error = self._error ?? NSError(domain: ErrorDomain, code: ErrorWrongType, userInfo: [NSLocalizedDescriptionKey: "Dictionary[\"\(key)\"] failure, It is not an dictionary"]) 445 | } 446 | return r 447 | } 448 | set { 449 | if self.type == .dictionary && newValue.error == nil { 450 | self.rawDictionary[key] = newValue.object 451 | } 452 | } 453 | } 454 | 455 | /// If `sub` is `Int`, return `subscript(index:)`; If `sub` is `String`, return `subscript(key:)`. 456 | fileprivate subscript(sub sub: JSONSubscriptType) -> JSON { 457 | get { 458 | switch sub.jsonKey { 459 | case .index(let index): return self[index: index] 460 | case .key(let key): return self[key: key] 461 | } 462 | } 463 | set { 464 | switch sub.jsonKey { 465 | case .index(let index): self[index: index] = newValue 466 | case .key(let key): self[key: key] = newValue 467 | } 468 | } 469 | } 470 | 471 | /** 472 | Find a json in the complex data structures by using array of Int and/or String as path. 473 | 474 | - parameter path: The target json's path. Example: 475 | 476 | let json = JSON[data] 477 | let path = [9,"list","person","name"] 478 | let name = json[path] 479 | 480 | The same as: let name = json[9]["list"]["person"]["name"] 481 | 482 | - returns: Return a json found by the path or a null json with error 483 | */ 484 | public subscript(path: [JSONSubscriptType]) -> JSON { 485 | get { 486 | return path.reduce(self) { $0[sub: $1] } 487 | } 488 | set { 489 | switch path.count { 490 | case 0: 491 | return 492 | case 1: 493 | self[sub:path[0]].object = newValue.object 494 | default: 495 | var aPath = path; aPath.remove(at: 0) 496 | var nextJSON = self[sub: path[0]] 497 | nextJSON[aPath] = newValue 498 | self[sub: path[0]] = nextJSON 499 | } 500 | } 501 | } 502 | 503 | /** 504 | Find a json in the complex data structures by using array of Int and/or String as path. 505 | 506 | - parameter path: The target json's path. Example: 507 | 508 | let name = json[9,"list","person","name"] 509 | 510 | The same as: let name = json[9]["list"]["person"]["name"] 511 | 512 | - returns: Return a json found by the path or a null json with error 513 | */ 514 | public subscript(path: JSONSubscriptType...) -> JSON { 515 | get { 516 | return self[path] 517 | } 518 | set { 519 | self[path] = newValue 520 | } 521 | } 522 | } 523 | 524 | // MARK: - LiteralConvertible 525 | 526 | extension JSON: Swift.ExpressibleByStringLiteral { 527 | 528 | public init(stringLiteral value: StringLiteralType) { 529 | self.init(value as Any) 530 | } 531 | 532 | public init(extendedGraphemeClusterLiteral value: StringLiteralType) { 533 | self.init(value as Any) 534 | } 535 | 536 | public init(unicodeScalarLiteral value: StringLiteralType) { 537 | self.init(value as Any) 538 | } 539 | } 540 | 541 | extension JSON: Swift.ExpressibleByIntegerLiteral { 542 | 543 | public init(integerLiteral value: IntegerLiteralType) { 544 | self.init(value as Any) 545 | } 546 | } 547 | 548 | extension JSON: Swift.ExpressibleByBooleanLiteral { 549 | 550 | public init(booleanLiteral value: BooleanLiteralType) { 551 | self.init(value as Any) 552 | } 553 | } 554 | 555 | extension JSON: Swift.ExpressibleByFloatLiteral { 556 | 557 | public init(floatLiteral value: FloatLiteralType) { 558 | self.init(value as Any) 559 | } 560 | } 561 | 562 | extension JSON: Swift.ExpressibleByDictionaryLiteral { 563 | public init(dictionaryLiteral elements: (String, Any)...) { 564 | let array = elements 565 | self.init(dictionaryLiteral: array) 566 | } 567 | 568 | public init(dictionaryLiteral elements: [(String, Any)]) { 569 | let jsonFromDictionaryLiteral: ([String : Any]) -> JSON = { dictionary in 570 | let initializeElement = Array(dictionary.keys).flatMap { key -> (String, Any)? in 571 | if let value = dictionary[key] { 572 | return (key, value) 573 | } 574 | return nil 575 | } 576 | return JSON(dictionaryLiteral: initializeElement) 577 | } 578 | 579 | var dict = [String : Any](minimumCapacity: elements.count) 580 | 581 | for element in elements { 582 | let elementToSet: Any 583 | if let json = element.1 as? JSON { 584 | elementToSet = json.object 585 | } else if let jsonArray = element.1 as? [JSON] { 586 | elementToSet = JSON(jsonArray).object 587 | } else if let dictionary = element.1 as? [String : Any] { 588 | elementToSet = jsonFromDictionaryLiteral(dictionary).object 589 | } else if let dictArray = element.1 as? [[String : Any]] { 590 | let jsonArray = dictArray.map { jsonFromDictionaryLiteral($0) } 591 | elementToSet = JSON(jsonArray).object 592 | } else { 593 | elementToSet = element.1 594 | } 595 | dict[element.0] = elementToSet 596 | } 597 | 598 | self.init(dict) 599 | } 600 | } 601 | 602 | extension JSON: Swift.ExpressibleByArrayLiteral { 603 | 604 | public init(arrayLiteral elements: Any...) { 605 | self.init(elements as Any) 606 | } 607 | } 608 | 609 | extension JSON: Swift.ExpressibleByNilLiteral { 610 | 611 | @available(*, deprecated, message: "use JSON.null instead. Will be removed in future versions") 612 | public init(nilLiteral: ()) { 613 | self.init(NSNull() as Any) 614 | } 615 | } 616 | 617 | // MARK: - Raw 618 | 619 | extension JSON: Swift.RawRepresentable { 620 | 621 | public init?(rawValue: Any) { 622 | if JSON(rawValue).type == .unknown { 623 | return nil 624 | } else { 625 | self.init(rawValue) 626 | } 627 | } 628 | 629 | public var rawValue: Any { 630 | return self.object 631 | } 632 | 633 | public func rawData(options opt: JSONSerialization.WritingOptions = JSONSerialization.WritingOptions(rawValue: 0)) throws -> Data { 634 | guard JSONSerialization.isValidJSONObject(self.object) else { 635 | throw NSError(domain: ErrorDomain, code: ErrorInvalidJSON, userInfo: [NSLocalizedDescriptionKey: "JSON is invalid"]) 636 | } 637 | 638 | return try JSONSerialization.data(withJSONObject: self.object, options: opt) 639 | } 640 | 641 | public func rawString(_ encoding: String.Encoding = .utf8, options opt: JSONSerialization.WritingOptions = .prettyPrinted) -> String? { 642 | do { 643 | return try _rawString(encoding, options: [.jsonSerialization: opt]) 644 | } catch { 645 | print("Could not serialize object to JSON because:", error.localizedDescription) 646 | return nil 647 | } 648 | } 649 | 650 | public func rawString(_ options: [writtingOptionsKeys: Any]) -> String? { 651 | let encoding = options[.encoding] as? String.Encoding ?? String.Encoding.utf8 652 | let maxObjectDepth = options[.maxObjextDepth] as? Int ?? 10 653 | do { 654 | return try _rawString(encoding, options: options, maxObjectDepth: maxObjectDepth) 655 | } catch { 656 | print("Could not serialize object to JSON because:", error.localizedDescription) 657 | return nil 658 | } 659 | } 660 | 661 | fileprivate func _rawString( 662 | _ encoding: String.Encoding = .utf8, 663 | options: [writtingOptionsKeys: Any], 664 | maxObjectDepth: Int = 10 665 | ) throws -> String? { 666 | if (maxObjectDepth < 0) { 667 | throw NSError(domain: ErrorDomain, code: ErrorInvalidJSON, userInfo: [NSLocalizedDescriptionKey: "Element too deep. Increase maxObjectDepth and make sure there is no reference loop"]) 668 | } 669 | switch self.type { 670 | case .dictionary: 671 | do { 672 | if !(options[.castNilToNSNull] as? Bool ?? false) { 673 | let jsonOption = options[.jsonSerialization] as? JSONSerialization.WritingOptions ?? JSONSerialization.WritingOptions.prettyPrinted 674 | let data = try self.rawData(options: jsonOption) 675 | return String(data: data, encoding: encoding) 676 | } 677 | 678 | guard let dict = self.object as? [String: Any?] else { 679 | return nil 680 | } 681 | let body = try dict.keys.map { key throws -> String in 682 | guard let value = dict[key] else { 683 | return "\"\(key)\": null" 684 | } 685 | guard let unwrappedValue = value else { 686 | return "\"\(key)\": null" 687 | } 688 | 689 | let nestedValue = JSON(unwrappedValue) 690 | guard let nestedString = try nestedValue._rawString(encoding, options: options, maxObjectDepth: maxObjectDepth - 1) else { 691 | throw NSError(domain: ErrorDomain, code: ErrorInvalidJSON, userInfo: [NSLocalizedDescriptionKey: "Could not serialize nested JSON"]) 692 | } 693 | if nestedValue.type == .string { 694 | return "\"\(key)\": \"\(nestedString.replacingOccurrences(of: "\\", with: "\\\\").replacingOccurrences(of: "\"", with: "\\\""))\"" 695 | } else { 696 | return "\"\(key)\": \(nestedString)" 697 | } 698 | } 699 | 700 | return "{\(body.joined(separator: ","))}" 701 | } catch _ { 702 | return nil 703 | } 704 | case .array: 705 | do { 706 | if !(options[.castNilToNSNull] as? Bool ?? false) { 707 | let jsonOption = options[.jsonSerialization] as? JSONSerialization.WritingOptions ?? JSONSerialization.WritingOptions.prettyPrinted 708 | let data = try self.rawData(options: jsonOption) 709 | return String(data: data, encoding: encoding) 710 | } 711 | 712 | guard let array = self.object as? [Any?] else { 713 | return nil 714 | } 715 | let body = try array.map { value throws -> String in 716 | guard let unwrappedValue = value else { 717 | return "null" 718 | } 719 | 720 | let nestedValue = JSON(unwrappedValue) 721 | guard let nestedString = try nestedValue._rawString(encoding, options: options, maxObjectDepth: maxObjectDepth - 1) else { 722 | throw NSError(domain: ErrorDomain, code: ErrorInvalidJSON, userInfo: [NSLocalizedDescriptionKey: "Could not serialize nested JSON"]) 723 | } 724 | if nestedValue.type == .string { 725 | return "\"\(nestedString.replacingOccurrences(of: "\\", with: "\\\\").replacingOccurrences(of: "\"", with: "\\\""))\"" 726 | } else { 727 | return nestedString 728 | } 729 | } 730 | 731 | return "[\(body.joined(separator: ","))]" 732 | } catch _ { 733 | return nil 734 | } 735 | case .string: 736 | return self.rawString 737 | case .number: 738 | return self.rawNumber.stringValue 739 | case .bool: 740 | return self.rawBool.description 741 | case .null: 742 | return "null" 743 | default: 744 | return nil 745 | } 746 | } 747 | } 748 | 749 | // MARK: - Printable, DebugPrintable 750 | 751 | extension JSON: Swift.CustomStringConvertible, Swift.CustomDebugStringConvertible { 752 | 753 | public var description: String { 754 | if let string = self.rawString(options:.prettyPrinted) { 755 | return string 756 | } else { 757 | return "unknown" 758 | } 759 | } 760 | 761 | public var debugDescription: String { 762 | return description 763 | } 764 | } 765 | 766 | // MARK: - Array 767 | 768 | extension JSON { 769 | 770 | //Optional [JSON] 771 | public var array: [JSON]? { 772 | get { 773 | if self.type == .array { 774 | return self.rawArray.map{ JSON($0) } 775 | } else { 776 | return nil 777 | } 778 | } 779 | } 780 | 781 | //Non-optional [JSON] 782 | public var arrayValue: [JSON] { 783 | get { 784 | return self.array ?? [] 785 | } 786 | } 787 | 788 | //Optional [Any] 789 | public var arrayObject: [Any]? { 790 | get { 791 | switch self.type { 792 | case .array: 793 | return self.rawArray 794 | default: 795 | return nil 796 | } 797 | } 798 | set { 799 | if let array = newValue { 800 | self.object = array as Any 801 | } else { 802 | self.object = NSNull() 803 | } 804 | } 805 | } 806 | } 807 | 808 | // MARK: - Dictionary 809 | 810 | extension JSON { 811 | 812 | //Optional [String : JSON] 813 | public var dictionary: [String : JSON]? { 814 | if self.type == .dictionary { 815 | var d = [String : JSON](minimumCapacity: rawDictionary.count) 816 | for (key, value) in rawDictionary { 817 | d[key] = JSON(value) 818 | } 819 | return d 820 | } else { 821 | return nil 822 | } 823 | } 824 | 825 | //Non-optional [String : JSON] 826 | public var dictionaryValue: [String : JSON] { 827 | return self.dictionary ?? [:] 828 | } 829 | 830 | //Optional [String : Any] 831 | 832 | public var dictionaryObject: [String : Any]? { 833 | get { 834 | switch self.type { 835 | case .dictionary: 836 | return self.rawDictionary 837 | default: 838 | return nil 839 | } 840 | } 841 | set { 842 | if let v = newValue { 843 | self.object = v as Any 844 | } else { 845 | self.object = NSNull() 846 | } 847 | } 848 | } 849 | } 850 | 851 | // MARK: - Bool 852 | 853 | extension JSON { // : Swift.Bool 854 | 855 | //Optional bool 856 | public var bool: Bool? { 857 | get { 858 | switch self.type { 859 | case .bool: 860 | return self.rawBool 861 | default: 862 | return nil 863 | } 864 | } 865 | set { 866 | if let newValue = newValue { 867 | self.object = newValue as Bool 868 | } else { 869 | self.object = NSNull() 870 | } 871 | } 872 | } 873 | 874 | //Non-optional bool 875 | public var boolValue: Bool { 876 | get { 877 | switch self.type { 878 | case .bool: 879 | return self.rawBool 880 | case .number: 881 | return self.rawNumber.boolValue 882 | case .string: 883 | return ["true", "y", "t"].contains() { (truthyString) in 884 | return self.rawString.caseInsensitiveCompare(truthyString) == .orderedSame 885 | } 886 | default: 887 | return false 888 | } 889 | } 890 | set { 891 | self.object = newValue 892 | } 893 | } 894 | } 895 | 896 | // MARK: - String 897 | 898 | extension JSON { 899 | 900 | //Optional string 901 | public var string: String? { 902 | get { 903 | switch self.type { 904 | case .string: 905 | return self.object as? String 906 | default: 907 | return nil 908 | } 909 | } 910 | set { 911 | if let newValue = newValue { 912 | self.object = NSString(string:newValue) 913 | } else { 914 | self.object = NSNull() 915 | } 916 | } 917 | } 918 | 919 | //Non-optional string 920 | public var stringValue: String { 921 | get { 922 | switch self.type { 923 | case .string: 924 | return self.object as? String ?? "" 925 | case .number: 926 | return self.rawNumber.stringValue 927 | case .bool: 928 | return (self.object as? Bool).map { String($0) } ?? "" 929 | default: 930 | return "" 931 | } 932 | } 933 | set { 934 | self.object = NSString(string:newValue) 935 | } 936 | } 937 | } 938 | 939 | // MARK: - Number 940 | extension JSON { 941 | 942 | //Optional number 943 | public var number: NSNumber? { 944 | get { 945 | switch self.type { 946 | case .number: 947 | return self.rawNumber 948 | case .bool: 949 | return NSNumber(value: self.rawBool ? 1 : 0) 950 | default: 951 | return nil 952 | } 953 | } 954 | set { 955 | self.object = newValue ?? NSNull() 956 | } 957 | } 958 | 959 | //Non-optional number 960 | public var numberValue: NSNumber { 961 | get { 962 | switch self.type { 963 | case .string: 964 | let decimal = NSDecimalNumber(string: self.object as? String) 965 | if decimal == NSDecimalNumber.notANumber { // indicates parse error 966 | return NSDecimalNumber.zero 967 | } 968 | return decimal 969 | case .number: 970 | return self.object as? NSNumber ?? NSNumber(value: 0) 971 | case .bool: 972 | return NSNumber(value: self.rawBool ? 1 : 0) 973 | default: 974 | return NSNumber(value: 0.0) 975 | } 976 | } 977 | set { 978 | self.object = newValue 979 | } 980 | } 981 | } 982 | 983 | //MARK: - Null 984 | extension JSON { 985 | 986 | public var null: NSNull? { 987 | get { 988 | switch self.type { 989 | case .null: 990 | return self.rawNull 991 | default: 992 | return nil 993 | } 994 | } 995 | set { 996 | self.object = NSNull() 997 | } 998 | } 999 | public func exists() -> Bool{ 1000 | if let errorValue = error, errorValue.code == ErrorNotExist || 1001 | errorValue.code == ErrorIndexOutOfBounds || 1002 | errorValue.code == ErrorWrongType { 1003 | return false 1004 | } 1005 | return true 1006 | } 1007 | } 1008 | 1009 | //MARK: - URL 1010 | extension JSON { 1011 | 1012 | //Optional URL 1013 | public var url: URL? { 1014 | get { 1015 | switch self.type { 1016 | case .string: 1017 | // Check for existing percent escapes first to prevent double-escaping of % character 1018 | if let _ = self.rawString.range(of: "%[0-9A-Fa-f]{2}", options: .regularExpression, range: nil, locale: nil) { 1019 | return Foundation.URL(string: self.rawString) 1020 | } else if let encodedString_ = self.rawString.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed) { 1021 | // We have to use `Foundation.URL` otherwise it conflicts with the variable name. 1022 | return Foundation.URL(string: encodedString_) 1023 | } else { 1024 | return nil 1025 | } 1026 | default: 1027 | return nil 1028 | } 1029 | } 1030 | set { 1031 | self.object = newValue?.absoluteString ?? NSNull() 1032 | } 1033 | } 1034 | } 1035 | 1036 | // MARK: - Int, Double, Float, Int8, Int16, Int32, Int64 1037 | 1038 | extension JSON { 1039 | 1040 | public var double: Double? { 1041 | get { 1042 | return self.number?.doubleValue 1043 | } 1044 | set { 1045 | if let newValue = newValue { 1046 | self.object = NSNumber(value: newValue) 1047 | } else { 1048 | self.object = NSNull() 1049 | } 1050 | } 1051 | } 1052 | 1053 | public var doubleValue: Double { 1054 | get { 1055 | return self.numberValue.doubleValue 1056 | } 1057 | set { 1058 | self.object = NSNumber(value: newValue) 1059 | } 1060 | } 1061 | 1062 | public var float: Float? { 1063 | get { 1064 | return self.number?.floatValue 1065 | } 1066 | set { 1067 | if let newValue = newValue { 1068 | self.object = NSNumber(value: newValue) 1069 | } else { 1070 | self.object = NSNull() 1071 | } 1072 | } 1073 | } 1074 | 1075 | public var floatValue: Float { 1076 | get { 1077 | return self.numberValue.floatValue 1078 | } 1079 | set { 1080 | self.object = NSNumber(value: newValue) 1081 | } 1082 | } 1083 | 1084 | public var int: Int? 1085 | { 1086 | get 1087 | { 1088 | return self.number?.intValue 1089 | } 1090 | set 1091 | { 1092 | if let newValue = newValue 1093 | { 1094 | self.object = NSNumber(value: newValue) 1095 | } else 1096 | { 1097 | self.object = NSNull() 1098 | } 1099 | } 1100 | } 1101 | 1102 | public var intValue: Int { 1103 | get { 1104 | return self.numberValue.intValue 1105 | } 1106 | set { 1107 | self.object = NSNumber(value: newValue) 1108 | } 1109 | } 1110 | 1111 | public var uInt: UInt? { 1112 | get { 1113 | return self.number?.uintValue 1114 | } 1115 | set { 1116 | if let newValue = newValue { 1117 | self.object = NSNumber(value: newValue) 1118 | } else { 1119 | self.object = NSNull() 1120 | } 1121 | } 1122 | } 1123 | 1124 | public var uIntValue: UInt { 1125 | get { 1126 | return self.numberValue.uintValue 1127 | } 1128 | set { 1129 | self.object = NSNumber(value: newValue) 1130 | } 1131 | } 1132 | 1133 | public var int8: Int8? { 1134 | get { 1135 | return self.number?.int8Value 1136 | } 1137 | set { 1138 | if let newValue = newValue { 1139 | self.object = NSNumber(value: Int(newValue)) 1140 | } else { 1141 | self.object = NSNull() 1142 | } 1143 | } 1144 | } 1145 | 1146 | public var int8Value: Int8 { 1147 | get { 1148 | return self.numberValue.int8Value 1149 | } 1150 | set { 1151 | self.object = NSNumber(value: Int(newValue)) 1152 | } 1153 | } 1154 | 1155 | public var uInt8: UInt8? { 1156 | get { 1157 | return self.number?.uint8Value 1158 | } 1159 | set { 1160 | if let newValue = newValue { 1161 | self.object = NSNumber(value: newValue) 1162 | } else { 1163 | self.object = NSNull() 1164 | } 1165 | } 1166 | } 1167 | 1168 | public var uInt8Value: UInt8 { 1169 | get { 1170 | return self.numberValue.uint8Value 1171 | } 1172 | set { 1173 | self.object = NSNumber(value: newValue) 1174 | } 1175 | } 1176 | 1177 | public var int16: Int16? { 1178 | get { 1179 | return self.number?.int16Value 1180 | } 1181 | set { 1182 | if let newValue = newValue { 1183 | self.object = NSNumber(value: newValue) 1184 | } else { 1185 | self.object = NSNull() 1186 | } 1187 | } 1188 | } 1189 | 1190 | public var int16Value: Int16 { 1191 | get { 1192 | return self.numberValue.int16Value 1193 | } 1194 | set { 1195 | self.object = NSNumber(value: newValue) 1196 | } 1197 | } 1198 | 1199 | public var uInt16: UInt16? { 1200 | get { 1201 | return self.number?.uint16Value 1202 | } 1203 | set { 1204 | if let newValue = newValue { 1205 | self.object = NSNumber(value: newValue) 1206 | } else { 1207 | self.object = NSNull() 1208 | } 1209 | } 1210 | } 1211 | 1212 | public var uInt16Value: UInt16 { 1213 | get { 1214 | return self.numberValue.uint16Value 1215 | } 1216 | set { 1217 | self.object = NSNumber(value: newValue) 1218 | } 1219 | } 1220 | 1221 | public var int32: Int32? { 1222 | get { 1223 | return self.number?.int32Value 1224 | } 1225 | set { 1226 | if let newValue = newValue { 1227 | self.object = NSNumber(value: newValue) 1228 | } else { 1229 | self.object = NSNull() 1230 | } 1231 | } 1232 | } 1233 | 1234 | public var int32Value: Int32 { 1235 | get { 1236 | return self.numberValue.int32Value 1237 | } 1238 | set { 1239 | self.object = NSNumber(value: newValue) 1240 | } 1241 | } 1242 | 1243 | public var uInt32: UInt32? { 1244 | get { 1245 | return self.number?.uint32Value 1246 | } 1247 | set { 1248 | if let newValue = newValue { 1249 | self.object = NSNumber(value: newValue) 1250 | } else { 1251 | self.object = NSNull() 1252 | } 1253 | } 1254 | } 1255 | 1256 | public var uInt32Value: UInt32 { 1257 | get { 1258 | return self.numberValue.uint32Value 1259 | } 1260 | set { 1261 | self.object = NSNumber(value: newValue) 1262 | } 1263 | } 1264 | 1265 | public var int64: Int64? { 1266 | get { 1267 | return self.number?.int64Value 1268 | } 1269 | set { 1270 | if let newValue = newValue { 1271 | self.object = NSNumber(value: newValue) 1272 | } else { 1273 | self.object = NSNull() 1274 | } 1275 | } 1276 | } 1277 | 1278 | public var int64Value: Int64 { 1279 | get { 1280 | return self.numberValue.int64Value 1281 | } 1282 | set { 1283 | self.object = NSNumber(value: newValue) 1284 | } 1285 | } 1286 | 1287 | public var uInt64: UInt64? { 1288 | get { 1289 | return self.number?.uint64Value 1290 | } 1291 | set { 1292 | if let newValue = newValue { 1293 | self.object = NSNumber(value: newValue) 1294 | } else { 1295 | self.object = NSNull() 1296 | } 1297 | } 1298 | } 1299 | 1300 | public var uInt64Value: UInt64 { 1301 | get { 1302 | return self.numberValue.uint64Value 1303 | } 1304 | set { 1305 | self.object = NSNumber(value: newValue) 1306 | } 1307 | } 1308 | } 1309 | 1310 | //MARK: - Comparable 1311 | extension JSON : Swift.Comparable {} 1312 | 1313 | public func ==(lhs: JSON, rhs: JSON) -> Bool { 1314 | 1315 | switch (lhs.type, rhs.type) { 1316 | case (.number, .number): 1317 | return lhs.rawNumber == rhs.rawNumber 1318 | case (.string, .string): 1319 | return lhs.rawString == rhs.rawString 1320 | case (.bool, .bool): 1321 | return lhs.rawBool == rhs.rawBool 1322 | case (.array, .array): 1323 | return lhs.rawArray as NSArray == rhs.rawArray as NSArray 1324 | case (.dictionary, .dictionary): 1325 | return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary 1326 | case (.null, .null): 1327 | return true 1328 | default: 1329 | return false 1330 | } 1331 | } 1332 | 1333 | public func <=(lhs: JSON, rhs: JSON) -> Bool { 1334 | 1335 | switch (lhs.type, rhs.type) { 1336 | case (.number, .number): 1337 | return lhs.rawNumber <= rhs.rawNumber 1338 | case (.string, .string): 1339 | return lhs.rawString <= rhs.rawString 1340 | case (.bool, .bool): 1341 | return lhs.rawBool == rhs.rawBool 1342 | case (.array, .array): 1343 | return lhs.rawArray as NSArray == rhs.rawArray as NSArray 1344 | case (.dictionary, .dictionary): 1345 | return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary 1346 | case (.null, .null): 1347 | return true 1348 | default: 1349 | return false 1350 | } 1351 | } 1352 | 1353 | public func >=(lhs: JSON, rhs: JSON) -> Bool { 1354 | 1355 | switch (lhs.type, rhs.type) { 1356 | case (.number, .number): 1357 | return lhs.rawNumber >= rhs.rawNumber 1358 | case (.string, .string): 1359 | return lhs.rawString >= rhs.rawString 1360 | case (.bool, .bool): 1361 | return lhs.rawBool == rhs.rawBool 1362 | case (.array, .array): 1363 | return lhs.rawArray as NSArray == rhs.rawArray as NSArray 1364 | case (.dictionary, .dictionary): 1365 | return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary 1366 | case (.null, .null): 1367 | return true 1368 | default: 1369 | return false 1370 | } 1371 | } 1372 | 1373 | public func >(lhs: JSON, rhs: JSON) -> Bool { 1374 | 1375 | switch (lhs.type, rhs.type) { 1376 | case (.number, .number): 1377 | return lhs.rawNumber > rhs.rawNumber 1378 | case (.string, .string): 1379 | return lhs.rawString > rhs.rawString 1380 | default: 1381 | return false 1382 | } 1383 | } 1384 | 1385 | public func <(lhs: JSON, rhs: JSON) -> Bool { 1386 | 1387 | switch (lhs.type, rhs.type) { 1388 | case (.number, .number): 1389 | return lhs.rawNumber < rhs.rawNumber 1390 | case (.string, .string): 1391 | return lhs.rawString < rhs.rawString 1392 | default: 1393 | return false 1394 | } 1395 | } 1396 | 1397 | private let trueNumber = NSNumber(value: true) 1398 | private let falseNumber = NSNumber(value: false) 1399 | private let trueObjCType = String(cString: trueNumber.objCType) 1400 | private let falseObjCType = String(cString: falseNumber.objCType) 1401 | 1402 | // MARK: - NSNumber: Comparable 1403 | 1404 | extension NSNumber { 1405 | var isBool:Bool { 1406 | get { 1407 | let objCType = String(cString: self.objCType) 1408 | if (self.compare(trueNumber) == .orderedSame && objCType == trueObjCType) || (self.compare(falseNumber) == .orderedSame && objCType == falseObjCType){ 1409 | return true 1410 | } else { 1411 | return false 1412 | } 1413 | } 1414 | } 1415 | } 1416 | 1417 | func ==(lhs: NSNumber, rhs: NSNumber) -> Bool { 1418 | switch (lhs.isBool, rhs.isBool) { 1419 | case (false, true): 1420 | return false 1421 | case (true, false): 1422 | return false 1423 | default: 1424 | return lhs.compare(rhs) == .orderedSame 1425 | } 1426 | } 1427 | 1428 | func !=(lhs: NSNumber, rhs: NSNumber) -> Bool { 1429 | return !(lhs == rhs) 1430 | } 1431 | 1432 | func <(lhs: NSNumber, rhs: NSNumber) -> Bool { 1433 | 1434 | switch (lhs.isBool, rhs.isBool) { 1435 | case (false, true): 1436 | return false 1437 | case (true, false): 1438 | return false 1439 | default: 1440 | return lhs.compare(rhs) == .orderedAscending 1441 | } 1442 | } 1443 | 1444 | func >(lhs: NSNumber, rhs: NSNumber) -> Bool { 1445 | 1446 | switch (lhs.isBool, rhs.isBool) { 1447 | case (false, true): 1448 | return false 1449 | case (true, false): 1450 | return false 1451 | default: 1452 | return lhs.compare(rhs) == ComparisonResult.orderedDescending 1453 | } 1454 | } 1455 | 1456 | func <=(lhs: NSNumber, rhs: NSNumber) -> Bool { 1457 | 1458 | switch (lhs.isBool, rhs.isBool) { 1459 | case (false, true): 1460 | return false 1461 | case (true, false): 1462 | return false 1463 | default: 1464 | return lhs.compare(rhs) != .orderedDescending 1465 | } 1466 | } 1467 | 1468 | func >=(lhs: NSNumber, rhs: NSNumber) -> Bool { 1469 | 1470 | switch (lhs.isBool, rhs.isBool) { 1471 | case (false, true): 1472 | return false 1473 | case (true, false): 1474 | return false 1475 | default: 1476 | return lhs.compare(rhs) != .orderedAscending 1477 | } 1478 | } 1479 | 1480 | public enum writtingOptionsKeys { 1481 | case jsonSerialization 1482 | case castNilToNSNull 1483 | case maxObjextDepth 1484 | case encoding 1485 | } 1486 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/Target Support Files/Pods-Example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/Target Support Files/Pods-Example/Pods-Example-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## SwiftyJSON 5 | 6 | The MIT License (MIT) 7 | 8 | Copyright (c) 2016 Ruoyu Fu 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | 28 | Generated by CocoaPods - https://cocoapods.org 29 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/Target Support Files/Pods-Example/Pods-Example-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | The MIT License (MIT) 18 | 19 | Copyright (c) 2016 Ruoyu Fu 20 | 21 | Permission is hereby granted, free of charge, to any person obtaining a copy 22 | of this software and associated documentation files (the "Software"), to deal 23 | in the Software without restriction, including without limitation the rights 24 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 25 | copies of the Software, and to permit persons to whom the Software is 26 | furnished to do so, subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in 29 | all copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 36 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 37 | THE SOFTWARE. 38 | 39 | License 40 | MIT 41 | Title 42 | SwiftyJSON 43 | Type 44 | PSGroupSpecifier 45 | 46 | 47 | FooterText 48 | Generated by CocoaPods - https://cocoapods.org 49 | Title 50 | 51 | Type 52 | PSGroupSpecifier 53 | 54 | 55 | StringsTable 56 | Acknowledgements 57 | Title 58 | Acknowledgements 59 | 60 | 61 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/Target Support Files/Pods-Example/Pods-Example-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_Example : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_Example 5 | @end 6 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/Target Support Files/Pods-Example/Pods-Example-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | # This protects against multiple targets copying the same framework dependency at the same time. The solution 10 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html 11 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") 12 | 13 | install_framework() 14 | { 15 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 16 | local source="${BUILT_PRODUCTS_DIR}/$1" 17 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 18 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 19 | elif [ -r "$1" ]; then 20 | local source="$1" 21 | fi 22 | 23 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 24 | 25 | if [ -L "${source}" ]; then 26 | echo "Symlinked..." 27 | source="$(readlink "${source}")" 28 | fi 29 | 30 | # Use filter instead of exclude so missing patterns don't throw errors. 31 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 32 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 33 | 34 | local basename 35 | basename="$(basename -s .framework "$1")" 36 | binary="${destination}/${basename}.framework/${basename}" 37 | if ! [ -r "$binary" ]; then 38 | binary="${destination}/${basename}" 39 | fi 40 | 41 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 42 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 43 | strip_invalid_archs "$binary" 44 | fi 45 | 46 | # Resign the code if required by the build settings to avoid unstable apps 47 | code_sign_if_enabled "${destination}/$(basename "$1")" 48 | 49 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 50 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 51 | local swift_runtime_libs 52 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 53 | for lib in $swift_runtime_libs; do 54 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 55 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 56 | code_sign_if_enabled "${destination}/${lib}" 57 | done 58 | fi 59 | } 60 | 61 | # Copies the dSYM of a vendored framework 62 | install_dsym() { 63 | local source="$1" 64 | if [ -r "$source" ]; then 65 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DWARF_DSYM_FOLDER_PATH}\"" 66 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DWARF_DSYM_FOLDER_PATH}" 67 | fi 68 | } 69 | 70 | # Signs a framework with the provided identity 71 | code_sign_if_enabled() { 72 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 73 | # Use the current code_sign_identitiy 74 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 75 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'" 76 | 77 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 78 | code_sign_cmd="$code_sign_cmd &" 79 | fi 80 | echo "$code_sign_cmd" 81 | eval "$code_sign_cmd" 82 | fi 83 | } 84 | 85 | # Strip invalid architectures 86 | strip_invalid_archs() { 87 | binary="$1" 88 | # Get architectures for current file 89 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 90 | stripped="" 91 | for arch in $archs; do 92 | if ! [[ "${ARCHS}" == *"$arch"* ]]; then 93 | # Strip non-valid architectures in-place 94 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 95 | stripped="$stripped $arch" 96 | fi 97 | done 98 | if [[ "$stripped" ]]; then 99 | echo "Stripped $binary of architectures:$stripped" 100 | fi 101 | } 102 | 103 | 104 | if [[ "$CONFIGURATION" == "Debug" ]]; then 105 | install_framework "${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework" 106 | fi 107 | if [[ "$CONFIGURATION" == "Release" ]]; then 108 | install_framework "${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework" 109 | fi 110 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 111 | wait 112 | fi 113 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/Target Support Files/Pods-Example/Pods-Example-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | # This protects against multiple targets copying the same framework dependency at the same time. The solution 12 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html 13 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") 14 | 15 | case "${TARGETED_DEVICE_FAMILY}" in 16 | 1,2) 17 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 18 | ;; 19 | 1) 20 | TARGET_DEVICE_ARGS="--target-device iphone" 21 | ;; 22 | 2) 23 | TARGET_DEVICE_ARGS="--target-device ipad" 24 | ;; 25 | 3) 26 | TARGET_DEVICE_ARGS="--target-device tv" 27 | ;; 28 | 4) 29 | TARGET_DEVICE_ARGS="--target-device watch" 30 | ;; 31 | *) 32 | TARGET_DEVICE_ARGS="--target-device mac" 33 | ;; 34 | esac 35 | 36 | install_resource() 37 | { 38 | if [[ "$1" = /* ]] ; then 39 | RESOURCE_PATH="$1" 40 | else 41 | RESOURCE_PATH="${PODS_ROOT}/$1" 42 | fi 43 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 44 | cat << EOM 45 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 46 | EOM 47 | exit 1 48 | fi 49 | case $RESOURCE_PATH in 50 | *.storyboard) 51 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true 52 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 53 | ;; 54 | *.xib) 55 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true 56 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 57 | ;; 58 | *.framework) 59 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true 60 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 61 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true 62 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 63 | ;; 64 | *.xcdatamodel) 65 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" || true 66 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 67 | ;; 68 | *.xcdatamodeld) 69 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" || true 70 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 71 | ;; 72 | *.xcmappingmodel) 73 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" || true 74 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 75 | ;; 76 | *.xcassets) 77 | ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" 78 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 79 | ;; 80 | *) 81 | echo "$RESOURCE_PATH" || true 82 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 83 | ;; 84 | esac 85 | } 86 | 87 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 88 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 89 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 90 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 91 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 92 | fi 93 | rm -f "$RESOURCES_TO_COPY" 94 | 95 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 96 | then 97 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 98 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 99 | while read line; do 100 | if [[ $line != "${PODS_ROOT}*" ]]; then 101 | XCASSET_FILES+=("$line") 102 | fi 103 | done <<<"$OTHER_XCASSETS" 104 | 105 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 106 | fi 107 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/Target Support Files/Pods-Example/Pods-Example-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_ExampleVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_ExampleVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/Target Support Files/Pods-Example/Pods-Example.debug.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/SwiftyJSON" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/SwiftyJSON/SwiftyJSON.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -framework "SwiftyJSON" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_BUILD_DIR = $BUILD_DIR 9 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/Target Support Files/Pods-Example/Pods-Example.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_Example { 2 | umbrella header "Pods-Example-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/Target Support Files/Pods-Example/Pods-Example.release.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/SwiftyJSON" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/SwiftyJSON/SwiftyJSON.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -framework "SwiftyJSON" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_BUILD_DIR = $BUILD_DIR 9 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/Target Support Files/SwiftyJSON/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 3.1.4 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/Target Support Files/SwiftyJSON/SwiftyJSON-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_SwiftyJSON : NSObject 3 | @end 4 | @implementation PodsDummy_SwiftyJSON 5 | @end 6 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/Target Support Files/SwiftyJSON/SwiftyJSON-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/Target Support Files/SwiftyJSON/SwiftyJSON-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double SwiftyJSONVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char SwiftyJSONVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/Target Support Files/SwiftyJSON/SwiftyJSON.modulemap: -------------------------------------------------------------------------------- 1 | framework module SwiftyJSON { 2 | umbrella header "SwiftyJSON-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /fixtures/ios/Example/Pods/Target Support Files/SwiftyJSON/SwiftyJSON.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/SwiftyJSON 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 4 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 5 | PODS_BUILD_DIR = $BUILD_DIR 6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/SwiftyJSON 9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 10 | SKIP_INSTALL = YES 11 | SWIFT_VERSION = 3.0 12 | -------------------------------------------------------------------------------- /fixtures/ios/bridging-header.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Mozilla 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | this file except in compliance with the License. You may obtain a copy of the 5 | License at http://www.apache.org/licenses/LICENSE-2.0 6 | Unless required by applicable law or agreed to in writing, software distributed 7 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 8 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | #ifndef bridging_header_h 13 | #define bridging_header_h 14 | 15 | #include "externals.h" 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /fixtures/ios/externals.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Mozilla 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | this file except in compliance with the License. You may obtain a copy of the 5 | License at http://www.apache.org/licenses/LICENSE-2.0 6 | Unless required by applicable law or agreed to in writing, software distributed 7 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 8 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | #include 13 | 14 | const char* __get_display_list(float, float); 15 | void __free_display_list(char *); 16 | -------------------------------------------------------------------------------- /fixtures/web/example-canvas.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | 15 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /fixtures/web/example-dom.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | 15 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /fixtures/web/example-webgl.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | 15 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /fixtures/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /gulpfile.babel.js: -------------------------------------------------------------------------------- 1 | // Any copyright is dedicated to the Public Domain. 2 | // http://creativecommons.org/publicdomain/zero/1.0/ 3 | 4 | import del from 'del'; 5 | import gulp from 'gulp'; 6 | import exec from 'gulp-exec'; 7 | import flatten from 'gulp-flatten'; 8 | import rename from 'gulp-rename'; 9 | import serve from 'serve'; 10 | import yargs from 'yargs'; 11 | 12 | const TARGET = yargs.argv.target || 'asmjs-unknown-emscripten'; 13 | const RELEASE = yargs.argv.release ? '--release' : ''; 14 | const DIST_DIR = './dist/target-web'; 15 | 16 | console.log(`TARGET = ${TARGET}`); 17 | console.log(`RELEASE = ${RELEASE}`); 18 | 19 | const CARGO_EXEC_OPTIONS = { 20 | pipeStdout: true, 21 | }; 22 | 23 | gulp.task('clean', () => 24 | del(['./dist'])); 25 | 26 | gulp.task('build-web:copy-html', () => 27 | gulp.src('./fixtures/web/**/*.html') 28 | .pipe(flatten()) 29 | .pipe(gulp.dest(DIST_DIR))); 30 | 31 | gulp.task('build-web:copy-js', () => 32 | gulp.src('./rsx-renderers/packages/web-renderer/dist/bundle/**/*.{js,map}') 33 | .pipe(flatten()) 34 | .pipe(gulp.dest(DIST_DIR))); 35 | 36 | gulp.task('build-web:copy-rust', () => 37 | gulp.src(`./target/${TARGET}/${RELEASE ? 'release' : 'debug'}/*.{js,map}`) 38 | .pipe(rename({ basename: 'main.rs' })) 39 | .pipe(gulp.dest(DIST_DIR))); 40 | 41 | gulp.task('build-web:cargo', () => 42 | gulp.src('./Cargo.toml') 43 | .pipe(exec(`cargo build --manifest-path <%= file.path %> --target=${TARGET} ${RELEASE}`, CARGO_EXEC_OPTIONS)) 44 | .pipe(exec.reporter())); 45 | 46 | gulp.task('build', gulp.series( 47 | 'clean', 48 | 'build-web:cargo', 49 | 'build-web:copy-html', 50 | 'build-web:copy-js', 51 | 'build-web:copy-rust', 52 | )); 53 | 54 | gulp.task('open', () => 55 | serve(DIST_DIR, { open: yargs.argv.open })); 56 | 57 | gulp.task('start', gulp.series( 58 | 'build', 59 | 'open', 60 | )); 61 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rsx-demo", 3 | "version": "1.0.0", 4 | "description": "RSX Demo", 5 | "repository": "https://github.com/victorporof/rsx-demo", 6 | "main": "src/js/index.js", 7 | "scripts": { 8 | "clean": "gulp clean", 9 | "build": "gulp build", 10 | "start": "npm run release", 11 | "debug": "gulp start", 12 | "release": "gulp start --release", 13 | "test": "echo \"Error: no test specified\" && exit 1" 14 | }, 15 | "author": "Victor Porof ", 16 | "license": "Apache-2.0", 17 | "engines": { 18 | "node": ">=9.0.0" 19 | }, 20 | "devDependencies": { 21 | "babel-core": "6.26.0", 22 | "babel-eslint": "8.2.1", 23 | "babel-preset-env": "1.6.1", 24 | "del": "3.0.0", 25 | "eslint": "4.16.0", 26 | "eslint-config-airbnb-base": "12.1.0", 27 | "eslint-plugin-babel": "4.1.2", 28 | "eslint-plugin-import": "2.8.0", 29 | "gulp": "4.0.0", 30 | "gulp-exec": "3.0.1", 31 | "gulp-flatten": "0.4.0", 32 | "gulp-rename": "1.2.2", 33 | "serve": "6.4.8", 34 | "yargs": "10.1.1" 35 | } 36 | } -------------------------------------------------------------------------------- /rust-toolchain: -------------------------------------------------------------------------------- 1 | nightly-2017-11-14 -------------------------------------------------------------------------------- /src/example.css: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Mozilla 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | this file except in compliance with the License. You may obtain a copy of the 5 | License at http://www.apache.org/licenses/LICENSE-2.0 6 | Unless required by applicable law or agreed to in writing, software distributed 7 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 8 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | .center { 13 | flex: 1; 14 | align-items: center; 15 | justify-content: center; 16 | } 17 | 18 | .root { 19 | background-color: rgba(255, 0, 0, 0.1); 20 | width: 500px; 21 | height: 120px; 22 | flex-direction: row; 23 | align-items: center; 24 | padding: 20px; 25 | } 26 | 27 | .image { 28 | background-color: rgba(0, 128, 0, 0.1); 29 | opacity: 0.5; 30 | width: 80px; 31 | margin-right: 20px; 32 | } 33 | 34 | .text { 35 | background-color: rgba(0, 0, 255, 0.1); 36 | color: #333; 37 | height: 25px; 38 | flex-shrink: 1; 39 | font-size: 18px; 40 | overflow: hidden; 41 | } 42 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Mozilla 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | this file except in compliance with the License. You may obtain a copy of the 5 | License at http://www.apache.org/licenses/LICENSE-2.0 6 | Unless required by applicable law or agreed to in writing, software distributed 7 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 8 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | #![feature(box_syntax)] 13 | #![feature(proc_macro)] 14 | #![feature(link_args)] 15 | 16 | extern crate rsx; 17 | #[macro_use] 18 | extern crate rsx_embedding; 19 | 20 | use rsx::{css, load_font, load_image, rsx}; 21 | use rsx_embedding::rsx_dom::types::*; 22 | use rsx_embedding::rsx_primitives::prelude::{DOMTree, ResourceGroup}; 23 | use rsx_embedding::rsx_resources::fonts::types::EncodedFont; 24 | use rsx_embedding::rsx_resources::images::types::{EncodedImage, ImageEncodingFormat}; 25 | use rsx_embedding::rsx_shared::traits::{TDOMNode, TFontCache, TImageCache, TResourceGroup}; 26 | use rsx_embedding::rsx_stylesheet::types::*; 27 | 28 | link! { 29 | setup, 30 | render 31 | } 32 | 33 | fn setup(resources: &mut ResourceGroup) { 34 | let logo = load_image!("fixtures/images/Quantum.png"); 35 | resources.images().add_image("app://logo.png", &logo); 36 | 37 | let font = load_font!("fixtures/fonts/FreeSans.ttf"); 38 | resources.fonts().add_font("FreeSans", &font, 0); 39 | } 40 | 41 | fn render() -> DOMTree { 42 | let mut stylesheet = css!("src/example.css"); 43 | 44 | rsx! { 45 | 46 | 47 | 48 | 49 | { "Hello World!" } 50 | 51 | 52 | 53 | } 54 | } 55 | --------------------------------------------------------------------------------