Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an iOS Framework using Xcode 5

How can I create a Framework for iOS, using Xcode 5? I previously used (before Xcode 5) a GitHub project that let me create a Fake Framework. In Xcode 5 it seems that it doesn't work anymore. Any suggestions?

UPDATE: To be clear I'm adding static libraries/frameworks to my framework project AND I want them linked into the produced framework. So I cannot just use the static library template.

like image 685
Idan Avatar asked Sep 22 '13 16:09

Idan


People also ask

How do I create a framework in Swift 5?

In the app, select the project from the project navigator, select the Stocktance target, and scroll to Frameworks, Libraries, and Embedded Content. Click on the plus button, click Add Other… and select Add Files… Navigate to the SettingsKit folder and select it. We've added the framework to the project.

How do I create a new framework in Xcode?

In Xcode, select File ▸ New ▸ Project…. Then choose iOS ▸ Framework & Library ▸ Framework. Click Next.

How do you create a framework on a Mac?

Creating Your Framework. From Xcode, choose File > New Project to create your project. Follow the prompts to select the type of framework you want and where you want to put your project directory. The default templates that come with Xcode let you specify whether you want to create a Carbon or Cocoa framework.


2 Answers

This approach works very well:

https://github.com/jverkoey/iOS-Framework#walkthrough

And you can use with CocoaPods (http://cocoapods.org/) with this simple fix: https://github.com/jverkoey/iOS-Framework/issues/46

Just change the xcodebuild line in the Framework target run script:

# Build the other platform.
xcodebuild ONLY_ACTIVE_ARCH=NO -workspace "${PROJECT_DIR}/${PROJECT_NAME}.xcworkspace" -scheme "${TARGET_NAME}" -configuration "${CONFIGURATION}" -sdk ${SF_OTHER_PLATFORM}${SF_SDK_VERSION} BUILD_DIR="${BUILD_DIR}" OBJROOT="${OBJROOT}" BUILD_ROOT="${BUILD_ROOT}" SYMROOT="${SYMROOT}" $ACTION
like image 59
Renato Silva Das Neves Avatar answered Oct 07 '22 00:10

Renato Silva Das Neves


Creating a framework is not hard, you are probably taking the long way using the template. Follow this steps:

  1. Mehfuz's Creating Universal IOS Framework
  2. Cocoanetics Making Your Own iPhone Frameworks. In Xcode.
  3. Hector Zhao's How to build custom iOS framework with Xcode

The script on the third Blog will give you the structure that Apple recommends, but all of them are great. I managed to build one framework using cocoa pods by setting a preprocessor macro COCOAPODS=1 and adding a user defined config setting PODS_ROOT : "${SRCROOT}/Pods". All of this on the settings of your bundle. You can also try setting the info tab of your Xcode project, under Configurations, to use Pods as your configuration file, but it may give you duplicate symbols, not sure.

like image 24
GianPac Avatar answered Oct 06 '22 22:10

GianPac