How to build an iOS infrastructure with XCode 6

I know familiar tutorials about this, but the introduction of the XCode 6 framework pattern changed the game.

I've already watched the WWDC 2014 video about building modern frameworks, but it talks more about building extensions, frameworks, and applications within a single project. It doesn't indicate if the wireframe I'm making with it is really reusable for any project.

I am building an XCode 6 framework (File-> New Project-> Framework and Library -> Cocoa Touch Framework), but when I import it into a test application project (separate from the framework project), I keep getting various errors.

Example: Include a non-modular header within a frame, etc.

I know this is not what he says and there are some missing steps in everything I do. the old tricks might have worked for everyone, but I just can't seem to find which way to follow after XCode 6.

For example, there is some folder structure that the framework needs, but Xcode 6 doesn't match when it is created. It is right? If not, how can I change the way the Xcode framework folder hierarchy is created?

Am I going back to the old school, or am I introducing some tiny thing in XCode 6 that I can't create a reusable structure?

+3


source to share


1 answer


I'm not sure if you are trying to build a framework with Objective-C or Swift, as your question does not specify it. I ran into the errors you mention with Swift, so I will give you my method for creating Swift frameworks.

I found the process for Objective-C to be very simple and well documented, so I'll skip this.

As for Swift, there are several things to consider. Firstly, Swift static libraries are not supported, so when linking your application to the library, you must use a framework (or dynamic library).



Here are the steps:

  • Build Framework with New> Project in IOS> Framework and Library, select Cocoa Touch Framework

  • To avoid "ld: warning: directory not found for parameter ...", go to the library search paths in the build settings for your target and remove the paths.

  • You can't mix Objective-C with Swift, so don't even consider adding a Swift-Header bridge file to your code.

  • There are some cases in swift where you need to import code from unexposed frameworks. I have successfully used a map module within a framework to handle this case.

  • I also select CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES in the build settings to resolve "enable non-modular header inside frame module". It seems to work

  • I'm pretty sure the header file that is being generated is marked as Public (not Project). Click on the file and you will see a selection in the inspector under "Target Membership"

Some bizarre error messages may appear on creation. Xcode tends to report linker errors when your code cannot compile correctly, resulting in no files that the linker needs to output from its binaries. Sometimes Xcode won't display errors in the files you compile and you need to manually navigate to build output and revert to files. Another time you will run into a problem when you need to delete the cache. I call these problems the Xcode blues and I do it all the time. I have found that problems like this occur more often when building libraries. The rest should work as expected.

+2


source







All Articles