How to use same Class"XY" for both ios and watchos3 with swif3 - frameworks

I tried to use a Custom Framework but it is not importing in the WatchApp Extension ->interfacecontroller.
In the ios App the Import statment work correct.
my question is :
how to use same classes in both targets(ios and watchos)

Creating a framework is indeed the recommended way to go. Just make sure your framework supports the arm7k architecture and also is compiled against the watchOS SDK.

Related

I'm making Swift framework but it doesn't have the class I made

I'm testing creating framework.
So, I made the test framework first.
And in another project, I imported the framework but I can't access the MyClass I made.
What's the problem? I don't know weather if can't access the class or framework doesn't have the class I made.
I'm struggling with this problem about two days.
Help me please.
Got the issue.PFB the explanation.
You have built the framework against 'Generic iOS device'.
You are trying to use against simulator which requires x86_64 architecture.
This is the reason which your iOS framework classes are not getting recognized in your view controller. Since your framework is built only for iOS devices.
Solution to your Question:
Change your build target device to 'Generic iOS device' and just build it and you can't run.
Generic Solution:
Try the tutorials for building universal framework where you will add 'Run Script phase' to create binary slices for all architectures(32-bit, 64-bit devices and simulators).
Output:

How to use json classes in xcode 4.1

I want use nsjsonserialiazation class in xcode 4.1....How can I use it? Should I have to download some framework? If yes then where can I download it?
It's native and available as of iOS 5.0 and all you need to do to use it is to invoke it.
No need to download extra frameworks. It's actually part of the Foundation framework that makes up the very basis of Objective C applications.
You can find the documentation on Apple's web site.

Recommended way to support backward/forward compatibility in iPhone app?

I'm in the early stages of an iPhone app and I have a question. I did some searching but did not find what I was looking for.
There are features in iPhone OS4 that I would like to take advantage of, but I would like for my app to also run on 3.X.
It looks like I want to develop against the 4.0 SDK and do the following:
Create a "weak link" to any new (4.0) frameworks
Call respondsToSelector: for any
new method in an existing framework
or any method in a new framework
before making that call
Am I close? What's recommended?
Pointers to similar questions welcome.
UPDATE:
Just as a note - if you are trying to check for a new framework, you're best chance is to call respondsToSelector: on a class method against the class object instead of using an instance method.
Yes, that's exactly how you do it!
The only other trick I can think of that you have not already mentioned is that you build against the latest SDK (i.e., 4.0 in this case) and set the target to be the earliest you want to support (3.0 in this case).
You might like to try using the 3.2 SDK to create a universal (iPhone/iPad) app. This is an Apple template that uses this same method to work with two different APIs.

How to build a Framework class in XCode?

I want to build a framework regarding some common aspects used in xcode like that of UIKit, Foundation etc. Is it possible for us to create our own framework which could be reused later ? If so, could you tell us a step by step procedure of how to do it?
This is now possible, see:
https://github.com/kstenerud/iOS-Universal-Framework
It's not currently possible to create a framework using the iPhone SDK. The closest you can come is bundling the logic you want to have shareable into a static library.
This is a good writeup on how to go about doing that for the iPhone SDK:
http://blog.stormyprods.com/2008/11/using-static-libraries-with-iphone-sdk.html

error when AppKit framework added in iphone application

i want to import in my iphone application, but i know this framework is not available in iphone sdk,but i need to use NSfileWrapper class in this framework, is this class also available in UIKit or others framework available in iphone sdk, thanks
No, NSFileWrapper is not available on the iPhone. Simply adding a framework that doesn't exist on the iPhone also won't get you anything. Your application is very limited on the iPhone with regards to accessing files and you basically have to use the classes and methods provided by the Foundation framework for the iPhone.