├── .gitignore
├── README.md
├── SetupEnv.sh
├── docs
├── PrepareMac.md
└── PrepareProject.md
├── scripts
├── 01-PrepareMac.sh
├── 02-DownloadLatestLibs.sh
├── 03-DownloadNdk.sh
├── 100-UpdateAndRun.sh
├── 12-CreateAndroidProject.sh
├── 14-CopyAndroidMutataLibs.sh
├── 15-ConvertIosProject.sh
├── 16-CreateSwiftPackageAndMutataFiles.sh
├── 17-CopyAndroidResFiles.sh
├── 18-CopyIosImagesAndXibs.sh
├── 19-UpdateMutataLicense.sh
├── 20-InstallAndRun.sh
├── 30-CleanBuildFolder.sh
├── 31-CleanMutataLibs.sh
└── 40-DownloadFreeLicense.sh
└── template_files
├── AndroidRes
└── res
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ └── values
│ ├── ic_launcher_background.xml
│ └── strings.xml
├── SourcesPackage.swift
└── SwiftPackage
├── Package.swift
└── Sources
└── SwiftAndroid
├── AndroidAppDelegate.swift
├── JavaBind.swift
└── Nib2UIKit+Nib2UIKitPackageNameProtocol.swift
/.gitignore:
--------------------------------------------------------------------------------
1 | build
2 | mutata_libs
3 | android-ndk-r21e
4 | license.json
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Quick Start Links
2 | __[How to video: Run MutataApp on your Mac](https://youtu.be/8pCRIwWf0Bg)__
3 | __[Get your Free to Try license](docs/PrepareProject.md#download-mutata-license)__
4 | __[Prepare your Mac](docs/PrepareMac.md)__
5 | __[Prepare your Project (Scripts-Only)](#prepare-and-run-your-project)__
6 | __[Prepare your Project (Detailed)](docs/PrepareProject.md)__
7 |
8 |
9 | # MutataApp
10 |
11 | [Mutata.io](https://mutata.io) is the first framework that enables you to run Swift iOS applications on Android devices, without rewriting your code.
12 |
13 | We have prepared automated scripts for every step needed to run your iOS project on an Android device.
14 |
15 | # Prepare your Mac
16 | In order to build your Swift project for Android on your macOS machine, you will need to install some open-source programs and libraries first.
17 | Please check the [Prepare your Mac](docs/PrepareMac.md) section before using Mutata for the first time.
18 |
19 | # Prepare and Run your project
20 | To run your iOS project using Mutata, after you have [Prepared your Mac](docs/PrepareMac.md), you will also need to prepare your iOS project.
21 | __Note:__ All of the scripts are explained in the detailed [Prepare your project](docs/PrepareProject.md) section.
22 |
23 | ```console
24 |
25 | # Create a new folder and cd in it.
26 |
27 | # MUTATA_IOS_SOURCES_PATH should be set to the path of your iOS Project
28 | # Example: Mutata Showcase App
29 | git clone https://github.com/kodika/Mutata-Showcase-App
30 | export MUTATA_IOS_SOURCES_PATH=$PWD/Mutata-Showcase-App
31 | # or use your own iOS Project
32 | # export MUTATA_IOS_SOURCES_PATH=/path/to/your/ios/sources
33 |
34 | # Your app's name without spaces and dashes
35 | export MUTATA_SWIFT_MODULE_NAME="MutataShowcase"
36 |
37 | # Clone this repo (MutataApp)
38 | git clone https://github.com/kodika/MutataApp
39 | cd MutataApp
40 | export MUTATA_ROOT_PATH=$PWD
41 |
42 | # (Optional) Prepare your Mac
43 | ./scripts/01-PrepareMac.sh
44 |
45 | # Download Mutata Libs and Ndk
46 | ./scripts/02-DownloadLatestLibs.sh
47 | ./scripts/03-DownloadNdk.sh
48 |
49 |
50 | # Prepare your Project
51 | # Please make sure to run the commands in the correct order and only once.
52 | # You can clean the generated files with ./scripts/30-CleanBuildFolder.sh
53 |
54 | ./scripts/12-CreateAndroidProject.sh
55 | ./scripts/14-CopyAndroidMutataLibs.sh
56 | ./scripts/15-ConvertIosProject.sh
57 | ./scripts/16-CreateSwiftPackageAndMutataFiles.sh
58 | ./scripts/17-CopyAndroidResFiles.sh
59 | ./scripts/18-CopyIosImagesAndXibs.sh
60 | ./scripts/40-DownloadFreeLicense.sh your@email.com
61 | ./scripts/19-UpdateMutataLicense.sh
62 |
63 | # Connect Android Device or Launch Android Emulator
64 |
65 | # Compile, Install and Run
66 | ./scripts/20-InstallAndRun.sh
67 |
68 | # Enjoy!
69 | ```
70 |
71 | ## Edit your iOS Code
72 | There is no need to run the whole process everytime you change something in your iOS Swift codebase.
73 | After you have edited your iOS Project using Xcode and have run it successfully in the iOS simulator, you can use these scripts to recompile and run your Android app.
74 |
75 | ```console
76 | # cd in the folder they you have cloned MutataApp (this repo)
77 | cd /path/to/MutataApp
78 |
79 | # (Optional) Set environment variables if they are not already set.
80 | # Custom Environment variables are usually cleared when Terminal is closed.
81 | export MUTATA_ROOT_PATH=$PWD
82 |
83 | # Path to your iOS Source code.
84 | export MUTATA_IOS_SOURCES_PATH=/path/to/your/ios/sources
85 |
86 | # Your app's name without spaces and dashes
87 | export MUTATA_SWIFT_MODULE_NAME="YourAppsName"
88 |
89 | # Run All-In-One script
90 | ./scripts/100-UpdateAndRun.sh
91 |
92 | # or you can run each script individually
93 | ./scripts/15-ConvertIosProject.sh
94 | ./scripts/16-CreateSwiftPackageAndMutataFiles.sh
95 | ./scripts/18-CopyIosImagesAndXibs.sh
96 | ./scripts/19-UpdateMutataLicense.sh
97 | ./scripts/20-InstallAndRun.sh
98 |
99 | ```
100 |
101 |
102 | ## MUTATA_ROOT_PATH environment variable.
103 | For Mutata scripts to work, clone this repo and then, set the __MUTATA_ROOT_PATH__ environment variable.
104 | __Note:__ You will need a new clone of the MutataApp repo for each of your iOS apps.
105 | __Note:__ You will need to set the environment variables every time you start the terminal, or change to a different iOS project.
106 |
--------------------------------------------------------------------------------
/SetupEnv.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [ -z "$MUTATA_ROOT_PATH" ]
4 | then
5 | echo -e "Please provide MUTATA_ROOT_PATH\nExample:\nexport MUTATA_ROOT_PATH=$PWD"
6 | return -1
7 | fi
8 |
9 | export MUTATA_SCRIPTS_PATH=$MUTATA_ROOT_PATH/scripts
10 | export MUTATA_TEMPLATES_PATH=$MUTATA_ROOT_PATH/template_files
11 | export MUTATA_BUILD_PATH=$MUTATA_ROOT_PATH/build
12 | export MUTATA_LIBS_PATH=$MUTATA_ROOT_PATH/mutata_libs
13 |
14 | export MUTATA_BUILD_SWIFT_SOURCES_ANDROID_PATH=$MUTATA_BUILD_PATH/iOSSources/Sources-Android
15 |
16 |
17 |
18 | export JAVA_HOME=$(/usr/libexec/java_home --version 1.8)
19 | export TOOLCHAINS=org.swift.540202104261a
20 |
21 | export ANDROID_NDK_HOME=$MUTATA_ROOT_PATH/android-ndk-r21e
22 | export NDK_ROOT=$ANDROID_NDK_HOME
23 | export ANDROID_NDK=$ANDROID_NDK_HOME
24 | export ANDROID_NDK_ROOT=$ANDROID_NDK_HOME
25 |
26 | export SWIFT_ANDROID_HOME=$MUTATA_LIBS_PATH/swift-android-5.4-r1
27 |
--------------------------------------------------------------------------------
/docs/PrepareMac.md:
--------------------------------------------------------------------------------
1 | # Prepare your Mac
2 |
3 | In order to be able to compile Swift iOS apps for Android you will need to have:
4 | - Official Swift 5.4.2 Toolchain for Xcode
5 | - Swift Android Toolchain & Gradle Plugin
6 | - Android NDK r21e
7 | - JDK 8
8 | - Precompiled Swift Mutata Libraries
9 | - Precompiled Mutata Android Libraries
10 | - HomeBrew, CMake and other tools
11 | - Android Studio & Command Line Tools
12 |
13 |
14 | # Automated Install Steps
15 | - Download Official Swift 5.4.2 Toolchain for Xcode from https://swift.org/builds/swift-5.4.2-release/xcode/swift-5.4.2-RELEASE/swift-5.4.2-RELEASE-osx.pkg and install it.
16 | - If you do not have Xcode Command Line tools, run `xcode-select --install`
17 | - Download and install Android Command Line Tools from https://developer.android.com/studio#command-tools
18 |
19 | - Clone this repo `git clone https://github.com/kodika/MutataApp`
20 | - Run `./scripts/01-PrepareMac.sh` to install HomeBrew, JDK 8, CMake.
21 | - Run `./scripts/02-DownloadLatestLibs.sh` to download latest Swift Android Toolchain, Mutata Swift and Android Libraries.
22 | - Run `./scripts/03-DownloadNdk.sh` to download the Android NDK r21e from Google.
23 |
24 | ```console
25 | # Clone this repo (MutataApp)
26 | git clone https://github.com/kodika/MutataApp
27 | cd MutataApp
28 | export MUTATA_ROOT_PATH=$PWD
29 |
30 | # Prepare your Mac
31 | ./scripts/01-PrepareMac.sh
32 |
33 | # Download latest Swift Android Toolchain, Mutata Swift and Android Libraries.
34 | ./scripts/02-DownloadLatestLibs.sh
35 |
36 | # Download the Android NDK r21e from Google
37 | ./scripts/03-DownloadNdk.sh
38 |
39 | ```
40 |
41 | # Manual Install Steps
42 | We suggest that you use the [Automated Install Steps](#Automated-Install-Steps) that we have prepared to ensure that you have the correct tools and versions but, below are the detailed instructions for each step/tool.
43 |
44 | ## Official Swift 5.4.2 Toolchain for Xcode
45 | Mutata is using the official [Swift 5.4.2](https://github.com/apple/swift/tree/swift-5.4.2-RELEASE) toolchain for Xcode which you can download from https://swift.org/builds/swift-5.4.2-release/xcode/swift-5.4.2-RELEASE/swift-5.4.2-RELEASE-osx.pkg
46 |
47 | ## Swift Android Toolchain + Gradle Plugin
48 | In order to make the compilation of Swift and the integration with Gradle easier, Readdle has created a [Gradle Plugin](https://github.com/readdle/swift-android-gradle) that integrates with the Swift Android Toolchain.
49 |
50 | ## Android NDK
51 | ```console
52 | cd $MUTATA_ROOT_PATH
53 | wget https://dl.google.com/android/repository/android-ndk-r21e-darwin-x86_64.zip
54 | unzip android-ndk-r21e-darwin-x86_64.zip
55 | rm -rf android-ndk-r21e-darwin-x86_64.zip
56 | ```
57 |
58 | ## JDK 8
59 | You will need JDK 8 to be able to compile the Android project.
60 | ```console
61 | brew search openjdk
62 | brew install openjdk@8
63 | ```
64 |
65 | ## Mutata Libraries
66 | In order to support the iOS frameworks on Android devices, you will need to have the __Mutata libraries__ and __Mutata Swift Android Toolchain__, which can be downloaded from [Mutata Libraries Releases](https://github.com/kodika/MutataLibraries/releases/latest).
67 |
68 | ## Homebrew
69 | ```console
70 | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
71 | ```
72 |
73 | ## CMake, Gradle and other tools
74 | You will need to have CMake and other open-source tools to use the Mutata scripts.
75 | ```console
76 | brew install coreutils cmake wget gradle
77 | ```
78 |
79 | ## Android Studio & Command Line Tools
80 | Download and install __Android Studio__ from https://developer.android.com/studio and then, install __Command Line tools__ and __Android 11 Platform tools__.
81 |
--------------------------------------------------------------------------------
/docs/PrepareProject.md:
--------------------------------------------------------------------------------
1 | ## MUTATA_ROOT_PATH environment variable.
2 | For Mutata scripts to work, clone this repo and then, set the __MUTATA_ROOT_PATH__ environment variable.
3 | __Note:__ You will need a new clone of this repo for each of your iOS apps.
4 | __Note:__ You will need to set the environment variables every time you start the terminal, or change to a different iOS project.
5 | ```console
6 | # Clone the repo
7 | git clone https://github.com/kodika/MutataApp
8 |
9 | # Change Directory to the MutataApp.
10 | cd MutataApp
11 |
12 | # Set environment variable to current directory
13 | export MUTATA_ROOT_PATH=$PWD
14 | ```
15 |
16 | ## Download Pre-configured Android project
17 |
18 | To create your .apk, you will need an Android Project which will include your Android Manifest, your assets, and the compiled Swift libraries. These have been pre-configured in a project which is provided with Mutata. After you have successfully run all the scripts, your configured Android project will be in `./build/AndroidProject`
19 |
20 | ```console
21 | ./scripts/12-CreateAndroidProject.sh
22 | ```
23 |
24 | ## Copy Android Mutata Libs
25 | Copy precompiled Android .aar libraries to your Android Project.
26 | ```console
27 | ./scripts/14-CopyAndroidMutataLibs.sh
28 | ```
29 |
30 | ## Convert your iOS Project
31 | __Note:__ Even though we do not change your iOS code, we strongly recommend backup/pushing your code or using a copy/clone of your iOS project.
32 | Before running the next script, please set the **MUTATA_IOS_SOURCES_PATH** environment variable to the root path of your iOS project .swift files.
33 |
34 | This script will copy your iOS Sources from **MUTATA_IOS_SOURCES_PATH** to `./build/iOSSources` and then will execute the `swiftSelectorsRewriter`.
35 | `swiftSelectorsRewriter` creates `IBActionsMutata.swift` file needed to run your IBActions and all your @objc selectors, as they are not supported in Swift.
36 | In addition, all __@objc, @IBOutlets, @IBActions__, etc. attributes will be converted as the Swift compiler does not officially support them so, Mutata uses `swiftSelectorsRewriter` to do that.
37 | Finally, `swiftSelectorsRewriter` will delete your copied __AppIcon.appiconset__ as you need to create a separate Android logo.
38 |
39 | ```console
40 | export MUTATA_IOS_SOURCES_PATH=/path/to/your/ios/sources
41 | ./scripts/15-ConvertIosProject.sh
42 | ```
43 |
44 | ## Create Package.swift
45 | Mutata uses the Swift Package Manager to compile your Swift code and link it with the Mutata libraries.
46 |
47 | Set the __MUTATA_SWIFT_MODULE_NAME__ environment variable with the name of your iOS app. This name will not be visible to the users.
48 | __Note:__ Please remove all whitespaces or replace them with underscores(_).
49 | ```console
50 | export MUTATA_SWIFT_MODULE_NAME="NameOfYourApp"
51 | ./scripts/16-CreateSwiftPackageAndMutataFiles.sh
52 | ```
53 | This script will create a new `Package.swift` file at `./out/AndroidProject/app/src/main/swift`, which will be used by Gradle to compile your Swift code and include it in the Android .apk.
54 | It will also copy three swift files, which are necessary to connect your Swift code with Mutata iOS and Android Libraries.
55 | Finally, it will create another `Package.swift` in your iOS Sources folder, which Mutata's Package.swift will depend on.
56 |
57 |
58 | ## Copy Android resource default files
59 | Copy temporary Android resources like Logo and App Name. You can replace them later.
60 | ```console
61 | ./scripts/17-CopyAndroidResFiles.sh
62 | ```
63 |
64 |
65 | ## Copy your iOS Images and xibs
66 | Copy your iOS resources like Images, xibs, and storyboards from `iOSSources` to `AndroidProject`.
67 | ```console
68 | ./scripts/18-CopyIosImagesAndXibs.sh
69 | ```
70 |
71 | ## Download Mutata License
72 | There are 2 types of Mutata Licenses.
73 | - __Free:__ Only to test your iOS app in Android.
74 | - __Paid:__ Release your app to the Play Store or device.
75 |
76 | ### Download a Free License
77 | You can download a free license to test your app using the `40-DownloadFreeLicense.sh` script with your email as an argument, or contact us at license[@]mutata.io
78 | ```console
79 | ./scripts/40-DownloadFreeLicense.sh your@email.com
80 | ```
81 |
82 | ### Purchase a Mutata License
83 | You can purchase your Mutata license from [Mutata.io](https://mutata.io/#pricing) or contact us at license[@]mutata.io
84 |
85 | ## Use Mutata License
86 | To use your license, you will need to update it in the `AndroidAppDelegate.swift`.
87 |
88 | ### Automatic License update
89 | After downloading a free license or purchasing one, you need to run
90 | ```console
91 | ./scripts/19-UpdateMutataLicense.sh
92 | ```
93 | to automatically update your `AndroidAppDelegate.swift` with the license code.
94 |
95 | ### Manual License update
96 | Open the `AndroidAppDelegate.swift` in `./build/AndroidProject/app/src/main/swift/Sources/SwiftAndroid/AndroidAppDelegate.swift` and insert your Mutata License at the beginning of the
97 | `public override func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]?) -> Bool` function
98 |
99 | ```Swift
100 | MutataLicense.setLicenseKey("YOUR_LICENSE_CODE") ///Paid
101 | MutataLicense.setLicenseKey("YOUR_LICENSE_CODE","1640908800") ///Free
102 | ```
103 |
104 | ## Android Device - Android Emulator
105 | Mutata will compile your apps for both Android Device and Android Emulator architectures.
106 |
107 | ### Connect Android Device
108 | Connect your Android Device to your Mac and [enable Developer Mode and USB Debugging](https://developer.android.com/studio/run/device).
109 |
110 | ### Launch Android Emulator
111 | You can launch an Android Emulator from [Android Studio -> AVD Manager](https://developer.android.com/studio/run/emulator) or from [Command Line](https://developer.android.com/studio/run/emulator-commandline).
112 |
113 | ## Compile, Install and Run
114 | Mutata uses `gradle` and `adb` to build and run your Android projects.
115 |
116 | You can run the following script and wait for the app to launch on your device or emulator.
117 | ```console
118 | ./20-InstallAndRun.sh
119 | ```
120 |
121 | ### Manual compile
122 | You can also manually build your apk with
123 | ```console
124 | cd ./out/AndroidProject
125 | gradle installDebug
126 | ```
127 | and then launch it either from the home screen of your device, or Manually run it with
128 | ```console
129 | adb shell am start -n YOUR_APPLICATION_ID/io.kodika.kodikaplayerandroid.MainActivity
130 | ```
131 |
--------------------------------------------------------------------------------
/scripts/01-PrepareMac.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | echo "Checking HomeBrew"
5 | which -s brew
6 | if [[ $? != 0 ]] ; then
7 | echo "Installing HomeBrew"
8 | echo "Installing Brew from https://brew.sh"
9 |
10 | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
11 | else
12 | echo "Updating HomeBrew"
13 | brew update
14 | fi
15 |
16 | echo "Installing Javac"
17 | brew install openjdk@8
18 |
19 | echo "Installing Tools: coreutils cmake wget gradle"
20 | brew install coreutils cmake wget gradle
21 |
--------------------------------------------------------------------------------
/scripts/02-DownloadLatestLibs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | if [ -z "$MUTATA_ROOT_PATH" ]
5 | then
6 | echo -e "Please provide MUTATA_ROOT_PATH\nExample:\nexport MUTATA_ROOT_PATH=$PWD"
7 | exit -1
8 | fi
9 | source $MUTATA_ROOT_PATH/SetupEnv.sh
10 |
11 | rm -rf $MUTATA_LIBS_PATH
12 | mkdir -p $MUTATA_LIBS_PATH
13 |
14 | pushd $MUTATA_LIBS_PATH > /dev/null
15 | curl -s https://api.github.com/repos/kodika/MutataLibraries/releases/latest \
16 | | grep "browser_download_url.*zip" \
17 | | cut -d : -f 2,3 \
18 | | tr -d \" \
19 | | wget --show-progress -qi -
20 |
21 | unzip swiftSelectorsRewriter.zip
22 | unzip android-mutatalib-release.zip
23 | unzip swift-android-5.4.zip
24 | unzip swift-android-5.4-r1.zip
25 | unzip MutataRunnerApp.zip
26 |
27 | rm swift-android-5.4.zip
28 | rm swift-android-5.4-r1.zip
29 | rm swiftSelectorsRewriter.zip
30 | rm android-mutatalib-release.zip
31 | rm MutataRunnerApp.zip
32 |
33 | xattr -r -d com.apple.quarantine ./swift-android-5.4-r1/ 2>/dev/null
34 |
35 | popd > /dev/null
36 |
37 | echo "Mutata libraries downloaded successfully!"
38 |
--------------------------------------------------------------------------------
/scripts/03-DownloadNdk.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | if [ -z "$MUTATA_ROOT_PATH" ]
5 | then
6 | echo -e "Please provide MUTATA_ROOT_PATH\nExample:\nexport MUTATA_ROOT_PATH=$PWD"
7 | exit -1
8 | fi
9 | source $MUTATA_ROOT_PATH/SetupEnv.sh
10 |
11 |
12 | echo "Installing Android NDK r21e from Google..."
13 | pushd $MUTATA_ROOT_PATH > /dev/null
14 | rm -rf android-ndk-r21e
15 | wget https://dl.google.com/android/repository/android-ndk-r21e-darwin-x86_64.zip
16 | unzip android-ndk-r21e-darwin-x86_64.zip
17 | rm android-ndk-r21e-darwin-x86_64.zip
18 | popd > /dev/null
19 |
20 | echo "Android NDK r21e installed successfully!"
21 |
--------------------------------------------------------------------------------
/scripts/100-UpdateAndRun.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | if [ -z "$MUTATA_ROOT_PATH" ]
5 | then
6 | echo -e "Please provide MUTATA_ROOT_PATH\nExample:\nexport MUTATA_ROOT_PATH=$PWD"
7 | exit -1
8 | fi
9 | source $MUTATA_ROOT_PATH/SetupEnv.sh
10 |
11 | if [ -z "$MUTATA_IOS_SOURCES_PATH" ]
12 | then
13 | echo -e "Please provide MUTATA_IOS_SOURCES_PATH\nexport MUTATA_IOS_SOURCES_PATH="
14 | exit -1
15 | fi
16 |
17 | swift_module_name=$MUTATA_SWIFT_MODULE_NAME
18 |
19 | if [ -z "$swift_module_name" ]
20 | then
21 | echo -e "Please provide MUTATA_SWIFT_MODULE_NAME\nExample:\nexport MUTATA_SWIFT_MODULE_NAME=\"MutataShowcase\""
22 | exit -1
23 | fi
24 |
25 | pushd $MUTATA_SCRIPTS_PATH > /dev/null
26 | ./15-ConvertIosProject.sh
27 | ./16-CreateSwiftPackageAndMutataFiles.sh
28 | ./18-CopyIosImagesAndXibs.sh
29 | ./19-UpdateMutataLicense.sh
30 | ./20-InstallAndRun.sh
31 | popd > /dev/null
32 |
--------------------------------------------------------------------------------
/scripts/12-CreateAndroidProject.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | if [ -z "$MUTATA_ROOT_PATH" ]
5 | then
6 | echo -e "Please provide MUTATA_ROOT_PATH\nExample:\nexport MUTATA_ROOT_PATH=$PWD"
7 | exit -1
8 | fi
9 | source $MUTATA_ROOT_PATH/SetupEnv.sh
10 |
11 |
12 | out_dir=$MUTATA_BUILD_PATH/AndroidProject
13 |
14 | rm -rf $out_dir
15 | mkdir -p $out_dir
16 |
17 | cp -r $MUTATA_LIBS_PATH/MutataRunnerApp/ $out_dir
18 |
19 | echo "Android project created successfully!"
20 |
--------------------------------------------------------------------------------
/scripts/14-CopyAndroidMutataLibs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | if [ -z "$MUTATA_ROOT_PATH" ]
5 | then
6 | echo -e "Please provide MUTATA_ROOT_PATH\nExample:\nexport MUTATA_ROOT_PATH=$PWD"
7 | exit -1
8 | fi
9 | source $MUTATA_ROOT_PATH/SetupEnv.sh
10 |
11 |
12 | android_libs_dir=$MUTATA_BUILD_PATH/AndroidProject/app/libs/
13 |
14 | mkdir -p $android_libs_dir
15 | cp $MUTATA_LIBS_PATH/android-mutatalib-release/mutatalib-release.aar $android_libs_dir
16 |
17 | echo "Android Mutata libraries copied successfully!"
18 |
--------------------------------------------------------------------------------
/scripts/15-ConvertIosProject.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | if [ -z "$MUTATA_ROOT_PATH" ]
5 | then
6 | echo -e "Please provide MUTATA_ROOT_PATH\nExample:\nexport MUTATA_ROOT_PATH=$PWD"
7 | exit -1
8 | fi
9 | source $MUTATA_ROOT_PATH/SetupEnv.sh
10 |
11 | if [ -z "$MUTATA_IOS_SOURCES_PATH" ]
12 | then
13 | echo -e "Please provide MUTATA_IOS_SOURCES_PATH\nexport MUTATA_IOS_SOURCES_PATH="
14 | exit -1
15 | fi
16 |
17 |
18 | original_sources_path=$MUTATA_IOS_SOURCES_PATH
19 | out_sources_path=$MUTATA_BUILD_PATH/iOSSources
20 |
21 | rm -rf $out_sources_path
22 | mkdir -p $out_sources_path
23 |
24 | cp -r $original_sources_path $out_sources_path/Sources
25 |
26 | pushd $out_sources_path > /dev/null
27 | $MUTATA_LIBS_PATH/swiftSelectorsRewriter --cleanObjc --IBActionSelectorsOutput IBActionsMutata.swift --performSelectorOutput NSObject+Perform.swift ./Sources
28 | mv IBActionsMutata.swift ./Sources-Android
29 | mv NSObject+Perform.swift ./Sources-Android
30 | rm -rf ./Sources-Android/Assets.xcassets/AppIcon.appiconset
31 | rm -rf ./Sources-Android/Pods
32 | popd > /dev/null
33 |
34 | echo "Your iOS Project copied successfully!"
35 |
--------------------------------------------------------------------------------
/scripts/16-CreateSwiftPackageAndMutataFiles.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | if [ -z "$MUTATA_ROOT_PATH" ]
5 | then
6 | echo -e "Please provide MUTATA_ROOT_PATH\nExample:\nexport MUTATA_ROOT_PATH=$PWD"
7 | exit -1
8 | fi
9 | source $MUTATA_ROOT_PATH/SetupEnv.sh
10 |
11 | swift_module_name=$MUTATA_SWIFT_MODULE_NAME
12 |
13 | if [ -z "$swift_module_name" ]
14 | then
15 | echo -e "Please provide MUTATA_SWIFT_MODULE_NAME\nExample:\nexport MUTATA_SWIFT_MODULE_NAME=\"MutataShowcase\""
16 | exit -1
17 | fi
18 |
19 |
20 | out_dir=$MUTATA_BUILD_PATH/AndroidProject/app/src/main/swift
21 | template_files_dir=$MUTATA_TEMPLATES_PATH
22 |
23 |
24 | echo "Generating Swift Package files for $swift_module_name"
25 |
26 | echo "Creating Swift files at $out_dir"
27 |
28 | rm -rf $out_dir
29 | mkdir -p $out_dir
30 |
31 | cp -r $template_files_dir/SwiftPackage/ $out_dir
32 |
33 | sed -i '' -e 's,SWIFT_MODULE_NAME,'"$swift_module_name"',g' "$out_dir/Package.swift"
34 |
35 | sed -i '' -e 's,SWIFT_MODULE_NAME,'"$swift_module_name"',g' "$out_dir/Sources/SwiftAndroid/AndroidAppDelegate.swift"
36 | sed -i '' -e 's,SWIFT_MODULE_NAME,'"$swift_module_name"',g' "$out_dir/Sources/SwiftAndroid/Nib2UIKit+Nib2UIKitPackageNameProtocol.swift"
37 |
38 |
39 | out_sources_path=$MUTATA_BUILD_PATH/iOSSources
40 | cp $template_files_dir/SourcesPackage.swift $out_sources_path/Package.swift
41 |
42 | sed -i '' -e 's,SWIFT_MODULE_NAME,'"$swift_module_name"',g' "$out_sources_path/Package.swift"
43 |
44 | echo "Swift Mutata Package created successfully!"
45 |
--------------------------------------------------------------------------------
/scripts/17-CopyAndroidResFiles.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | if [ -z "$MUTATA_ROOT_PATH" ]
5 | then
6 | echo -e "Please provide MUTATA_ROOT_PATH\nExample:\nexport MUTATA_ROOT_PATH=$PWD"
7 | exit -1
8 | fi
9 | source $MUTATA_ROOT_PATH/SetupEnv.sh
10 |
11 | mkdir -p $MUTATA_BUILD_PATH/iOSFiles/res
12 | cp -r $MUTATA_TEMPLATES_PATH/AndroidRes/res/ $MUTATA_BUILD_PATH/iOSFiles/res
13 |
14 | echo "Android resources copied successfully!"
15 |
--------------------------------------------------------------------------------
/scripts/18-CopyIosImagesAndXibs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | if [ -z "$MUTATA_ROOT_PATH" ]
5 | then
6 | echo -e "Please provide MUTATA_ROOT_PATH\nExample:\nexport MUTATA_ROOT_PATH=$PWD"
7 | exit -1
8 | fi
9 | source $MUTATA_ROOT_PATH/SetupEnv.sh
10 |
11 |
12 | ios_files_dir=$MUTATA_BUILD_PATH/iOSFiles
13 |
14 | rm -rf $ios_files_dir/copiedFromPackage/
15 |
16 | destinationXibsDir=$ios_files_dir/copiedFromPackage/assets #Nib2UIKit needs them in first level in assets
17 | destinationFontsDir=$ios_files_dir/copiedFromPackage/assets/fonts
18 | destinationImagesDir=$ios_files_dir/copiedFromPackage/images/drawable
19 |
20 | mkdir -p $destinationXibsDir
21 | mkdir -p $destinationFontsDir
22 | mkdir -p $destinationImagesDir
23 |
24 | find $MUTATA_BUILD_SWIFT_SOURCES_ANDROID_PATH -name '*.xib' -exec cp -pr '{}' $destinationXibsDir ';'
25 | find $MUTATA_BUILD_SWIFT_SOURCES_ANDROID_PATH -name '*.storyboard' -exec cp -pr '{}' $destinationXibsDir ';'
26 | find $MUTATA_BUILD_SWIFT_SOURCES_ANDROID_PATH -name '*.png' -exec cp -pr '{}' $destinationImagesDir ';'
27 | find $MUTATA_BUILD_SWIFT_SOURCES_ANDROID_PATH -name '*.ttf' -exec cp -pr '{}' $destinationFontsDir ';'
28 | find $MUTATA_BUILD_SWIFT_SOURCES_ANDROID_PATH -name '*.otf' -exec cp -pr '{}' $destinationFontsDir ';'
29 |
30 | find -s $ios_files_dir/copiedFromPackage/ -type f -exec md5 -q {} \; | md5 > $ios_files_dir/copiedFromPackage/assets/assets.version
31 |
32 | pushd $destinationImagesDir > /dev/null
33 |
34 | for file in *.png; do
35 | if [ -f "${file}" ]; then
36 | #Replace whitespaces
37 | filename=$(echo $file | tr ' ' '_');
38 |
39 | filename="${file%.*}";
40 | extension="${file##*.}";
41 |
42 | #Lowercase all file names
43 | filename=$(echo $filename | tr '[A-Z]' '[a-z]');
44 | #Replace all invalid characters with underscore
45 | filename=$(echo $filename | sed -e 's/[^a-z0-9_]/_/g');
46 |
47 | if [[ $filename =~ ^[0-9] ]]; then
48 | filename="_${filename}"
49 | fi
50 |
51 | mv "$file" "${filename}.${extension}";
52 | fi
53 | done
54 |
55 | for file in *.jpg; do
56 | if [ -f "${file}" ]; then
57 | #Replace whitespaces
58 | filename=$(echo $file | tr ' ' '_');
59 |
60 | filename="${file%.*}";
61 | extension="${file##*.}";
62 |
63 | #Lowercase all file names
64 | filename=$(echo $filename | tr '[A-Z]' '[a-z]');
65 | #Replace all invalid characters with underscore
66 | filename=$(echo $filename | sed -e 's/[^a-z0-9_]/_/g');
67 |
68 | if [[ $filename =~ ^[0-9] ]]; then
69 | filename="_${filename}"
70 | fi
71 |
72 | mv "$file" "${filename}.${extension}";
73 | fi
74 | done
75 |
76 | popd > /dev/null
77 |
78 | echo "iOS Assets copied successfully!"
79 |
--------------------------------------------------------------------------------
/scripts/19-UpdateMutataLicense.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | if [ -z "$MUTATA_ROOT_PATH" ]
5 | then
6 | echo -e "Please provide MUTATA_ROOT_PATH\nExample:\nexport MUTATA_ROOT_PATH=$PWD"
7 | exit -1
8 | fi
9 | source $MUTATA_ROOT_PATH/SetupEnv.sh
10 |
11 | license_path=$MUTATA_ROOT_PATH/license.json
12 |
13 | if [ ! -f $license_path ]; then
14 | echo "license.json does not exist at $license_path"
15 | exit -1
16 | fi
17 |
18 | license=$(cat $license_path | sed 's/.*"license":"\{0,1\}\([^,"]*\)"\{0,1\}.*/\1/')
19 |
20 | expires=$(cat $license_path | sed 's/.*"expires":"\{0,1\}\([^,"]*\)"\{0,1\}.*/\1/')
21 |
22 |
23 | swift_android_dir=$MUTATA_BUILD_PATH/AndroidProject/app/src/main/swift
24 | if [ $expires == "NO" ]; then
25 | sed -i '' -e 's,fatalError("MUTATA_LICENSE"),MutataLicense.setLicenseKey("'"$license"'"),g' "$swift_android_dir/Sources/SwiftAndroid/AndroidAppDelegate.swift"
26 | else
27 | sed -i '' -e 's,fatalError("MUTATA_LICENSE"),MutataLicense.setLicenseKey("'"$license"'"\,"'"$expires"'"),g' "$swift_android_dir/Sources/SwiftAndroid/AndroidAppDelegate.swift"
28 | fi
29 |
30 |
31 | android_app_gradle_file=$MUTATA_BUILD_PATH/AndroidProject/app/build.gradle
32 |
33 | applicationId=$(cat $license_path | sed 's/.*"applicationId":"\{0,1\}\([^,"]*\)"\{0,1\}.*/\1/')
34 | appVersionCode=$(cat $license_path | sed 's/.*"appVersionCode":"\{0,1\}\([^,"]*\)"\{0,1\}.*/\1/')
35 | appVersionName=$(cat $license_path | sed 's/.*"appVersionName":"\{0,1\}\([^,"]*\)"\{0,1\}.*/\1/')
36 |
37 | sed -i '' -e 's,MUTATA_GRADLE_APPLICATION_ID,'"$applicationId"',g' "$android_app_gradle_file"
38 | sed -i '' -e 's,MUTATA_GRADLE_VERSION_CODE,'"$appVersionCode"',g' "$android_app_gradle_file"
39 | sed -i '' -e 's,MUTATA_GRADLE_VERSION_NAME,'"$appVersionName"',g' "$android_app_gradle_file"
40 |
41 | echo "Mutata License updated successfully!"
42 |
--------------------------------------------------------------------------------
/scripts/20-InstallAndRun.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | if [ -z "$MUTATA_ROOT_PATH" ]
5 | then
6 | echo -e "Please provide MUTATA_ROOT_PATH\nExample:\nexport MUTATA_ROOT_PATH=$PWD"
7 | exit -1
8 | fi
9 | source $MUTATA_ROOT_PATH/SetupEnv.sh
10 |
11 | license_path=$MUTATA_ROOT_PATH/license.json
12 |
13 | if [ ! -f $license_path ]; then
14 | echo "license.json does not exist at $license_path"
15 | exit -1
16 | fi
17 |
18 | applicationId=$(cat $license_path | sed 's/.*"applicationId":"\{0,1\}\([^,"]*\)"\{0,1\}.*/\1/')
19 |
20 | pushd $MUTATA_BUILD_PATH/AndroidProject > /dev/null
21 |
22 | gradle installDebug
23 | adb shell am start -n $applicationId/io.kodika.kodikaplayerandroid.MainActivity
24 | popd > /dev/null
25 |
--------------------------------------------------------------------------------
/scripts/30-CleanBuildFolder.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | if [ -z "$MUTATA_ROOT_PATH" ]
5 | then
6 | echo -e "Please provide MUTATA_ROOT_PATH\nExample:\nexport MUTATA_ROOT_PATH=$PWD"
7 | exit -1
8 | fi
9 | source $MUTATA_ROOT_PATH/SetupEnv.sh
10 |
11 | rm -rf $MUTATA_BUILD_PATH
12 |
--------------------------------------------------------------------------------
/scripts/31-CleanMutataLibs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | if [ -z "$MUTATA_ROOT_PATH" ]
5 | then
6 | echo -e "Please provide MUTATA_ROOT_PATH\nExample:\nexport MUTATA_ROOT_PATH=$PWD"
7 | exit -1
8 | fi
9 | source $MUTATA_ROOT_PATH/SetupEnv.sh
10 |
11 | rm -rf $MUTATA_LIBS_PATH
12 |
--------------------------------------------------------------------------------
/scripts/40-DownloadFreeLicense.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | if [ -z "$MUTATA_ROOT_PATH" ]
5 | then
6 | echo -e "Please provide MUTATA_ROOT_PATH\nExample:\nexport MUTATA_ROOT_PATH=$PWD"
7 | exit -1
8 | fi
9 | source $MUTATA_ROOT_PATH/SetupEnv.sh
10 |
11 | license_path=$MUTATA_ROOT_PATH/license.json
12 |
13 | if [ -f $license_path ]; then
14 | echo "You have already downloaded a license. Please delete or backup your previous license at $license_path and retry."
15 | exit -1
16 | fi
17 |
18 | email=$1
19 |
20 | if [ -z "$email" ]
21 | then
22 | echo -e "Please provide your email\nexample: ./40-DownloadFreeLicense.sh your@email.com"
23 | exit -1
24 | fi
25 |
26 | curl --location --request POST 'https://api.mutata.io/v1/generateFreeLicense' \
27 | -o $MUTATA_ROOT_PATH/license.json \
28 | --silent \
29 | --header 'Content-Type: application/json' \
30 | --data-raw '{
31 | "email":"'$email'"
32 | }'
33 |
34 | license=$(cat $MUTATA_ROOT_PATH/license.json)
35 | error=$(echo $license | sed 's/.*"error":"\{0,1\}\([^,"]*\)"\{0,1\}.*/\1/')
36 |
37 | if [ "$error" == "$license" ]
38 | then
39 | echo "Mutata License downloaded successfully!"
40 | else
41 | echo $error
42 | fi
43 |
--------------------------------------------------------------------------------
/template_files/AndroidRes/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/template_files/AndroidRes/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/template_files/AndroidRes/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodika/MutataApp/2545c41154a39f48ef31353495636b19ab048601/template_files/AndroidRes/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/template_files/AndroidRes/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodika/MutataApp/2545c41154a39f48ef31353495636b19ab048601/template_files/AndroidRes/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/template_files/AndroidRes/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodika/MutataApp/2545c41154a39f48ef31353495636b19ab048601/template_files/AndroidRes/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/template_files/AndroidRes/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodika/MutataApp/2545c41154a39f48ef31353495636b19ab048601/template_files/AndroidRes/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/template_files/AndroidRes/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodika/MutataApp/2545c41154a39f48ef31353495636b19ab048601/template_files/AndroidRes/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/template_files/AndroidRes/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodika/MutataApp/2545c41154a39f48ef31353495636b19ab048601/template_files/AndroidRes/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/template_files/AndroidRes/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodika/MutataApp/2545c41154a39f48ef31353495636b19ab048601/template_files/AndroidRes/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/template_files/AndroidRes/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodika/MutataApp/2545c41154a39f48ef31353495636b19ab048601/template_files/AndroidRes/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/template_files/AndroidRes/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodika/MutataApp/2545c41154a39f48ef31353495636b19ab048601/template_files/AndroidRes/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/template_files/AndroidRes/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodika/MutataApp/2545c41154a39f48ef31353495636b19ab048601/template_files/AndroidRes/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/template_files/AndroidRes/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodika/MutataApp/2545c41154a39f48ef31353495636b19ab048601/template_files/AndroidRes/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/template_files/AndroidRes/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodika/MutataApp/2545c41154a39f48ef31353495636b19ab048601/template_files/AndroidRes/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/template_files/AndroidRes/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodika/MutataApp/2545c41154a39f48ef31353495636b19ab048601/template_files/AndroidRes/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/template_files/AndroidRes/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodika/MutataApp/2545c41154a39f48ef31353495636b19ab048601/template_files/AndroidRes/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/template_files/AndroidRes/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodika/MutataApp/2545c41154a39f48ef31353495636b19ab048601/template_files/AndroidRes/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/template_files/AndroidRes/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFFFFF
4 |
--------------------------------------------------------------------------------
/template_files/AndroidRes/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Mutata Showcase
3 |
--------------------------------------------------------------------------------
/template_files/SourcesPackage.swift:
--------------------------------------------------------------------------------
1 | // swift-tools-version:5.0
2 |
3 | import PackageDescription
4 |
5 | let package = Package(
6 | name: "SWIFT_MODULE_NAME",
7 | products: [
8 | .library(
9 | name: "SWIFT_MODULE_NAME",
10 | targets: ["SWIFT_MODULE_NAME"]),
11 | ],
12 | dependencies: [
13 | ],
14 | targets: [
15 | .target(
16 | name: "SWIFT_MODULE_NAME",
17 | dependencies: [
18 | ],
19 | path: "",
20 | sources: [
21 | "./Sources-Android/"
22 | ],
23 | swiftSettings:[
24 | .define("ANDROID"),
25 | ]
26 | ),
27 | ]
28 | )
29 |
--------------------------------------------------------------------------------
/template_files/SwiftPackage/Package.swift:
--------------------------------------------------------------------------------
1 | // swift-tools-version:5.0
2 | import PackageDescription
3 |
4 | let package = Package(
5 | name: "SwiftAndroid",
6 | products: [
7 | .library(name: "SwiftAndroid", type: .dynamic, targets: ["SwiftAndroid"])
8 | ],
9 | dependencies: [
10 | .package(path: "../../../../../iOSSources")
11 | ],
12 | targets: [
13 | .target(
14 | name: "SwiftAndroid",
15 | dependencies: [
16 | "SWIFT_MODULE_NAME"
17 | ]
18 | )
19 | ]
20 | )
21 |
--------------------------------------------------------------------------------
/template_files/SwiftPackage/Sources/SwiftAndroid/AndroidAppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AndroidAppDelegate.swift
3 | //
4 | //
5 | //
6 |
7 | import Foundation
8 | import UIKit
9 | import java_swift
10 | import JavaCoder
11 | import StoreKit
12 |
13 | import SWIFT_MODULE_NAME
14 |
15 | internal class AndroidAppDelegate: AppDelegate {
16 |
17 | /// - Warning: `application:willFinishLaunchingWithOptions:` MUST exist in `AppDelegate`
18 | public override func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]?) -> Bool {
19 |
20 | fatalError("MUTATA_LICENSE")
21 |
22 | JavaCoderConfig.RegisterBasicJavaTypes()
23 | JavaCoderConfig.RegisterType(type: StoreKit.SkuDetails.self, javaClassname: "com.android.billingclient.api.SkuDetails", encodableClosure: { (skuDetail, _) -> jobject in
24 | fatalError("")
25 | }) { (javaObject, _) -> Decodable in
26 | return try! StoreKit.SkuDetails.from(javaObject: javaObject)
27 | }
28 |
29 | JavaCoderConfig.RegisterType(type: StoreKit.AndroidPurchase.self, javaClassname: "com.android.billingclient.api.Purchase", encodableClosure: { (skuDetail, _) -> jobject in
30 | fatalError("")
31 | }) { (javaObject, _) -> Decodable in
32 | return try! StoreKit.AndroidPurchase.from(javaObject: javaObject)
33 | }
34 |
35 | return super.application(application, willFinishLaunchingWithOptions: launchOptions)
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/template_files/SwiftPackage/Sources/SwiftAndroid/JavaBind.swift:
--------------------------------------------------------------------------------
1 | //
2 | // JavaBind.swift
3 | //
4 | //
5 | //
6 |
7 | import Foundation
8 |
9 | import Java
10 | import Android
11 | import java_swift
12 | import UIKit
13 |
14 | @_silgen_name("Java_io_kodika_kodikaplayerandroid_Application_bind")
15 | public func bindApplication( __env: UnsafeMutablePointer, __this: jobject?) -> jlong? {
16 |
17 | let swiftObject = AndroidUIKitApplication(javaObject: __this)
18 |
19 | UIApplication.shared.delegate = AndroidAppDelegate()
20 |
21 | return jlong(Int(bitPattern: Unmanaged.passRetained(swiftObject).toOpaque()))
22 | }
23 |
24 |
25 | @_silgen_name("Java_io_kodika_kodikaplayerandroid_MainActivity_bind")
26 | public func bindActivity( __env: UnsafeMutablePointer, __this: jobject?) -> jlong? {
27 |
28 | let swiftObject = AndroidUIKitActivity(javaObject: __this)
29 | return jlong(Int(bitPattern: Unmanaged.passRetained(swiftObject).toOpaque()))
30 | }
31 |
--------------------------------------------------------------------------------
/template_files/SwiftPackage/Sources/SwiftAndroid/Nib2UIKit+Nib2UIKitPackageNameProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Nib2UIKit+Nib2UIKitPackageNameProtocol.swift
3 | //
4 | //
5 | //
6 |
7 | import Foundation
8 | import Nib2UIKit
9 |
10 | extension Nib2UIKit: Nib2UIKitPackageNameProtocol {
11 | public static var packageNameWithXibsFromModule = "SWIFT_MODULE_NAME."
12 | }
13 |
--------------------------------------------------------------------------------