Access Xcode Server API with native Swift objects.

Overview

Xcode Server SDK

satellite badge Latest XcodeServerSDK Release CocoaPods

License Blog Twitter Czechboy0

Use Xcode Server's API with native Swift objects.

First brought to you in Buildasaur, now in an independent project. This is an unofficial, community-maintained project and is not associated with Apple. We also maintain the unofficial documentation of Xcode Server in case you'd like to integrate using a different programming language! ๐Ÿ˜‰

๐ŸŽ“ Getting Started With Xcode Server

To find out how to set up Xcode Server on your Mac in minutes (and more), check out my series of tutorials.
To see how easy it is to integrate XcodeServerSDK into an iOS app, check out the XCSDemo project created by @cojoj.

๐Ÿ“ถ Xcode Server API Versions

| Xcode Server API | Supported? | | :-- | :--: | :--: | | Xcode 7 and newer | โœ… from 0.1 | | Xcode 6 and older | โœ… up to 0.0.4 |

You'll need OS X Server of version >= 4. For Xcode 7 you need OS X >= 10.10.4.

The latest version supporting the old, undocumented Xcode 6 version of the Xcode Server API is 0.0.4. All newer versions only support the new, first publicly documented Xcode 7 version of the API.

:octocat: Sources

One way to integrate XcodeServerSDK into your project is with CocoaPods. Add this to your Podfile (with the version being the latest released pod version: CocoaPods:

pod 'XcodeServerSDK'

๐Ÿ”ง Usage

Create the server config object with the server's URL, username and password.

do {
    let config = XcodeServerConfig(host: "https://127.0.0.1", user: "IRuleBots", password: "superSecr3t")
} catch ConfigurationErrors.NoHostProvided {
    fatalError("You haven't provided any host")
} catch ConfigurationErrors.InvalidHostProvided(let host){
    fatalError("You've provided invalid host: \(host)")
} catch ConfigurationErrors.InvalidSchemeProvided(let scheme) {
    fatalError("You've provided invalid scheme: \(scheme)")
} catch {
    fatalError("Error, not related to XcodeServerConfig; \(error)")
}

Instantiate XcodeServer.

let server = XcodeServerFactory.server(config: config)

Go wild!

server.getBots { bots, error in
    guard error == nil else {
        Log.error("Oh no! \(error.description)")
        return
    }
    
    // go crazy with bots
    if let firstBot = bots?.first {
        // use the first bot...
    }
}

๐Ÿ“ถ Swift Versions

The latest Swift 1.2 compatible version is 0.0.4, so put this exact version in your Podfile if you're targeting Swift 1.2. All newer releases will be targeting Swift 2, because we're all just so forward-thinking.

๐ŸŽช Play with Playground

We're providing a Plaground in which you can easily interact with XcodeServerSDK and test it's functionalities without any need to create a new app. Playground target is set to be OS X (so don't use UIKit inside).

๐Ÿš€ Features

Apple has finally shipped the official docs for Xcode Server. They're slightly different from what has been presented on WWDC (slide 69). Below is the table with features described in docs - divided into categories. Last category, unofficial, is the cluster of features reverse engineered while working on XcodesServerSDK, so you won't find them in docs, but they're definitely in code! ๐Ÿ˜ƒ

Category Description XcodeServerSDK support
Bots
Creates a new bot โœ…
Retrieve a list of bots โœ…
Retrieve a single bot โœ…
Update a single bot โ›”
Delete a single bot โœ…
Duplicate an existing bot โ›”
Integrations
Begin an integration for the specified bot โœ…
Retrieve a single integration โœ…
Delete an integration โ›”
Cancel a integration currently being executed โœ…
Retrieve options to perform filters, selections and calculations on all integrations for the specified bot partially
Retrieve options to perform filters, selections and calculations on all integrations partially
Retrieve the tests for an integration partially
Retrieve the test information list for a given integration and device identifier partially
Retrieve the test information list of issues for a given integration and device identifier โœ…
Retrieve the list of files for a given integration โ›”
Assets
Retrieve an asset given its relative path โ›”
Code Coverage
Retrieve the Code Coverage information for a given integration โ›”
Unofficial
Check if user can create bots โœ…
List hosted repositories on server โœ…
Create a new hosted repository โœ…
Get supported platforms โœ…
Get SCM branches from Blueprint โœ…
Verify user can manage server โœ…

๐ŸŒ‡ Supported Platforms

Currently XcodeServerSDK provides support for the following platforms:

Platform Minimum Version CocoaPods
OS X 10.10 โœ…
iOS 8.0 โœ…
watchOS 2.0 โœ…
tvOS 9.0 โœ…

๐ŸŽ‰ Projects using XcodeServerSDK

  • Buildasaur - connect Xcode Server with GitHub Pull Requests.
  • (using XcodeServerSDK too? Send a PR with a link to your project added here!)

Want to create yours but need some inspiration? Watch this WWDC 2015 session on Xcode Server! Using hardware buttons to start integrations? Why not! The sky is the limit.

โœŒ๏ธ License

MIT

๐Ÿšข Building & Testing

We use CocoaPods for dependency management. When you clone the repo, you'll need to run pod install to download the necessary dependencies.

๐Ÿ’™ Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

โœ๏ธ Contributing

Create an issue or (preferably) send a pull request. Do you just want to get involved and help out? See the issues marked as up-for-grabs. These are the ones just waiting for some beautiful soul like you to build/fix it. We just don't have enough bandwidth and any help is welcome :) (You'll be in the contributors list of the release if you send a PR! ๐ŸŽ† )

๐Ÿ’ฌ Get in touch

For things like general problems/ideas please report an issue, so anyone can see them and relate to them in the future. It's realy important for Open Source projects like this! If your problem requires a deep discussion or you have a great idea and you really want to share it with someone before opening an issue you can join the official Buildasaurs Slack team! (To do so, go to this website and have your e-mail address ready ๐Ÿ“ง )

๐ŸŽ… Origin Story

This code has been pulled out of Buildasaur, bringing you integration of GitHub Pull Requests to Xcode Bots.

๐Ÿ‘ฝ Author

Honza Dvorsky honzadvorsky.com @czechboy0

Comments
  • Add integration issues API endpoint feature

    Add integration issues API endpoint feature

    I've started working on the next missing official API support endpoint from our list.

    This time, List the build issues produced by an integration, is on a plate ๐Ÿ›.

    opened by cojoj 58
  • BuildaUtils for iOS target

    BuildaUtils for iOS target

    I've tried to run today XcodeServerSDK's iOS target I get this rather strange error:

    screen shot 2015-07-29 at 10 43 52

    It looks like our Podfile is linking wrong BuildaUtils target. Any idea what's wrong?

    bug help wanted 
    opened by cojoj 22
  • Find Swift 2-compatible HTTP request mocking library

    Find Swift 2-compatible HTTP request mocking library

    I'd like to add proper tests for requests/responses, so we need a library that helps us with that. I tried Mockingjay, unfortunately it doesn't yet have Swift 2 support. This is pretty urgent.

    (cc: @cojoj and @esttorhe)

    help wanted blocker 
    opened by czechboy0 20
  • XcodeServerEndpoints.createRequest tests

    XcodeServerEndpoints.createRequest tests

    Hey, I added three tests for createRequest method, but I don't have a clue how to 100% cover the XcodeServerEndpoints class. Please take a look.

    Btw. I have one proposition regarding XcodeServer class. I would move the code below (from sendRequestWithMethod method) to createRequest method, because createRequest method can figure out HTTP.Method directly from its parameter. What do you think?

    var allParams = [
        "method": method.rawValue
    ]
    
    //merge the two params
    if let params = params {
        for (key, value) in params {
            allParams[key] = value
        }
    }
    
    opened by pmkowal 19
  • Device and Platforms tests

    Device and Platforms tests

    @czechboy0 I hope you're back from holidays, full of energy and ready to work ๐Ÿ˜†

    New batch with Device tests.

    First of all, I've added missing fields/properties to Device model - please check them and let me know what do you think and if things marked as Enum? in comments should be moved to DeviceSpecyfication file.

    One thing that concerns me about cassetes is that we're only testing gold path and skipping any possible error paths. Do you think we should create test cases and test failing paths as well? If so, how would you write those tests? Record another casette, write mocks or stubs? As we leave it as it is now we won't get full coverage of the code...

    opened by cojoj 19
  • XcodeServerEndpoints.endpointURL tests

    XcodeServerEndpoints.endpointURL tests

    I've created tests for endpointURL method from XcodeServerEndpoints class. I set access level of XcodeServerEndpoints.endpointURL method as internal as we discussed in #79 issue.

    I also renamed EndPoints -> Endpoints in XcodeServerEndPoints name in order to maintain the compatibility between names of files, classes and variables.

    Please review.

    opened by pmkowal 18
  • ๏ฃฟแดกแด€แด›แด„สœ

    ๏ฃฟแดกแด€แด›แด„สœ

    Fix #33

    Adds support for ๏ฃฟแดกแด€แด›แด„สœ framework.

    Dependencies

    This PR depends on #32 (because its using the ยซnewยป throws/guard inits on the XcodeServerConfig class

    opened by esttorhe 18
  • XcodeServerConfig refactoring

    XcodeServerConfig refactoring

    While writing tests for this class I've noticed that it may be struggling in some cases.

    First of all, when you create object using public init(var host: String, user: String?, password: String?) we're checking if host has https scheme and so on but if we go through the second init?() we can see that it won't check if scheme was provided - it only checks existence of host.

    I think we should extract method for checking and creating host eg.

    
    funct validateHost(var host: String) -> String{
        if let url = NSURL(string: host) {
            if url.scheme.isEmpty {
                // exted host with https scheme
                host = "https://" + host
            } else if url.scheme != "https" {
                Log.error("Xcode Server generally uses https, please double check your hostname")
            }
        }
    
        return host
    }
    

    But I think in this case we can make some use of throws and guard...

    discussion 
    opened by cojoj 18
  • Add test for fetching repositories

    Add test for fetching repositories

    As I pointed in #45 I've witnessed some twisted behaviors of test coverage - indicates that not all of my code is covered while breakpoints execute in not covered part of code... Maybe some ideas?

    Anyway, this code works fine and all tests are passing on both iOS and OS X.

    opened by cojoj 14
  • Carthage support

    Carthage support

    In #1 @cojoj mentioned Carthage support. Let's look into how much would be required to properly support it, test out that our framework works both in iOS and OS X projects and if everything works, let's add the proper badge into our readme: Carthage compatible

    @cojoj, do you want to take care of this?

    help wanted task 
    opened by czechboy0 14
  • Commits request

    Commits request

    I'm working on another point from #40 and I want to consult some matters before implementing anything.

    It's obvious that List the commits included in an integration will consist of Commit model but... Response JSON is strange in some way and I'd like to clarify naming convention. Basically integration/id/commits response JSON looks like:

    {
        "count": 1,
        "results": [{
            "_id": "62395864c6d0b1fc6536c0ab3a0d2b2d",
            "_rev": "3-ced1cebb3b420512ee66e7a1927e32f2",
            "commits": {
                      []
                    },
                    "integration": "62395864c6d0b1fc6536c0ab3a0d0733",
            "botID": "38a6d8e59f34d59c810e98f5c6030e02",
            "botTinyID": "23530A6",
            "endedTimeDate": [2015, 7, 7, 14, 15, 20],
            "doc_type": "commit",
            "tinyID": "127FDC7"
        }]
    }
    

    IMHO, main object should be called something like IntegrationCommits because there's Commits array inside of it but Commit, itself, doesn't containt fields to be XcodeServerEntity. What's more, commits array contains an array of repositories which holds actual commits - so another model? Actual Commit looks like:

    {
        "XCSCommitCommitChangeFilePaths": [{
            "status": 4,
            "filePath": "cells/NewProductCell.m"
        }, {
            "status": 4,
            "filePath": "GreetingTextViewController.m"
        }, {
            "status": 4,
            "filePath": "ViewControllers/NewChooseProductViewController.m"
        }],
        "XCSCommitMessage": "Fixed ios7 bug",
        "XCSBlueprintRepositoryID": "715A78DA7313BF688CEE0585F44D4F0B2EAEE4B8",
        "XCSCommitContributor": {
            "XCSContributorEmails": ["[email protected]"],
            "XCSContributorName": "Foo Bar",
            "XCSContributorDisplayName": "Foo Bar"
        },
        "XCSCommitHash": "aeb85aed37e633b6c9776cb863a39f922cb464d9",
        "XCSCommitTimestamp": "2015-07-07T14:14:29.000Z",
        "XCSCommitTimestampDate": [2015, 7, 7, 14, 14, 29]
    }
    

    I have a feeling I'm complicating everything but what do you think - should those models be separated or treated like one big, nested model and inherit from XcodeServerEntity?

    discussion 
    opened by cojoj 13
  • bot creation

    bot creation

    In order to create a bot through the XCode Server API, is it required a first manual step to create the bot?

    Inside https://honzadvorsky.com/articles/2015-08-04-xcs_tutorials_1_getting_started/ it says "One way to create Bots is directly from Xcode", so I'm wondering if it's possible to avoid the manual configuration. Our idea is to fully automatize the bot creation and its integrations.

    opened by jordirlatgit 1
  • Build a API tester to run on every new release

    Build a API tester to run on every new release

    That would warn us if any of the supported API calls changed responses - maybe use DVR and compare canned and live responses? First we'd wipe all bots, then inject known data and then query for it and compare.

    Also, it'd be interesting to build a script which scrapes the internal .js files and creates a sorted list out of it, again would allow to quickly spot API changes (although it'd be ideal if Apple actually informed of the API version changes in the documentation).

    help wanted feature task up-for-grabs 
    opened by czechboy0 0
  • XcodeServerProxy (proxy, load balancer)

    XcodeServerProxy (proxy, load balancer)

    In order to support https://github.com/czechboy0/Buildasaur/issues/180, we need to add a new object, XcodeServerProxy, which will look like a plain old Xcode Server on the outside, however on the inside it will talk to multiple real Xcode Servers, distribute work between them and when e.g. asked for Bots, will gather Bots from all real instances (and keep an internal map of which Bot lives on which instance).

    This will get complicated, but is another step in powering awesome usecases which devs are coming up with - in this case, having a farm of Xcode Servers and distributing work between them.

    All feedback is welcome, because I've never done anything like this. Should be fun.

    (Note: this will require heavy tests to be written probably before we start implementing it to be able to lock down the behavior).

    help wanted feature 
    opened by czechboy0 4
  • Review & adapt to the new XCS API Docs

    Review & adapt to the new XCS API Docs

    They're sort of out. Review and adapt some of our API calls (we might not be doing certain things properly).

    https://developer.apple.com/library/prerelease/mac/documentation/Xcode/Conceptual/XcodeServerAPIReference/index.html

    opened by czechboy0 2
