A job portal is a good last project because it joins list screens, filtering, forms, file handling and backend calls. It is also close to the purpose of this website. The app has two main screens: a searchable, filterable list of jobs, and a detail screen where the user attaches a resume and applies.
The app can run with no backend, using FakeJobService and three sample jobs. When you have a backend, switch to RemoteJobService, which expects GET /jobs to return a JSON list and POST /jobs/{id}/apply to accept a multipart form with a cover note and a file. Sign-in is left out to keep the lesson focused. A real portal would add it with the secure networking pattern from the advanced course and send a token with each request.
Concepts in this project
- Filtering with a pure function:
[Job].filtered(by:)combines text, remote-only and job types, so it is easy to test. - A derived list:
shownis calculated from the loaded jobs and the filter, so they can never disagree. - Toggle buttons as chips:
Toggle(...).toggleStyle(.button), with a custom Binding for a set of types. - fileImporter: the system file picker. It needs no storage permission and gives access only to the chosen file.
- Security-scoped URLs: call
startAccessingSecurityScopedResourcebefore reading a picked file, and stop afterwards. - Multipart upload: a text part and a file part joined with a boundary.
Create the project
- In Xcode choose File > New > Project > iOS > App. Set Interface to SwiftUI, Language to Swift, and Testing System to Swift Testing. Set the minimum deployment to iOS 17, because the code uses @Observable. Name the product JobPortal.
- Delete the default ContentView.swift and the default @main file, then add the files below.
JobPortal/
JobsApp.swift @main
Job.swift model, filter, sample data
ResumeRules.swift file checks, mime type, multipart body
JobService.swift protocol, remote and fake services
JobViewModel.swift state, filter, apply
JobViews.swift list with chips, detail with upload
JobPortalTests/
JobsTests.swift
The code
`Job.swift`
import Foundation
enum JobType: String, Codable, CaseIterable, Identifiable {
case fullTime = "Full-time"
case internship = "Internship"
case contract = "Contract"
var id: String { rawValue }
}
struct Job: Identifiable, Codable, Hashable {
let id: Int
let title: String
let company: String
let location: String
let remote: Bool
let type: JobType
let description: String
}
struct JobFilter: Equatable {
var text = ""
var remoteOnly = false
var types: Set<JobType> = []
}
extension Array where Element == Job {
// A pure function: easy to test and the screen can never disagree with the filter.
func filtered(by filter: JobFilter) -> [Job] {
let needle = filter.text.trimmingCharacters(in: .whitespaces).lowercased()
return self.filter { job in
if filter.remoteOnly && !job.remote { return false }
if !filter.types.isEmpty && !filter.types.contains(job.type) { return false }
if needle.isEmpty { return true }
return job.title.lowercased().contains(needle)
|| job.company.lowercased().contains(needle)
|| job.location.lowercased().contains(needle)
}
}
}
enum SampleJobs {
static let all: [Job] = [
Job(id: 1, title: "iOS Developer", company: "Bright Apps", location: "Pune", remote: false,
type: .fullTime, description: "Build SwiftUI features for a consumer app."),
Job(id: 2, title: "Swift Intern", company: "Nimbus Labs", location: "Remote", remote: true,
type: .internship, description: "Learn on the job with a small mobile team."),
Job(id: 3, title: "Kotlin Android Developer", company: "Bright Apps", location: "Pune", remote: true,
type: .contract, description: "Six month contract for a Kotlin and Compose app.")
]
}
`ResumeRules.swift`
import Foundation
import UniformTypeIdentifiers
enum ResumeRules {
static let maxBytes = 5 * 1024 * 1024
static let allowedExtensions: Set<String> = ["pdf", "doc", "docx"]
// Returns a message for the user, or nil when the file is fine.
// The server must check again: anyone can skip this app and call the server directly.
static func problem(fileName: String, sizeBytes: Int) -> String? {
let ext = (fileName as NSString).pathExtension.lowercased()
if !allowedExtensions.contains(ext) { return "Choose a PDF or Word file." }
if sizeBytes <= 0 { return "That file is empty." }
if sizeBytes > maxBytes { return "The file is over 5 MB." }
return nil
}
static let contentTypes: [UTType] = [
.pdf,
UTType(filenameExtension: "doc") ?? .data,
UTType(filenameExtension: "docx") ?? .data
]
static func mimeType(for fileName: String) -> String {
switch (fileName as NSString).pathExtension.lowercased() {
case "pdf": return "application/pdf"
case "doc": return "application/msword"
case "docx": return "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
default: return "application/octet-stream"
}
}
}
enum Multipart {
// Builds the body of a multipart/form-data request: a text part and a file part.
static func body(boundary: String, note: String, fileName: String, mime: String, fileData: Data) -> Data {
var body = Data()
func add(_ text: String) { body.append(Data(text.utf8)) }
add("--\(boundary)\r\n")
add("Content-Disposition: form-data; name=\"note\"\r\n\r\n")
add("\(note)\r\n")
add("--\(boundary)\r\n")
add("Content-Disposition: form-data; name=\"resume\"; filename=\"\(fileName)\"\r\n")
add("Content-Type: \(mime)\r\n\r\n")
body.append(fileData)
add("\r\n--\(boundary)--\r\n")
return body
}
}
`JobService.swift`
import Foundation
protocol JobService {
func jobs() async throws -> [Job]
func apply(to job: Job, note: String, fileName: String, fileData: Data) async throws
}
// Talks to YOUR backend. Contract: GET {base}/jobs returns a JSON array of jobs,
// POST {base}/jobs/{id}/apply accepts multipart form data with "note" and "resume".
struct RemoteJobService: JobService {
let baseURL: URL
func jobs() async throws -> [Job] {
let (data, response) = try await URLSession.shared.data(from: baseURL.appendingPathComponent("jobs"))
try Self.check(response)
return try JSONDecoder().decode([Job].self, from: data)
}
func apply(to job: Job, note: String, fileName: String, fileData: Data) async throws {
let boundary = "Boundary-\(UUID().uuidString)"
var request = URLRequest(url: baseURL.appendingPathComponent("jobs/\(job.id)/apply"))
request.httpMethod = "POST"
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
request.httpBody = Multipart.body(boundary: boundary, note: note, fileName: fileName,
mime: ResumeRules.mimeType(for: fileName), fileData: fileData)
let (_, response) = try await URLSession.shared.data(for: request)
try Self.check(response)
}
private static func check(_ response: URLResponse) throws {
if let http = response as? HTTPURLResponse, !(200..<300).contains(http.statusCode) {
throw URLError(.badServerResponse)
}
}
}
// Sample data so the whole app runs with no backend.
struct FakeJobService: JobService {
func jobs() async throws -> [Job] { SampleJobs.all }
func apply(to job: Job, note: String, fileName: String, fileData: Data) async throws {
try await Task.sleep(for: .milliseconds(600))
}
}
`JobViewModel.swift`
import Foundation
import Observation
@Observable
@MainActor
final class JobViewModel {
enum State {
case loading
case ready([Job])
case failed
}
private(set) var state: State = .loading
var filter = JobFilter()
private let service: JobService
init(service: JobService) {
self.service = service
}
// Calculated from the full list and the filter, so the two cannot disagree.
var shown: [Job] {
if case .ready(let all) = state { return all.filtered(by: filter) }
return []
}
func load() async {
state = .loading
do {
state = .ready(try await service.jobs())
} catch {
state = .failed
}
}
// Returns a message to show, or nil on success.
func apply(to job: Job, note: String, fileURL: URL) async -> String? {
let accessing = fileURL.startAccessingSecurityScopedResource()
defer { if accessing { fileURL.stopAccessingSecurityScopedResource() } }
let values = try? fileURL.resourceValues(forKeys: [.fileSizeKey])
let size = values?.fileSize ?? 0
if let problem = ResumeRules.problem(fileName: fileURL.lastPathComponent, sizeBytes: size) {
return problem
}
do {
let data = try Data(contentsOf: fileURL)
try await service.apply(to: job, note: note, fileName: fileURL.lastPathComponent, fileData: data)
return nil
} catch {
return "Could not send your application. Please try again."
}
}
}
`JobViews.swift`
import SwiftUI
struct JobListView: View {
@State private var model: JobViewModel
init(service: JobService) {
_model = State(initialValue: JobViewModel(service: service))
}
var body: some View {
NavigationStack {
Group {
switch model.state {
case .loading:
ProgressView("Loading jobs...")
case .failed:
VStack(spacing: 12) {
Text("Could not load jobs.")
Button("Try again") { Task { await model.load() } }
.buttonStyle(.borderedProminent)
}
case .ready:
list
}
}
.navigationTitle("Jobs")
.searchable(text: $model.filter.text, prompt: "Title, company or place")
.navigationDestination(for: Job.self) { JobDetailView(job: $0, model: model) }
}
.task { await model.load() }
}
private var list: some View {
List {
Section {
ScrollView(.horizontal, showsIndicators: false) {
HStack {
Toggle("Remote", isOn: $model.filter.remoteOnly)
.toggleStyle(.button)
ForEach(JobType.allCases) { type in
Toggle(type.rawValue, isOn: binding(for: type))
.toggleStyle(.button)
}
}
}
}
Section {
if model.shown.isEmpty {
Text("No jobs match your search.").foregroundStyle(.secondary)
}
ForEach(model.shown) { job in
NavigationLink(value: job) {
VStack(alignment: .leading, spacing: 2) {
Text(job.title).font(.headline)
Text("\(job.company) · \(job.location)").font(.subheadline)
Text(job.type.rawValue + (job.remote ? " · Remote" : ""))
.font(.caption).foregroundStyle(.secondary)
}
}
}
}
}
}
private func binding(for type: JobType) -> Binding<Bool> {
Binding(
get: { model.filter.types.contains(type) },
set: { isOn in
if isOn { model.filter.types.insert(type) } else { model.filter.types.remove(type) }
}
)
}
}
struct JobDetailView: View {
let job: Job
let model: JobViewModel
@State private var note = ""
@State private var pickedFile: URL?
@State private var showPicker = false
@State private var sending = false
@State private var message: String?
var body: some View {
Form {
Section("About the job") {
Text(job.description)
}
Section("Your application") {
TextField("Short cover note", text: $note, axis: .vertical)
.lineLimit(2...5)
Button(pickedFile?.lastPathComponent ?? "Choose resume") { showPicker = true }
Button(sending ? "Sending..." : "Apply") {
guard let file = pickedFile else { return }
Task {
sending = true
message = await model.apply(to: job, note: note, fileURL: file) ?? "Application sent"
sending = false
}
}
.disabled(pickedFile == nil || sending)
if let message {
Text(message).font(.callout)
}
}
}
.navigationTitle(job.title)
.fileImporter(isPresented: $showPicker, allowedContentTypes: ResumeRules.contentTypes) { result in
if case .success(let url) = result { pickedFile = url }
}
}
}
`JobsApp.swift`
import SwiftUI
@main
struct JobsApp: App {
var body: some Scene {
WindowGroup {
// FakeJobService runs with no backend. Use RemoteJobService(baseURL:) for your own server.
JobListView(service: FakeJobService())
}
}
}
`JobsTests.swift (in the tests target)`
import Testing
import Foundation
@testable import JobPortal
struct JobsTests {
private let jobs = SampleJobs.all
@Test func textSearchMatchesTitleCompanyOrPlace() {
#expect(jobs.filtered(by: JobFilter(text: "kotlin")).map(\.id) == [3])
#expect(jobs.filtered(by: JobFilter(text: "bright")).count == 2)
#expect(jobs.filtered(by: JobFilter(text: "pune")).count == 2)
}
@Test func filtersCombine() {
let filter = JobFilter(text: "", remoteOnly: true, types: [.contract])
#expect(jobs.filtered(by: filter).map(\.id) == [3])
}
@Test func emptyFilterShowsEverything() {
#expect(jobs.filtered(by: JobFilter()).count == jobs.count)
}
@Test func resumeRules() {
#expect(ResumeRules.problem(fileName: "cv.png", sizeBytes: 1000) == "Choose a PDF or Word file.")
#expect(ResumeRules.problem(fileName: "cv.pdf", sizeBytes: 0) == "That file is empty.")
#expect(ResumeRules.problem(fileName: "cv.pdf", sizeBytes: 6 * 1024 * 1024) == "The file is over 5 MB.")
#expect(ResumeRules.problem(fileName: "CV.PDF", sizeBytes: 200_000) == nil)
}
@Test func multipartContainsBothParts() {
let body = Multipart.body(boundary: "XYZ", note: "Hello", fileName: "cv.pdf",
mime: "application/pdf", fileData: Data("DATA".utf8))
let text = String(decoding: body, as: UTF8.self)
#expect(text.contains("name=\"note\""))
#expect(text.contains("filename=\"cv.pdf\""))
#expect(text.hasSuffix("--XYZ--\r\n"))
}
}
Walkthrough
Job is Codable and Hashable, so it can be decoded from the server and used as a navigation value. JobFilter is a small struct with the search text, a remote-only switch and a set of types. The extension on Array where Element == Job adds filtered(by:). Each rule returns early when a job does not match: remote-only fails a non-remote job, a non-empty type set fails a job of another type, and the search text must appear in the title, company or location.
ResumeRules.problem returns a message in plain words or nil. It checks the extension against pdf, doc and docx, rejects empty files and rejects files over 5 MB. These checks give fast feedback, but they are not security. Anyone can send any request to your server without using your app, so the server must check the type, size and content again.
Multipart.body builds the request body by hand. Each part starts with the boundary, then headers, a blank line and the content. The file part includes its file name and content type. The last line is the boundary followed by two dashes. Writing it once helps you understand what upload libraries do for you.
JobViewModel.apply is where the picked file is handled. The URL from fileImporter points outside your app, so the code calls startAccessingSecurityScopedResource, and defer makes sure stop is called however the function ends. It reads the size, applies the rules, reads the data and calls the service. It returns a message instead of throwing, so the view can show it directly.
In the list view, the chips are Toggle views with the button style. The remote switch binds directly to the filter. For the job types, a small binding(for:) function builds a Binding that inserts or removes a type in the set. The detail view disables Apply until a file is picked and while sending, which prevents double submits.
How it works
- The list loads jobs from the service and shows those that match the filter.
- Opening a job shows its description, a cover note field and a resume picker.
- Before upload the view model checks the file type and size and reads the file safely.
- A multipart request sends the note and file. The server validates again and stores the application.
Expected output
The list shows a search field, chips for Remote, Full-time, Internship and Contract, and a row for each job with the title, company and place. Type "kotlin": only the Kotlin job remains. Clear it and turn on Remote and Contract: only jobs that are both remain. Open a job: you see the description, a note box, Choose resume and Apply. Choose a PNG: pressing Apply shows "Choose a PDF or Word file." Choose a PDF under 5 MB: Apply shows "Application sent". With RemoteJobService and no backend, the list shows "Could not load jobs." with a Try again button. The five tests pass.
Your task
- Build the app with the fake service and test the filters.
- Write a small backend or a mock server that matches the contract.
- Add sign-in and send a token with each request.
- Save jobs for later with SwiftData and add a Saved tab.
How to check it worked
- Filters combine correctly.
- Wrong file types and big files are refused before upload.
- You can explain why the server must validate the resume again.
Next, try the same idea on another platform with the Android Development with Kotlin course, or go deeper on iOS with the Advanced iOS Development course.