0Pricing
Objective-C iOS Development for Legacy & Enterprise Apps · 강의

Objective-C 프레임워크 만들기

Objective-C와 Swift 프로젝트 모두에서 사용할 수 있는 Objective-C 프레임워크를 개발하고 연동합니다.

Objective-C 프레임워크 만들기은(는) CoddyKit의 무료 Objective-C iOS Development for Legacy & Enterprise Apps 강의입니다. 이것은 4개 중 3번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Objective-C iOS Development for Legacy & Enterprise Apps 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Objective-C iOS Development for Legacy & Enterprise Apps 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

What are Frameworks?

Welcome! Today, we'll dive into Objective-C frameworks. Think of a framework as a self-contained bundle of code and resources.

  • They package reusable code, like classes and functions.
  • They can also include assets, such as images or localized strings.
  • Frameworks promote modularity, making it easier to reuse code across multiple projects or distribute to others.

They are essential for building complex apps and sharing components.

Framework vs. Libraries

You might have heard of static or dynamic libraries. How do frameworks differ?

  • Libraries (.a, .dylib) contain only compiled code.
  • Frameworks (.framework) are a directory structure bundling code, headers, resources, and even other frameworks.
  • This self-contained nature simplifies distribution and integration into projects.

On iOS, frameworks are the preferred way to package and share reusable components.

Creating a New Framework

Let's create our first Objective-C framework in Xcode:

  1. Go to File > New > Project...
  2. Select the iOS > Framework & Library template.
  3. Choose Framework and click Next.
  4. Give it a name, e.g., MyUtilityFramework.
  5. Ensure Language is Objective-C.

Xcode will set up a new project tailored for framework development.

Framework Project Structure

After creating your framework, you'll see a structure like this:

  • Public Headers: These headers define the API of your framework. Any classes or methods declared here will be visible to apps using your framework.
  • Private Headers: For internal use only within the framework.
  • Project Headers: Headers used during framework development, not exposed.
  • Umbrella Header: A main header file (e.g., MyUtilityFramework.h) that imports all public headers. This is the single header an app usually imports.

Exposing Framework Classes

To make a class visible outside your framework, its header file must be placed in the 'Public' section of the 'Build Phases > Headers' settings. Let's create a simple Greeter class:

// Greeter.h
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface Greeter : NSObject

- (NSString *)sayHelloTo:(NSString *)name;

@end

NS_ASSUME_NONNULL_END

// Greeter.m
#import "Greeter.h"

@implementation Greeter

- (NSString *)sayHelloTo:(NSString *)name {
    return [NSString stringWithFormat:@"Hello, %@!", name];
}

@end

The Umbrella Header

For users to easily import your framework's public classes, you'll usually import them all into the framework's main umbrella header. This header usually has the same name as your framework (e.g., MyUtilityFramework.h).

Make sure MyUtilityFramework.h includes #import to expose our Greeter class.

// MyUtilityFramework.h (the umbrella header)

#import <Foundation/Foundation.h>

//! Project version number for MyUtilityFramework.
FOUNDATION_EXPORT double MyUtilityFrameworkVersionNumber;

//! Project version string for MyUtilityFramework.
FOUNDATION_EXPORT const unsigned char MyUtilityFrameworkVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <MyUtilityFramework/PublicHeader.h>

#import <MyUtilityFramework/Greeter.h>

Integrating into Objective-C App

Once your framework is built, you can drag the .framework bundle into an Objective-C project, then embed it in 'General > Frameworks, Libraries, and Embedded Content'.

Then, simply import the umbrella header and use your classes!

// main.m (in an Objective-C app)
#import <Foundation/Foundation.h>
#import <MyUtilityFramework/MyUtilityFramework.h>

int main(int argc, const char * argv[]) {
  @autoreleasepool {
    Greeter *myGreeter = [[Greeter alloc] init];
    NSString *greeting = [myGreeter sayHelloTo:@"CoddyKit User"];
    NSLog(@"%@", greeting);
  }
  return 0;
}

Integrating into Swift App

A major advantage of frameworks is their direct interoperability with Swift. Unlike individual Objective-C files, frameworks do not require a bridging header when used in Swift!

After embedding the framework in your Swift project (same steps as Objective-C), you just import it directly.

Using Framework in Swift

Once imported, you can instantiate and call methods on your Objective-C framework classes directly from Swift code. Xcode automatically generates Swift interfaces for your Objective-C types.

Try running this Swift example!

// main.swift (in a Swift app)
import Foundation
import MyUtilityFramework // Direct import of the framework

let myGreeter = Greeter()
let greeting = myGreeter.sayHello(to: "Swift Learner")
print(greeting)

Frameworks Quick Check

You've learned how to create and use Objective-C frameworks in both Objective-C and Swift projects. Let's test your understanding!

Recap: Objective-C Frameworks

Great job! In this lesson, you've learned:

  • What frameworks are: Self-contained bundles for code and resources.
  • How to create one: Using Xcode's framework template.
  • Structure: Understanding public, private, and umbrella headers.
  • Integration: How to embed and use Objective-C frameworks in both Objective-C and Swift applications.

Frameworks are powerful tools for code reuse and modularity, especially in enterprise environments. Keep building!

자주 묻는 질문

“Objective-C 프레임워크 만들기” 강의는 무료인가요?

네 — “Objective-C 프레임워크 만들기” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Objective-C iOS Development for Legacy & Enterprise Apps 강의 전체를 잠금 해제할 수 있습니다. Objective-C iOS Development for Legacy & Enterprise Apps 강의에는 총 4개의 강의가 포함되어 있습니다.

“Objective-C 프레임워크 만들기”에서 뭘 배우나요?

Objective-C와 Swift 프로젝트 모두에서 사용할 수 있는 Objective-C 프레임워크를 개발하고 연동합니다. 브라우저에서 직접 실행하는 실습 코드로 Objective-C iOS Development for Legacy & Enterprise Apps을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Objective-C iOS Development for Legacy & Enterprise Apps을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Objective-C iOS Development for Legacy & Enterprise Apps은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 3번째 강의입니다.

“Objective-C 프레임워크 만들기” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Objective-C iOS Development for Legacy & Enterprise Apps 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Objective-C iOS Development for Legacy & Enterprise Apps 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. Objective-C와 Swift 연결
  2. Swift와 Objective-C 연결
  3. Objective-C 프레임워크 만들기
  4. 브리지 간 널 허용 여부와 타입 매핑 처리
← Objective-C iOS Development for Legacy & Enterprise Apps(으)로 돌아가기