Code Monkey home page Code Monkey logo

imobiledevice-net's Introduction

.NET bindings for imobiledevice

Build status NuGet Status

imobiledevice-net is a library which allows you to interact with iOS devices on Windows using any of the .NET Framework languages (such as C# or Visual Basic). It is based on the libimobiledevice library.

Installing

You can install imobiledev-net as a NuGet package

PM> Install-Package imobiledevice-net

Advantages of imobiledevice-net

We've done some work to make sure imobiledevice-net "just works":

  • Better string handling: Strings are marshalled (copied from .NET code to unmanaged code and vice versa) as UTF-8 strings. This is what libimobiledevice uses natively.
  • Better array handling: In most cases, we'll return a ReadOnlyCollection<string> object instead of IntPtr objects when the native API returns an array of strings.
  • Less memory leaks: We give you safe handles instead of IntPtr objects. When you dispose of the safe handle (or you forget, and the framework does it for you), the safe memory is freed, too.
  • Unit testing support: You interact with libimobiledevice through classes such as iDevice or Lockdown. For each of these classes, we also expose an interface, allowing you to unit test your code.
  • XML Documentation: Where possible, we've copied over the documentation of libimobiledevice to imobiledevice-net, giving you IntelliSense support.

How it works

We use libclang to parse the libimobiledevice C headers and generate the C# P/Invoke code.

Getting started

Using the library

Before you use the library, you must call NativeLibraries.Load() so that libimobiledevice is loaded correctly:

NativeLibraries.Load();

Listing all iOS devices

The following snippit lists all devices which are currently connected to your PC:

ReadOnlyCollection<string> udids;
int count = 0;

var idevice = LibiMobileDevice.Instance.iDevice;
var lockdown = LibiMobileDevice.Instance.Lockdown;

var ret = idevice.idevice_get_device_list(out udids, ref count);

if (ret == iDeviceError.NoDevice)
{
    // Not actually an error in our case
    return;
}

ret.ThrowOnError();

// Get the device name
foreach (var udid in udids)
{
    iDeviceHandle deviceHandle;
    idevice.idevice_new(out deviceHandle, udid).ThrowOnError();

    LockdownClientHandle lockdownHandle;
    lockdown.lockdownd_client_new_with_handshake(deviceHandle, out lockdownHandle, "Quamotion").ThrowOnError();

    string deviceName;
    lockdown.lockdownd_get_device_name(lockdownHandle, out deviceName).ThrowOnError();

    deviceHandle.Dispose();
    lockdownHandle.Dispose();
}

imobiledevice-net's People

Contributors

qmfrederik avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.