{"id":19149801,"url":"https://github.com/harness/ff-ios-client-sdk","last_synced_at":"2025-05-07T04:44:30.000Z","repository":{"id":38447353,"uuid":"343499041","full_name":"harness/ff-ios-client-sdk","owner":"harness","description":"iOS Client SDK to integrate with Harness FF service","archived":false,"fork":false,"pushed_at":"2025-04-30T08:21:41.000Z","size":395,"stargazers_count":3,"open_issues_count":0,"forks_count":8,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-05-07T04:44:20.980Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/harness.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-03-01T17:23:14.000Z","updated_at":"2025-04-30T08:21:45.000Z","dependencies_parsed_at":"2024-12-07T16:17:33.568Z","dependency_job_id":"003baf8e-cc4d-4382-a822-81b66e631564","html_url":"https://github.com/harness/ff-ios-client-sdk","commit_stats":null,"previous_names":["drone/ff-ios-client-sdk"],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harness%2Fff-ios-client-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harness%2Fff-ios-client-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harness%2Fff-ios-client-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harness%2Fff-ios-client-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harness","download_url":"https://codeload.github.com/harness/ff-ios-client-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252816519,"owners_count":21808702,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T08:09:43.209Z","updated_at":"2025-05-07T04:44:29.980Z","avatar_url":"https://github.com/harness.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# iOS SDK For Harness Feature Flags\n\n[![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-4BC51D.svg?style=flat)](https://swift.org/package-manager/)\n[![CocoaPods compatible](https://img.shields.io/badge/CocoaPods-compatible-4BC51D.svg?style=flat)](https://github.com/CocoaPods/CocoaPods)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\n---\nUse this README to get started with our Feature Flags (FF) SDK for iOS. This guide outlines the basics of getting started with the SDK and provides a full code sample for your to try out.\n\nThis sample doesn't include configuration options, for in depth steps and configuring the SDK, for example, disabling streaming or using our Relay Proxy, see the [iOS SDK Reference](https://ngdocs.harness.io/article/6qt2v8g92m-ios-sdk-reference).\n\n\nFor a sample FF iOS SDK project, see [our test iOS project](https://github.com/drone/ff-ios-client-sample).\n\n## Requirements\nTo use this SDK, make sure you've:\n- Installed XCode to use the Swift Package Manager (SPM), CocoaPods, or Carthage\n\nTo follow along with our test code sample, make sure you’ve:\n- [Created a Feature Flag](https://ngdocs.harness.io/article/1j7pdkqh7j-create-a-feature-flag) on the Harness Platform called `harnessappdemodarkmode`\n- Created a [server/client SDK key](https://ngdocs.harness.io/article/1j7pdkqh7j-create-a-feature-flag#step_3_create_an_sdk_key) and made a copy of it\n\n## Installing the SDK\nThere are multiple methods to installing the iOS SDK:\n## \u003cu\u003e_Swift Package Manager (SPM)_\u003c/u\u003e\nThe [Swift Package Manager](https://swift.org/package-manager/) is a dependency manager integrated into the `swift` compiler and `Xcode`.\n\nTo integrate `ff-ios-client-sdk` into an Xcode project, go to the `File` drop down, and select `Add Packages`. From here, search the url `https://github.com/harness/ff-ios-client-sdk.git` in the search bar and click the `Add Package` button.\n\nOR\n\nYou can also add the `ff-ios-client-sdk` dependency locally by dragging the SDK folder into the root directory of the project and simply add it to the dependencies section of your `Package.swift` file.\n\n```Swift\ndependencies: [\n\t.package(url: \"https://github.com/harness/ff-ios-client-sdk.git\", .upToNextMinor(from: \"1.1.0\"))\n]\n```\n\u0026nbsp;\n## \u003cu\u003e_CocoaPods_\u003c/u\u003e\nThe [CocoaPods](https://cocoapods.org//) CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. It has over 81 thousand libraries and is used in over 3 million apps. CocoaPods can help you scale your projects elegantly.\n\nCocoaPods is built with Ruby and it will be installable with the default Ruby available on macOS. You can use a Ruby Version manager, however we recommend that you use the standard Ruby available on macOS unless you know what you're doing.\n\nUsing the default Ruby install will require you to use sudo when installing gems. (This is only an issue for the duration of the gem installation, though.)\n```Swift\n$ sudo gem install cocoapods\n```\n\nOnce cocoapods are installed, from your root project folder, create a `Podfile`, which will be located in your project's root folder, by entering the next command in your terminal:\n```Swift\n$ pod init\n```\n\nTo import `ff-ios-client-sdk` to your `.xcproject`, simply add `ff-ios-client-sdk` to your newly created Podfile and save the Podfile changes.\n```Swift\nplatform :ios, '10.0'\nuse_frameworks!\n\ntarget 'MyApp' do\n  pod 'ff-ios-client-sdk'\nend\n```\n\nOnly thing left to do is to install your packages by running the next command.\n```Swift\npod install\n```\nNOTE: A new `.xcworkspace` will be created and you should use that, instead of your `.xcodeproj` from now on in order to utilize the imported Pods.\n\n## \u003cu\u003e_Carthage_\u003c/u\u003e\nCarthage is intended to be the simplest way to add frameworks to your Cocoa application.\nCarthage builds your dependencies and provides you with binary frameworks, but you retain full control over your project structure and setup. Carthage does not automatically modify your project files or your build settings.\nIn order to integrate `ff-ios-client-sdk` into your app, there are a few steps to follow.\nNavigate to the root folder of your project and create a `Cartfile`. This is the file where you would input all of your dependencies that you plan to use with Carthage. You can create it by entering\n```Swift\ntouch Cartfile\n```\nin Terminal at your project's root folder. Once you open the `Cartfile`, you can copy/paste below line and save the changes.\n```Swift\ngithub \"harness/ff-ios-client-sdk\"\n```\n\nNow, you need to run\n```Swift\ncarthage update --no-build\n```\nThis command will fetch the source for `ff-ios-client-sdk` from the repository specified in the `Cartfile`.\n\nYou will now have a new folder, named `Carthage` at the same location your `Cartfile` and your `.xcodeproj` are.\nWithin the `Carthage` folder, you will see another `Checkout` folder where the source code is located.\nNext, we need to create a project for `ff-ios-client-sdk` dependency. We can do this easily by entering the following in the termial.\n```Swift\n//From your project's root folder\ncd Carthage/Checkouts/ff-ios-client-sdk\n```\nfollowed by\n```Swift\nswift package generate-xcodeproj\n```\n...or, you can enter it all on the same line.\n```Swift\n//From your project's root folder\ncd Carthage/Checkouts/ff-ios-client-sdk \u0026\u0026 swift package generate-xcodeproj\n```\nGo back into your project's root folder and enter the next command:\n```Swift\ncarthage build --use-xcframeworks --platform iOS\n```\nThis command will build the project and place it in the `Build` folder next to `Checkouts`.\nOn your application targets’ `General` settings tab, in the `Frameworks, Libraries, and Embedded Content` section, drag and drop the `.xcframework` file from the `Carthage/Build` folder. In the `\"Embed\"` section, select `\"Embed \u0026 Sign\"`.\n\nOnly thing left to do is:\n```Swift\nimport ff_ios_client_sdk\n```\n...wherever you need to use `ff-ios-client-sdk`\n\nWhen a new version of `ff-ios-client-sdk` is available and you wish to update this dependency, run\n```Swift\n$ carthage update --use-xcframeworks --platform iOS\n```\nAnd your embedded library will be updated.\n\n## Code Sample\nThe following is a complete code example that you can use to test the `harnessappdemodarkmode` Flag you created on the Harness Platform. When you run the code it will:\n1. Connect to the FF service.\n2. Report the value of the Flag every 10 seconds until the connection is closed. Every time the `harnessappdemodarkmode` Flag is toggled on or off on the Harness Platform, the updated value is reported.\n3. Close the SDK.\n\nTo use this sample, copy it into your project and enter your SDK key into the `apiKey` field.\n\n```\nimport UIKit\nimport ff_ios_client_sdk\nclass ViewController: UIViewController {\n  override func viewDidLoad() {\n    super.viewDidLoad()\n    NSLog(\"Start\")\n    let config = CfConfiguration.builder()\n      .setStreamEnabled(true)\n      .build()\n    let target = CfTarget.builder().setIdentifier(\"Harness\").build()\n    CfClient.sharedInstance.initialize(\n      apiKey: \"apiKey\",\n      configuration:config,\n      target: target\n    ) { [weak self] result in\n      switch result {\n        case .failure(let error):\n          NSLog(\"End: Error \\(error)\")\n        case .success():\n          NSLog(\"Init: Ok\")\n          CfClient.sharedInstance.boolVariation(evaluationId: \"EVALUATION_ID\", { (eval) in\n            print(\"Value: \\(eval!)\")\n          })\n          CfClient.sharedInstance.registerEventsListener() { (result) in\n            switch result {\n              case .failure(let error):\n                print(error)\n              case .success(let eventType):\n                switch eventType {\n                  case .onPolling:\n                    print(\"Event: Received all evaluation flags\")\n                  case .onEventListener(let evaluation):\n                    print(\"Event: Received an evaluation flag, \\(evaluation!)\")\n                  case .onComplete:\n                    print(\"Event: SSE stream has completed\")\n                  case .onOpen:\n                    print(\"Event: SSE stream has been opened\")\n                  case .onMessage(let messageObj):\n                    print(messageObj?.event ?? \"Event: Message received\")\n                  case .onDelete(let flagID):\n                    print(\"Flag was deleted:, \\(flagID!)\")\n                }\n            }\n          }\n      }\n    }\n  }\n  override func viewWillDisappear(_ animated: Bool) {\n    CfClient.sharedInstance.destroy()\n    NSLog(\"End: Ok\")\n    super.viewWillDisappear(animated)\n  }\n}\n```\n\n## Additional Reading\nFor further examples and config options:\n- See the [iOS SDK Reference](https://docs.harness.io/article/6qt2v8g92m-ios-sdk-reference)\n- [Further Reading](docs/further_reading.md)\n\nFor more information about Feature Flags, see our [Feature Flags documentation](https://docs.harness.io/article/0a2u2ppp8s-getting-started-with-feature-flags).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharness%2Fff-ios-client-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharness%2Fff-ios-client-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharness%2Fff-ios-client-sdk/lists"}