CocoaPods를 사용하는 실제 예제

Important

sharpie pod는 이제 사용되지 않습니다. 자세한 내용은 GitHub 이슈를 참조하세요.

버전 3.0의 새로운 기능인 Objective Sharpie는 CocoaPod 바인딩을 지원하며, CocoaPod를 매우 쉽게 다운로드, 구성 및 빌드할 수 있도록 하는 명령(sharpie pod)도 포함합니다. 이 기능을 사용하기 전에 일반적으로 CocoaPods를 숙지해야 합니다.

CocoaPod에 대한 바인딩 만들기

sharpie pod 명령에는 전역 옵션 1개와 하위 명령 2개가 있습니다.

$ sharpie pod -help
usage: sharpie pod [OPTIONS] COMMAND [COMMAND_OPTIONS]

Pod Options:
  -d, -dir DIR     Use DIR as the CocoaPods binding directory,
                   defaulting to the current directory

Available Commands:
  init         Initialize a new Xamarin C# CocoaPods binding project
  bind         Bind an existing Xamarin C# CocoaPods project

init 하위 명령에도 몇 가지 유용한 도움말이 있습니다.

$ sharpie pod init -help
usage: sharpie pod init [INIT_OPTIONS] TARGET_SDK POD_SPEC_NAMES

Init Options:
  -f, -force       Initialize a new Podfile and run actions against
                   it even if one already exists

여러 CocoaPod 이름 및 하위 지정 이름을 제공할 init수 있습니다.

$ sharpie pod init ios AFNetworking
** Setting up CocoaPods master repo ...
   (this may take a while the first time)
** Searching for requested CocoaPods ...
** Working directory:
**   - Writing Podfile ...
**   - Installing CocoaPods ...
**     (running `pod install --no-integrate --no-repo-update`)
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (2.6.0)
Generating Pods project
Sending stats
** 🍻 Success! You can now use other `sharpie podn`  commands.

CocoaPod가 설정되면 이제 바인딩을 만들 수 있습니다.

$ sharpie pod bind

이렇게 하면 CocoaPod Xcode 프로젝트가 빌드된 다음 Objective Sharpie에서 평가 및 구문 분석됩니다. 많은 콘솔 출력이 생성되지만 마지막에 바인딩 정의가 생성됩니다.

(... lots of build output ...)

Parsing 19 header files...

Binding...
  [write] ApiDefinitions.cs
  [write] StructsAndEnums.cs

Done.

다음 단계

ApiDefinitions.cs 및 StructsAndEnums.cs 파일을 생성한 후 다음 설명서를 살펴보고 앱에서 사용할 어셈블리를 생성합니다.