Creating and Distributing iOS Frameworks

I am getting these errors (and more) when I run pod spec lint at the end. It appears as though it doesn’t recognize Swift 3?

→ ThreeRingControl (1.0.0)
- ERROR | xcodebuild: ThreeRingControl/ThreeRingControl/CircularGradient.swift:29:3: error: expected declaration
- ERROR | xcodebuild: ThreeRingControl/ThreeRingControl/CircularGradient.swift:29:14: error: consecutive declarations on a line must be separated by ‘;’

SOLVED:
This will solve it. Create a file called .swift-version with just one line:

3.0

and place it at:

/Phonercise/repo/ThreeRingControl/.swift-version

Really awesome tutorial, thanks!
Here are three typos/suggestions for improvement:

Change from this:

You just added an entry for the framework in both Embedded Binaries and Linked Frameworks and Binaries.

To this:

You just added an entry for the framework in both Embedded Binaries and Linked Frameworks and Libraries.

Change from this:

To restore functionality to the app, you have to update the access control on two Phonercise classes.

To this:

To restore functionality to the app, you have to update the access control on two ThreeRingControl classes.

Change from this:

  1. Select ThreeRingControl.xcodeproj in the project navigator and delete it.
  1. Choose Remove Reference in the confirmation dialog, since you’ll need to keep the files on disk to create the pod.

To this:

Select ThreeRingControl.xcodeproj in the project navigator and delete it, BUT ONLY REMOVE REFERENCE (since you’ll need to keep the files on disk to create the pod.)

Hello! The big issue I’m facing here is that I’m not able to add the framework to the sample app as a bunch of files. It only adds the xcodeproj file and that’s about it. I can’t see the dropdown of framework files to edit it and develop both.

Do you still have that project open in another Xcode window? It only lets you edit a project in one place at a time.

My framework depends on a cocoapod (AlamofireImage). At the step where I’ve included the framework inside the other project, I am getting an error that it can’t find AlamofireImage. How do I solve that?

2 Likes

@mkatz I am getting lot of errors related to Swift 3.0 when i try to build the ThreeRingsControl framework. Is there any updated code which supports Phonercise Starter project. In GitHub also its updated 10 months back.

@subinrevi Be sure to use the download links and text within the tutorial itself. These have been updated to swift3. There is no official github hosting of this tutorial, so any links you found are not likely to be kept up to date (even my own copy).

Hi. Very nice tutorial. I did it with my own frameworks and project.
Unfortunately I am stuck with this error ‘No such module’ while importing the classes of the framework.
How can I get rid of this?

@tfx - I was getting the same ‘No such module’ error. I had placed the ‘public’ keyword in front of @IBInspectable instead of in front of the var below. Once I changed this, it worked. Hope this helps.

I have a question when I build my framework project with Cocoapods.

in this tutorial it mentioned

cd ThreeRingControl/
git add .
git commit -m "initial commit"
git push

And when I build the framework, it had a dependency to OpenCV framework.

Can I extrude the openCV framework from the git repo? or should I include it?

@oaleeapp
There is endless debate around the internet whether to check your pods or dependancies into git or not. If you check it in, then you’ll have a stable record of the framework, can be assured you’ll always be able to build, and be able to access it if you pull the repo onto another a machine. The downside is that when you update the framework it adds churn to your git logs and potential merge conflicts, and increases the size of your repo download, which can increase bandwidth usage and time to get your code changes.

I want to use “ThreeRingControl.framework” on another project, without pods, and without adding ThreeRingControl as a sub-project. It didn’t work for me. This is what I did:

  1. In settings for ThreeRingControl, set “Skip Install” to “NO”
  2. From the Product menu, I selected Archive
  3. Organizer pops up when it’s done, and I export the archive.
  4. In the archive, I find “ThreeRingControl.framework”, and drag/drop it into another swift project into “Linked Frameworks and Libraries” (select “Copy items if needed”)
  5. I can now “import ThreeRingControl” at top of a class in my new project, but if I try to use any of the classes from ThreeRingControl, they’re not found. I get the error: “ThreeRingView is unavailable. cannot find Swift declaration for this class”

Were you able to find an answer to this question of yours? I am having the same issue.

Thanks for this nice intro, very useful. I have just question: When we create a new “Cocoa Touch Framework” projet a file “*.h” is created. What this for ?
Thanks un advanced.

The .h is a header file that is imported when you do @import YourFramework or <YourFramework/YourFramework.h>. You can add additional imports, such as other frameworks or header files if you include public Objective-C files.

EDIT – Nevermind Fixed!

Hello,
First I just want to say I have thanks for this tutorial.
I’m having trouble doing ‘pod install’ on the on the app
after creating and modifying the podspec. The terminal returns
the following 


[!] The ThreeRingControl pod failed to validate due to 1 error.
[!] The validator for Swift projects uses Swift 3.0 by default, if you are using a different version of swift you can use a .swift-version file to set the version for your Pod. For example to use Swift 2.3, run:
echo “2.3” > .swift-version:

Can you please advise how to correct the swift version? I know someone mentioned a .swift-Version file. Is that supposed to go into the same directory as the frameworks source files?
Thanks!

Thanks for the great tutorial.
My One simple question is that how we will manage to make updates in already published pod? Any good process? because we will not edit the Pod files directly.

Like ThreeRingControl, if i want to make some changes and publish it and update the pod where its actually using.

Yes, put it in the same directory as the sources/podspec.

What you would do is copy the podspec to another directory, and update the version number and the git tag in the podspec to the appropriate commit.

If you were publishing the spec to the public spec repo, it would look like this:

/Specs

/ThreeRingControl

/1.0.0/ThreeRingControl.podspec

/1.1.0/ThreeRingControl.podspec

and so on for each new version.

1 Like

How to Add how to add bridging header / Umbrella header in Framework ?