Exercism exercises in Objective-C
If you've downloaded the command-line client and have Objective-C installed on your machine, then go ahead and fetch the first problem.
exercism fetch objective-c
In order to be able to submit your solution, you'll need to configure the client with your Exercism API key.
exercism configure --key=YOUR_EXERCISM_KEY
When you've written a solution, submit it to the site. You'll have to configure the command-line client with your exercism API key before you can submit.
exercism submit PATH_TO_FILE
Exercism will only download a test file. You will need to manually create the header and the source file associated with the exercise. You will need to generate an Xcode Project file with the test file, the header file (.h) and the source file (.m). Alternatively, you can use a test runner utility that's described below.
Tests will be run through Xcode.
Note: If you receive the error "No visible @interface
for ExerciseName declares the selector ExerciseSelector," you followed the steps correctly, but haven't written anything in your header/implementation file(s). After you declare your method in the .h file and define it in the .m file, your tests should raise more helpful errors that will lead you towards completing the exercise. Read this primer on Objective-C Classes for more in-depth information.
An alternative to manually generating the project file is to use a test runner utility written in ruby, objc, that will create a project file for you with the test file, header file and source file.
$ gem install objc
Run the tests with
$ objc -x ExerciseName
(Note the -x
/--xcodebuild
flag, which specifies using xcodebuild
instead of xctool
. The latter does not work with Xcode's latest releases.)
The objc
utility uses the exercise name to find the test file, ExerciseNameTest.m, the header file, ExerciseName.h and source file ExerciseName.m. The files are inserted into a temporary Xcode Project and then xcodebuild is used to run the tests for the project.
While objc
makes it so you never have to launch Xcode to complete these exercises, the error messages and feedback through the command-line are not as clear as through the Xcode user interface.
The xcode project uses OCLint.