{"id":17275277,"url":"https://github.com/jflinter/resourceful","last_synced_at":"2025-04-14T09:13:27.603Z","repository":{"id":145373345,"uuid":"43795724","full_name":"jflinter/Resourceful","owner":"jflinter","description":"Autogenerate swift code to stop using stringly-typed imageNamed","archived":false,"fork":false,"pushed_at":"2015-10-11T23:04:52.000Z","size":148,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T09:13:14.502Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jflinter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-07T04:50:43.000Z","updated_at":"2019-08-18T16:52:54.000Z","dependencies_parsed_at":"2023-04-09T13:14:21.074Z","dependency_job_id":null,"html_url":"https://github.com/jflinter/Resourceful","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jflinter%2FResourceful","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jflinter%2FResourceful/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jflinter%2FResourceful/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jflinter%2FResourceful/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jflinter","download_url":"https://codeload.github.com/jflinter/Resourceful/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248852182,"owners_count":21171842,"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-10-15T08:55:50.457Z","updated_at":"2025-04-14T09:13:27.576Z","avatar_url":"https://github.com/jflinter.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Resourceful\n\nResourceful is an Xcode utility that helps avoid making mistakes when using `UIImage/NSImage imageNamed:`. That method takes a String, and loads an image from your app's bundle with that name. Unfortunately, there's no warning if you, say, typo the string.\n\nResourceful skirts this issue by inspecting your Xcode project for image assets, and creating an enum of all of their possible values. Thus,\n```swift\nlet image = UIImage(named: \"catsInSpace\")\n```\n\nbecomes\n```swift\nlet image = Resource.Image.CatsInSpace.image\n```\n\nThere are [many][0] [other][1] [libraries][2] that do this, but this one is mine. Why should you use it instead of anything else?\n- It's written in Go, and really fast (important for a program that you'll be running as part of every Xcode build)\n- It works for both iOS and OS X projects\n- It can optionally generate warnings for you in places where you're still using `imageNamed` in your app.\n\n## Getting started\n\nFirst, install Resourceful:\n```bash\ncd /usr/local/bin\ncurl -L -O https://github.com/jflinter/Resourceful/releases/download/0.2/resourceful.tar.gz\ntar -zxvf resourceful.tar.gz\n```\n\nNext, in your Xcode build phases settings, add a new Run Script Build Phase at the beginning of your build. For its contents, simply type\n```\nresourceful\n```\n\nIn the \"Input Files\" section, put a link to your app's `Images.xcassets` directory. This will typically be:\n```\n$(SRCROOT)/Your_apps_name/Images.xcassets\n```\n\nIn the \"Output Files\" section, specify where you'd like the code Resourceful generates to live. This will typically be:\n```\n$(SRCROOT)/Your_apps_name/Resourceful.swift\n```\n\nIf you're wondering, you specify your files this way because Xcode can then intelligently avoid re-running this script unless the contents of your `Images.xcassets` changes.\n\nNext, build your app. This will generate `Resourceful.swift` at the directory you specified.\n\nFinally, add `Resourceful.swift` to your Xcode project by going to File -\u003e Add Files to \"Your app's name\".\n\n### Optional\n\nAs mentioned previously, Resourceful can also generate warnings in your Xcode project to encourage you to stop using imageNamed. To do this, add another Run Script Build Phase (it needs to be separate from the previous script, in case Xcode skips the previous one due to caching) with the contents:\n```\nresourceful warn\n```\n\nAnd you're done!\n\n[0]: https://github.com/mac-cain13/R.swift\n[1]: https://github.com/AliSoftware/SwiftGen\n[2]: https://github.com/kaandedeoglu/Shark\n[3]: https://golang.org/doc/install\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjflinter%2Fresourceful","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjflinter%2Fresourceful","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjflinter%2Fresourceful/lists"}