$npx -y skills add Redth/maui-skillz --skill ios-slim-bindingsCreate and update slim/native platform interop bindings for iOS in .NET MAUI and .NET for iOS projects. Guides through creating Swift/Objective-C wrappers, configuring Xcode projects, generating C# API definitions, and integrating native iOS libraries using the Native Library Int
| 1 | # When to use this skill |
| 2 | |
| 3 | Activate this skill when the user asks: |
| 4 | - How do I create iOS bindings for a native library? |
| 5 | - How do I wrap an iOS SDK for use in .NET MAUI? |
| 6 | - How do I create slim bindings for iOS? |
| 7 | - How do I use Native Library Interop for iOS? |
| 8 | - How do I bind a Swift library to .NET? |
| 9 | - How do I use Objective Sharpie for iOS bindings? |
| 10 | - How do I integrate an xcframework into .NET MAUI? |
| 11 | - How do I create a Swift wrapper for a native iOS library? |
| 12 | - How do I update iOS bindings when the native SDK changes? |
| 13 | - How do I fix iOS binding build errors? |
| 14 | - How do I expose native iOS APIs to C#? |
| 15 | - How do I handle CocoaPods dependencies in iOS bindings? |
| 16 | - How do I handle Swift Package Manager dependencies? |
| 17 | |
| 18 | # Overview |
| 19 | |
| 20 | This skill guides the creation of **Native Library Interop (Slim Bindings)** for iOS. This modern approach creates a thin native Swift/Objective-C wrapper exposing only the APIs you need from a native iOS library, making bindings easier to create and maintain. |
| 21 | |
| 22 | ## When to Use Slim Bindings vs Traditional Bindings |
| 23 | |
| 24 | | Scenario | Recommended Approach | |
| 25 | |----------|---------------------| |
| 26 | | Need only a subset of library functionality | **Slim Bindings** ✓ | |
| 27 | | Easier maintenance when SDK updates | **Slim Bindings** ✓ | |
| 28 | | Prefer working in Swift/Objective-C for wrapper | **Slim Bindings** ✓ | |
| 29 | | Better isolation from breaking changes | **Slim Bindings** ✓ | |
| 30 | | Need entire library API surface | Traditional Bindings | |
| 31 | | Creating bindings for third-party developers | Traditional Bindings | |
| 32 | | Already maintaining traditional bindings | Traditional Bindings | |
| 33 | |
| 34 | # Inputs |
| 35 | |
| 36 | | Parameter | Required | Example | Notes | |
| 37 | |-----------|----------|---------|-------| |
| 38 | | libraryName | yes | `FirebaseMessaging`, `Lottie` | Name of the native iOS library to bind | |
| 39 | | bindingProjectName | yes | `MyBinding.MaciOS` | Name for the C# binding project | |
| 40 | | dependencySource | no | `cocoapods`, `spm`, `xcframework` | How the native library is distributed | |
| 41 | | targetFrameworks | no | `net9.0-ios;net9.0-maccatalyst` | Target frameworks (default: latest .NET iOS + Mac Catalyst) | |
| 42 | | exposedApis | no | List of specific APIs | Which native APIs to expose (helps scope the wrapper) | |
| 43 | |
| 44 | # Project Structure |
| 45 | |
| 46 | The recommended project structure for Native Library Interop: |
| 47 | |
| 48 | ``` |
| 49 | MyBinding/ |
| 50 | ├── macios/ |
| 51 | │ ├── native/ |
| 52 | │ │ └── MyBinding/ # Xcode project |
| 53 | │ │ ├── MyBinding.xcodeproj/ |
| 54 | │ │ │ └── project.pbxproj |
| 55 | │ │ ├── MyBinding/ |
| 56 | │ │ │ └── DotnetMyBinding.swift # Swift wrapper implementation |
| 57 | │ │ └── Podfile # If using CocoaPods |
| 58 | │ │ └── Package.swift # If using Swift Package Manager |
| 59 | │ └── MyBinding.MaciOS.Binding/ |
| 60 | │ ├── MyBinding.MaciOS.Binding.csproj |
| 61 | │ └── ApiDefinition.cs |
| 62 | ├── sample/ |
| 63 | │ └── MauiSample/ # Sample MAUI app |
| 64 | │ ├── MauiSample.csproj |
| 65 | │ └── MainPage.xaml.cs |
| 66 | └── README.md |
| 67 | ``` |
| 68 | |
| 69 | # Step-by-step Process |
| 70 | |
| 71 | ## Step 1: Create Project Structure from Command Line |
| 72 | |
| 73 | This section shows how to create the entire binding project structure using only command-line tools—no GUI or template cloning required. |
| 74 | |
| 75 | ### Prerequisites |
| 76 | |
| 77 | Install XcodeGen (generates Xcode projects from YAML): |
| 78 | |
| 79 | ```bash |
| 80 | brew install xcodegen |
| 81 | ``` |
| 82 | |
| 83 | ### Create Directory Structure |
| 84 | |
| 85 | ```bash |
| 86 | # Set your binding name |
| 87 | BINDING_NAME="MyBinding" |
| 88 | |
| 89 | # Create the full directory structure |
| 90 | mkdir -p ${BINDING_NAME}/macios/native/${BINDING_NAME}/${BINDING_NAME} |
| 91 | mkdir -p ${BINDING_NAME}/macios/${BINDING_NAME}.MaciOS.Binding |
| 92 | mkdir -p ${BINDING_NAME}/sample/MauiSample |
| 93 | |
| 94 | cd ${BINDING_NAME} |
| 95 | ``` |
| 96 | |
| 97 | ## Step 2: Create the Xcode Project with XcodeGen |
| 98 | |
| 99 | ### Create the XcodeGen Project Spec |
| 100 | |
| 101 | Create `macios/native/${BINDING_NAME}/project.yml`: |
| 102 | |
| 103 | ```bash |
| 104 | cat > macios/native/${BINDING_NAME}/project.yml << 'EOF' |
| 105 | name: MyBinding |
| 106 | options: |
| 107 | bundleIdPrefix: com.example |
| 108 | deploymentTarget: |
| 109 | iOS: "15.0" |
| 110 | macOS: "12.0" |
| 111 | xcodeVersion: "15.0" |
| 112 | generateEmptyDirectories: true |
| 113 | |
| 114 | settings: |
| 115 | base: |
| 116 | MARKETING_VERSION: "1.0.0" |
| 117 | CURRENT_PROJECT_VERSION: "1" |
| 118 | BUILD_LIBRARY_FOR_DISTRIBUTION: YES |
| 119 | SKIP_INSTALL: NO |
| 120 | MACH_O_TYPE: staticlib |
| 121 | SWIFT_VERSION: "5.0" |
| 122 | ENABLE_BITCODE: NO |
| 123 | DEFINES_MODULE: YES |
| 124 | |
| 125 | targets: |
| 126 | MyBinding: |
| 127 | type: framework |
| 128 | platform: iOS |
| 129 | sources: |
| 130 | - path: MyBinding |
| 131 | type: group |
| 132 | settings: |
| 133 | base: |
| 134 | INFOPLIST_FILE: MyBinding/Info.plist |
| 135 | PRODUCT_BUNDLE_IDENTIFIER: com.example.mybinding |
| 136 | PRODUCT_NAME: MyBinding |
| 137 | TARGETED_DEVICE_FAMIL |