Releases(v0.7.1)
Owner
Buildasaurs
Everything for Buildasaur
Buildasaurs
An iOS library to route API paths to objects on client side with request, mapping, routing and auth layers

WANetworkRouting Developed and Maintained by ipodishima Founder & CTO at Wasappli Inc. Sponsored by Wisembly A routing library to fetch objects from a

null 10 Nov 20, 2022
Setup your class structure in Xcode Interface Builder and save() in Parse Server.

ISParseBind With ISParseBind you can save, update and query PFObjects using the power of Xcode Interface Builder resources. https://www.youtube.com/wa

Weni 10 Mar 28, 2022
Server-side Swift. The Perfect core toolset and framework for Swift Developers. (For mobile back-end development, website and API development, and moreโ€ฆ)

Perfect: Server-Side Swift ็ฎ€ไฝ“ไธญๆ–‡ Perfect: Server-Side Swift Perfect is a complete and powerful toolbox, framework, and application server for Linux, iO

PerfectlySoft Inc. 13.9k Jan 6, 2023
An Alamofire extension which converts JSON response data into swift objects using EVReflection

AlamofireJsonToObjects ?? This is now a subspec of EVReflection and the code is maintained there. ?? You can install it as a subspec like this: use_fr

Edwin Vermeer 161 Sep 29, 2022
Lazily deserialize JSON into strongly typed Swift objects

