itinance
itinance

Reputation: 12388

How to use Cocoa Touch Frameworks in an App Project

I am familiar building single iOS Apps, but i stuck on sharing common code to multiple apps with a Cocoa Touch Framework.

The Problem:

The Header-Files of the Framework are not visible/not linkable to the consuming App Project.

What i did:

1. I created a Project "Cocoa Touch Framework" called "libTestFramework"

2. I created a Single View Application called "FrameworkTester"

3. in the App Project:

What did i misunderstood?

I created a public github-Repository containing both projects to reproduce: https://github.com/itinance/testCocoaTouchFramework

Some Screenshots following:

enter image description here

enter image description here

enter image description here

Upvotes: 2

Views: 948

Answers (1)

Bodey Baker
Bodey Baker

Reputation: 306

I had the same problem. I don't know how to resolve your problem from your current situation but I do know how to do it from a new project. After following the steps below you could add your code until you get the working system you wanted. If you put the project into a git repository first, you could get it working and then do a diff to see what you were doing wrong. I'd be curious to see that too.

Wokring:

  1. Create a Single View Application called "FrameworkTester"
  2. Click File -> Add -> Target...
  3. Create "Cocoa Touch Framework" called "libTestFramework"
  4. Add required header and source to framework (start with something small)
  5. Add public headers to libTestFramework.h
  6. Go to configuration, select "libTestFramework" and Build Phases

    • Ensure your source is in Compile Sources
    • Ensure used headers are in Headers Public
  7. Put an obvious reference to the framework somewhere in "FrameworkTester"
  8. Run to test.

I'm writing this mostly from memory. If I've missed something then the article iOS 8 Extensions: Sharing Code with an Embedded Framework on A Tiny Fish will probably have what you need. And here are a list of mistakes you can make

Upvotes: 1

Related Questions