Module of distributed Framework not found in InterfaceBuilder - ios

before Xcode 7, I were able to build a Framework for (development) distribution for both device and simulator (usually as a fat-binary) and include it into any of my projects. When I now try to build and integrate the Framework I still can see my classes and the Framework-Module and use both in my code, but when I try to reference them from within my Storyboard, they are no longer visible.
Correct me if I am wrong - I've been working with Frameworks since swift was released, but my memories might deceive me here - but I remember being able to use classes from a Framework and reference them in an InterfaceBuilder-file in the previous versions. Referencing a framework-class is no problem when the Framework-target is build from within the same Project.
To test this, I simply set up a Framework-Project and added a custom UIViewController. Then I've build the Framework and imported it into another SingleView-Application. I already checked if there is a possible setting preventing the Framework-module from being visible (BitCode, SDK, Deployment Target) and configured the ViewController as public.
Maybe I'm just missing some new setting Apple introduced in Xcode 7 ;-)

Related

Why is code in that is only supposed to be accessible to one target failing to compile for a different target?

I'm having a weird issue. I'm trying to merge two projects (one iOS and one tvOS, both with a mix of objective-c and Swift) into a new single xcode project so that going forward they can share code.
I created a new project, created an iOS target and tvOS target, and brought all of the iOS code over, pretty quickly it was compiling fine for the iOS target. When bringing all of the code from the previous iOS project over I set all of the files to only be accessible to the iOS target.
Then I did the same with the tvOS code, once again only setting the files to be accessible to the tvOS target.
So because both of these code bases are very similar there are a lot of duplicated classes, but that over time have slightly diverged. Eventually my goal is to unify these, but for now I just need to get all the code in the same place. So I have classes with the same name, I was hoping that just having files only accessible to the relevant target would solve this problem for me, but it only kind of does.
After migrating all of the code, the iOS target (which I got working before starting with the tvOS code) still compiles, however, the tvOS target doesn't. It fails on errors that should only be accessible to the iOS target, because the classnames and method are already used ('Duplicate interface definition for class' and similar errors).
So I really don't understand what's happening here -
Why does the the tvOS target have access to code that is only supposed to be available to the iOS target, but not the other way around? What can I do to fix this? (besides just wrapping all of the code in #if Target_OS_ios).
One other thing, the tvOS target only seems to have access to objective-c files from the iOS target, none of the errors have come up in any of the swift classes. Not sure if that is relevant or not.

Xcode error breaking on release version of custom framework

I am using the Release-iphoneos version of my custom framework in an app, I only added the Release-iphoneos binary, I didn't add the code to the project.
I had an error in the framework and Xcode stopped in the code of one of the objects of the framework, and all the code of that object was visible.
Is there some setting I am missing that would prevent the debugger from revealing my code?
UPDATE
In addition to the project I am working on, I have the framework project open in XCode, could that be the reason why it is stopping on the code?
If the framework is provided to third parties, I don't want them to see the code.
– MSimic
Then don't give them code. It's not added to the framework unless you include it. You have the code so Xcode shows it. Move it elsewhere on disk and it won't if it's compiled correctly.
– Sami Kuhmonen

iOS test target not recognizing main app's files

So I've been tasked by my company to develop our CI and testing, but I'm completely new to testing in iOS. I added a target, set as a testing unit, but I need access to the code within the primary target; however, my tests always fail, despite having added the primary app as a target(and vice versa) and checking that 'Symbols Hidden by Default' is off. Anyone have any advice? Really stuck until I can get those files working in my test target...thanks!
Have you checked that your source files also have a target membership for the tests application?You can do so by selecting one or more source files in the project navigator, opening the File Inspector (option+command+1) and enabling the target membership for your test application.
If you're using Xcode 6.4 or earlier (i.e. Swift 1.2), you need to make your classes and methods public. This is fixed in Xcode 7 / Swift 2.0.

How to build iOS framework with XCode 6

I know of familiar tutorials on this, but introduction of framework XCode 6 template has changed the game.
I already watched WWDC 2014 video about building modern frameworks but it talks more about building extensions, framework & app all inside single project. It does not specify if the framework I make with it is truly reusable across any project.
I am building framework the XCode 6 way (File->New Project->Framework and Library->Cocoa Touch Framework), but when I import it inside my test app project (separate from framework project) - I keep getting various errors.
Example: Include of non-modular header inside framework, and so on.
I know this is not what it says, and there are quite some missing steps in whatever I am doing. The older tricks may have worked for everyone, but I simply don't find which way to follow after XCode 6.
For example, there is some folder structure that a framework needs, but XCode 6 doesn't comply to it while building it. Is it right? If not, how can I change the way the XCode builds framework folder hierarchy?
Do I go back to old school or am I screwing some tiny thing in XCode 6 that I am unable to create a reusable framework?
I am not sure if you are trying to build a framework with Objective-C or Swift as your question doesn't state it. I've encountered errors you are mentioning with Swift so I'll give you my method to build Swift frameworks.
I found the process for Objective-C to be very straightforward and well documented, so I'll skip this.
As for Swift, there are a few things to consider. First, Swift static libraries are not supported, so you must exclusively use a framework (aka dynamic library) when linking an app to a library.
Here are the steps:
Create the Framework using New > Project under IOS > Framework & Library, select Cocoa Touch Framework
To avoid the "ld: warning: directory not found for option..." goto Library Search Paths in Build Settings for your target and delete the paths.
You can't mix Objective-C with Swift so don't even consider adding the Swift-Header bridge file in your code.
There are some cases in swift where you need to import code from unexposed Frameworks. I've successfully used the module-map inside the framework to deal with these case.
I also select CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES in the Build Settings to solve 'include of non-modular header inside framework module'. That seems to work
I make sure that the header file that gets generated is marked as Public (not Project). Click on the file and you'll see the selection in the inspector under 'Target Membership'
You may run into some bizarre error messages when building. Xcode has a tendency to report linker errors when your code can't compile correctly resulting in missing files the linker needs to output its binaries. Sometimes XCode won't show the errors in the files you are compiling and you need to go manually on the build output and go back to the files. Some other time, you'll get a problem where you need to delete the cache. Those issues I call XCode blues and deal with it constantly. I found this type of problems happens more often when building libraries. The rest should work as expected.

iOS: SpriteKit works even not linked?

In Xcode 5, I create a game demo using Xcode's 'Game Template', it links frameworks like this:
It use SpriteKit's code, but if I remove the SpriteKit.framework, it works too. I also use CoreMotion and find it not work without link CoreMotion Framework.
Then I create a game demo using Xcode 6, it doesn't link any framework now:
But it also works.
So there is no need to link frameworks?
I mainly using Xcode 5. Without linking how can I set it to 'Optional' to not crash on iOS6 ?
Okay, so this is basically a recollection from memory, correct me if I'm wrong.
Xcode can determine at compile time which (Apple) frameworks are referenced and links with them. It can also determine which other targets the main app target references.
However there's the possibility that this isn't quite true and since you've already built the project once with all the frameworks linked, the temporary build files make it so that the build with an empty Link Binaries list still works. To verify that, run a Product -> Clean in Xcode, then build & run again.
I'm not sure about using an optional framework. Either those frameworks are implicitly optional, or the whole point of adding them to the Link Binaries list is to be able to set them as optional.
A quick test with iOS 6.0 or earlier Simulator should help you find out which way it is.

Resources