LazyObject Lazily deserialize JSON into strongly typed Swift objects, with a few getter style options. Is your app using it? Let me know! Installation

rob phillips 11 Nov 16, 2022
DBNetworkStack is a network abstraction for fetching request and mapping them to model objects

DBNetworkStack Main Features ?? Typed network resources ?? Value oriented architecture ?? Exchangeable implementations ?? Extendable API ?? Composable

DB Systel GmbH 33 Jan 10, 2022
๐ŸŒ Makes Internet connectivity detection more robust by detecting Wi-Fi networks without Internet access.

Connectivity is a wrapper for Apple's Reachability providing a reliable measure of whether Internet connectivity is available where Reachability alone

Ross Butler 1.6k Dec 30, 2022
Simplified access to Apple's CloudKit

EVCloudKitDao Discuss EVCloudKitDao : What is this With Apple CloudKit, you can focus on your client-side app development and let iCloud eliminate the

Edwin Vermeer 632 Dec 29, 2022
This generic SOAP client allows you to access web services using a your iOS app, Mac OS X app and AppleTV app.

This generic SOAP client allows you to access web services using a your iOS app, Mac OS X app and Apple TV app. With this Framework you can create iPh

Prioregroup.com 479 Nov 22, 2022
Private Internet Access - PIA VPN for iOS

