| 1 | # pjsua2maui - pjsip on .net maui |
| 2 | |
| 3 | ## STEPS FOR BUILDING: |
| 4 | |
| 5 | ### Android |
| 6 | |
| 7 | - SETUP: |
| 8 | - Visual Studio Code & .NET MAUI - [Install steps](https://learn.microsoft.com/en-us/dotnet/maui/get-started/installation?view=net-maui-11.0&tabs=visual-studio-code) |
| 9 | - Java 17 |
| 10 | - Android NDK r21d or later |
| 11 | - pjsip v2.14.1 or later |
| 12 | |
| 13 | - Run the following commands: |
| 14 | |
| 15 | ```bash |
| 16 | export ANDROID_SDK_ROOT=/somewhere/there/is/installed/the/sdk/ |
| 17 | sdkmanager --install "ndk;28.0.12674087" --channel=3 --sdk_root=$ANDROID_SDK_ROOT |
| 18 | sdkmanager --install "cmake;3.31.0" --sdk_root=$ANDROID_SDK_ROOT |
| 19 | sdkmanager --install "build-tools;35.0.0" "platform-tools" "platforms;android-35" --sdk_root=$ANDROID_SDK_ROOT |
| 20 | echo yes | sdkmanager --licenses --sdk_root=$ANDROID_SDK_ROOT |
| 21 | ``` |
| 22 | note: |
| 23 | If you are sharing the Android SDK location with Android Studio, the recommended way to install/update the SDK and accept licenses is by using Android Studio. |
| 24 | |
| 25 | - Create the following variable: |
| 26 | |
| 27 | ```bash |
| 28 | |
| 29 | export ANDROID_NDK_ROOT=/path/to/ndk/root/installation |
| 30 | |
| 31 | ``` |
| 32 | |
| 33 | - Then build pjsip |
| 34 | |
| 35 | For device: |
| 36 | ```bash |
| 37 | ./configure-android |
| 38 | ``` |
| 39 | |
| 40 | For simulator: |
| 41 | ```bash |
| 42 | |
| 43 | TARGET_ABI=x86_64 ./configure-android |
| 44 | make dep && make clean && make |
| 45 | |
| 46 | ``` |
| 47 | |
| 48 | |
| 49 | after run make dep and make, run the make on ``` pjsip-apps/src/swig/csharp ``` folder |
| 50 | |
| 51 | ```bash |
| 52 | |
| 53 | make |
| 54 | |
| 55 | ``` |
| 56 | |
| 57 | then start the android emulator, go to ``` pjsip-apps/src/swig/csharp/pjsua2maui/pjsua2maui ``` and run: |
| 58 | |
| 59 | ```bash |
| 60 | |
| 61 | dotnet workload restore |
| 62 | dotnet restore |
| 63 | dotnet build -t:Run -c Debug -f net9.0-android |
| 64 | |
| 65 | ``` |
| 66 | or, for run in device: |
| 67 | |
| 68 | Open Android Studio and connect an Android device, such as by using "Pair Devices Using Wifi" |
| 69 | (Optional) Start Logcat in VS Code, for obtaining Android log. |
| 70 | Install Logcat: View-Extensions. Install Logcat extension. |
| 71 | Start Logcat: View-Command Pallette. |
| 72 | |
| 73 | ### iOS |
| 74 | |
| 75 | - SETUP: |
| 76 | - Visual Studio Code & .NET MAUI - [Install steps](https://learn.microsoft.com/en-us/dotnet/maui/get-started/installation?view=net-maui-11.0&tabs=visual-studio-code) |
| 77 | - Xcode 16.1 or later |
| 78 | - pjsip v2.14.1 or later |
| 79 | |
| 80 | - PREPARING: |
| 81 | |
| 82 | - Building pj stack: |
| 83 | |
| 84 | Create the following ``` config_site.h ``` : |
| 85 | |
| 86 | ```c |
| 87 | |
| 88 | #define PJ_CONFIG_IPHONE 1 |
| 89 | |
| 90 | #include <pj/config_site_sample.h> |
| 91 | |
| 92 | ``` |
| 93 | Create the following variable: |
| 94 | |
| 95 | ```bash |
| 96 | |
| 97 | export DEVPATH="`xcrun -sdk iphonesimulator --show-sdk-platform-path`/Developer" |
| 98 | |
| 99 | ``` |
| 100 | Run configure with the following flags to build the lib to run on simulator: |
| 101 | |
| 102 | ```bash |
| 103 | |
| 104 | MIN_IOS="-miphoneos-version-min=12.2" ARCH="-arch x86_64" CFLAGS="-O2 -m32 -mios-simulator-version-min=12.2 -fembed-bitcode" LDFLAGS="-O2 -m32 -mios-simulator-version-min=12.2 -fembed-bitcode" ./configure-iphone |
| 105 | |
| 106 | ``` |
| 107 | For run on device: |
| 108 | |
| 109 | ```bash |
| 110 | ./configure-iphone |
| 111 | ``` |
| 112 | |
| 113 | after run make dep and make, run the make on ``` pjsip-apps/src/swig/csharp ``` folder |
| 114 | |
| 115 | ```bash |
| 116 | |
| 117 | make |
| 118 | |
| 119 | ``` |
| 120 | |
| 121 | then go to ``` pjsip-apps/src/swig/csharp/pjsua2maui/pjsua2maui ``` and run: |
| 122 | |
| 123 | For simulator: |
| 124 | |
| 125 | ```bash |
| 126 | dotnet workload restore |
| 127 | dotnet restore |
| 128 | dotnet build -t:Run -c Debug -f net9.0-ios -p:_DeviceName=:v2:udid=UDID_OF_YOUR_EMULATOR |
| 129 | ``` |
| 130 | |
| 131 | For device: |
| 132 | |
| 133 | ```bash |
| 134 | dotnet workload restore |
| 135 | dotnet restore |
| 136 | dotnet build -t:Run -c Debug -f net9.0-ios -p:_DeviceName=:v2:udid=UDID_OF_YOUR_DEVICE |
| 137 | ``` |
| 138 | |
| 139 | For the codesign, here are the steps: |
| 140 | |
| 141 | ```bash |
| 142 | dotnet publish -c Debug -f net9.0-ios -p:RuntimeIdentifier=ios-arm64 |
| 143 | ``` |
| 144 | Open the resulting .ipa file in Xcode: ``` pjsip-apps/src/swig/csharp/pjsua2maui/pjsua2maui/bin/Debug/net9.0-ios/ios-arm64/publish/pjsua2maui.ipa ``` |
| 145 | |
| 146 | Drag it to your connected device under "Devices and Simulators." |
| 147 | Xcode will handle the signing and deployment. |