pod init
or adding PodFile (see example) in the root directory of your project.AppDelegate.swift
file, this is where we will initialize our SDK with the following parameters.urlEndpoint
is the required parameter. You can get the value of URL-endpoint from your ImageKit dashboard - https://imagekit.io/dashboard#url-endpoints.publicKey
and authenticationEndpoint
parameters are optional and only needed if you want to use the SDK for client-side file upload. You can get these parameters from the developer section in your ImageKit dashboard - https://imagekit.io/dashboard#developers.ImageKitURLConstructor
ImageKitURLConstructor
which takes the URL endpoint, image path, and transformation position as parameters to create the transformed url.urlConstructor
. create
function to get the final transformed URLheight
for h
and width
for w
parameter. It makes your code more readable. See the full list of supported transformations in iOS SDK on Github.addCustomTransformation
function and pass the transformation code from ImageKit docs as the first parameter and value as the second parameter. For example - .addCustomTransformation("w", "400").
pad_resize
crop strategy. In this strategy, the output image's dimension (height and width) is the same as requested, no cropping occurs, and the aspect ratio is preserved. This is accomplished by adding padding around the output image to get it to match the exact dimension as requested. You can read more about this here.ImageKitUploader
which provide functions to allow upload files to the ImageKit media library directly from the client-side. publicKey
and authenticationEndpoint
while initializing the SDK. Replace your_url_endpoint
, your_public_key
, your_authentication_endpoint
with actual values.Server
folder inside the tutorial project and install its npm packages:index.js
to implement http://localhost:8080/auth
which is our authenticationEndpoint
.curl http://localhost:8080/auth
in the terminal, you should see a JSON response like this. Actual values will vary.AppDelegate.swift
and ensure the authenticationEndpoint
is set to http://localhost:8080/auth
ImageKitUploader
. For complete API reference for the image upload function, check out the docs on the ImageKit iOS Git Repository. ImageKit.shared.uploader().upload
function can ingest files through UIImage
, NSData
or Url of a remote image