For Mutata scripts to work, clone this repo and then, set the MUTATA_ROOT_PATH environment variable.
Note: You will need a new clone of this repo for each of your iOS apps.
Note: You will need to set the environment variables every time you start the terminal, or change to a different iOS project.
# Clone the repo
git clone https://github.com/kodika/MutataApp
# Change Directory to the MutataApp.
cd MutataApp
# Set environment variable to current directory
export MUTATA_ROOT_PATH=$PWDTo 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
./scripts/12-CreateAndroidProject.shCopy precompiled Android .aar libraries to your Android Project.
./scripts/14-CopyAndroidMutataLibs.shNote: 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.
Before running the next script, please set the MUTATA_IOS_SOURCES_PATH environment variable to the root path of your iOS project .swift files.
This script will copy your iOS Sources from MUTATA_IOS_SOURCES_PATH to ./build/iOSSources and then will execute the swiftSelectorsRewriter.
swiftSelectorsRewriter creates IBActionsMutata.swift file needed to run your IBActions and all your @objc selectors, as they are not supported in Swift.
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.
Finally, swiftSelectorsRewriter will delete your copied AppIcon.appiconset as you need to create a separate Android logo.
export MUTATA_IOS_SOURCES_PATH=/path/to/your/ios/sources
./scripts/15-ConvertIosProject.shMutata uses the Swift Package Manager to compile your Swift code and link it with the Mutata libraries.
Set the MUTATA_SWIFT_MODULE_NAME environment variable with the name of your iOS app. This name will not be visible to the users.
Note: Please remove all whitespaces or replace them with underscores(_).
export MUTATA_SWIFT_MODULE_NAME="NameOfYourApp"
./scripts/16-CreateSwiftPackageAndMutataFiles.shThis 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.
It will also copy three swift files, which are necessary to connect your Swift code with Mutata iOS and Android Libraries.
Finally, it will create another Package.swift in your iOS Sources folder, which Mutata's Package.swift will depend on.
Copy temporary Android resources like Logo and App Name. You can replace them later.
./scripts/17-CopyAndroidResFiles.shCopy your iOS resources like Images, xibs, and storyboards from iOSSources to AndroidProject.
./scripts/18-CopyIosImagesAndXibs.shThere are 2 types of Mutata Licenses.
- Free: Only to test your iOS app in Android.
- Paid: Release your app to the Play Store or device.
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
./scripts/40-DownloadFreeLicense.sh your@email.comYou can purchase your Mutata license from Mutata.io or contact us at license[@]mutata.io
To use your license, you will need to update it in the AndroidAppDelegate.swift.
After downloading a free license or purchasing one, you need to run
./scripts/19-UpdateMutataLicense.shto automatically update your AndroidAppDelegate.swift with the license code.
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
public override func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]?) -> Bool function
MutataLicense.setLicenseKey("YOUR_LICENSE_CODE") ///Paid
MutataLicense.setLicenseKey("YOUR_LICENSE_CODE","1640908800") ///FreeMutata will compile your apps for both Android Device and Android Emulator architectures.
Connect your Android Device to your Mac and enable Developer Mode and USB Debugging.
You can launch an Android Emulator from Android Studio -> AVD Manager or from Command Line.
Mutata uses gradle and adb to build and run your Android projects.
You can run the following script and wait for the app to launch on your device or emulator.
./20-InstallAndRun.shYou can also manually build your apk with
cd ./out/AndroidProject
gradle installDebugand then launch it either from the home screen of your device, or Manually run it with
adb shell am start -n YOUR_APPLICATION_ID/io.kodika.kodikaplayerandroid.MainActivity