Private Internet Access Private Internet Access is the world's leading consumer VPN service. At Private Internet Access we believe in unfettered acces

Private Internet Access - Free and Open Source Software 202 Dec 23, 2022
Kiwix for offline access on iOS and macOS

Kiwix for iOS & macOS This is the home for Kiwix apps on iOS and macOS. Mobile app for iPads & iPhones Download the iOS mobile app on iTunes App Store

Kiwix 299 Dec 21, 2022
Swift Express is a simple, yet unopinionated web application server written in Swift

Documentation <h5 align="right"><a href="http://demo.swiftexpress.io/">Live ?? server running Demo <img src="https://cdn0.iconfinder.com/data/icons/

Crossroad Labs 850 Dec 2, 2022
Swift backend / server framework (Pure Swift, Supports Linux)

NetworkObjects NetworkObjects is a #PureSwift backend. This framework compiles for OS X, iOS and Linux and serves as the foundation for building power

Alsey Coleman Miller 258 Oct 6, 2022
๐Ÿ’ง A server-side Swift web framework.

Vapor is a web framework for Swift. It provides a beautifully expressive and easy to use foundation for your next website, API, or cloud project. Take

Vapor 22.4k Jan 2, 2023
A Swift web framework and HTTP server.

A Swift Web Framework and HTTP Server Summary Kitura is a web framework and web server that is created for web services written in Swift. For more inf

Kitura 7.6k Jan 6, 2023
Tiny http server engine written in Swift programming language.

What is Swifter? Tiny http server engine written in Swift programming language. Branches * stable - lands on CocoaPods and others. Supports the latest

null 3.6k Dec 31, 2022
Lightweight library for web server applications in Swift on macOS and Linux powered by coroutines.

Why Zewo? โ€ข Support โ€ข Community โ€ข Contributing Zewo Zewo is a lightweight library for web applications in Swift. What sets Zewo apart? Zewo is not a w

Zewo 1.9k Dec 22, 2022
Super lightweight async HTTP server library in pure Swift runs in iOS / MacOS / Linux

Embassy Super lightweight async HTTP server in pure Swift. Please read: Embedded web server for iOS UI testing. See also: Our lightweight web framewor

Envoy 540 Dec 15, 2022
Swift HTTP server using the pre-fork worker model

Curassow Curassow is a Swift Nest HTTP Server. It uses the pre-fork worker model and it's similar to Python's Gunicorn and Ruby's Unicorn. It exposes

Kyle Fuller Archive 397 Oct 30, 2022