I introduced Printing via AirPrint recently, but wanted to not drop support for pre 4.2 versions (obviously). Done it before for things like Game Center, etc. What I found particularly odd in this case was I had to weak link UIKit. Printing was not contained in its own framework allowing me to be more granular.
This just didn't feel right, although it solves my problem allowing the app to run properly on all versions.
In Apple's SDK Compatibility Guide they state:
When using a framework that is
available in your deployment target,
you should require that framework (and
not weakly link it).
UIKit is available, just not classes such as UIPrintInfo, UIPrintInteractionController, etc.
Am I right that it seems odd to weakly link such a core framework? Is there a better way?
There is a better way. iOS 4.2 introduced NS_CLASS_AVAILABLE for this purpose, but there are some restrictions on using it. All the details are listed in the documentation linked to below:
http://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/cross_development/Using/using.html
Related
Currently we can access a particular module in Swift by command + clicking a particular Swift type. Is there a way to easily access all Swift modules / standard libraries from within Xcode?
Is there a way to debug into Swift source code like one can in Android?
Is there a way to debug into Swift source code like one can in Android?
The answer depends on what you mean by "all Swift modules / standard libraries".
If you are interested in the Swift's standard libraries (i.e. clases like String or Array), then Swift was open-sourced by Apple and you can find sources on github following links from https://swift.org/source-code/. Still there seems to be no way to "attach" those sources to navigate there from your XCode project.
However, if you are interested in most of the MacOS or iOS frameworks such as UIKit and many others, then I believe the answer is NO.
Unlike Android, iOS is a proprietary closed source OS and in most of the areas Apple has no intentions to share its code with everyone.
Side Note: Once it was claimed that one of major reasons for Apple to switch its tools from GCC stack to Clang/LLVM stack was that GCC is licensed under "copyleft" GPL and thus Apple couldn't integrate parts of GCC Obj-C backend (such as code analysis or stuff useful for refactoring) into XCode even if those parts were developed by Apple itself without making whole XCode open source. Clang/LLVM on the other hand uses more permissive open-source license that allows such 3rd-party usages.
Moreover much of the Apple's internal code still must be in Objective-C or even plain C rather than Swift. It is relatively easy to convert "headers" i.e. interfaces specification from Obj-C to Swift automatically but it is very hard for real implementation especially given difference between Obj-C and Swift. So even if it was an open-source, there would be no debugging in Swift.
On a positive side: some code gets executed and Apple can't hide it and thus you can debug it. The only problem is that the code is in machine language helpfully decoded into Assembly (x86 or ARM) by XCode. However, it obviously requires some skill and time to understand any non-trivial logic from that. And beware that you probably can't copy logic found that way without violating some copyright laws.
Swift is open source. So you can get its code and modules here.
However, you can't do it with command + clicking in Xcode from your own project. In fact, the code you got from command + clicking was not Swift source. They were headers that were generated by the compiler automatically. Those headers may be generated from Swift source code, or even Objective-C code.
Also, even though you can get source code and edit it, you can't use it on your app that you want to be published to App Store. You can only use the Swift comes with Xcode to published to App Store, or your app will be rejected.
How can i add NSSpeechSynthesizer Class Reference.
I think it is in
/System/Library/Frameworks/AppKit.framework.
However there is no such framework name in framework window when I am clicking add existing frame work.
Can any one help me to do it.
VSSpeechSynthesizer is available for the iOS - but it is a private API and as such will likely be rejected from the app store. However you can still make apps for private consumption. I consider this a bug as it makes creating accessible apps for the partially sighted for instance, harder. I have filed Bug ID #: 9451650 Bug Title: VSSpeechSynthesizer is Private
I currently use Flite TTS in my App. All hopes fix on the Nuance integration in iOS5 being available as a public API.
AppKit framework is MacOS framework, not iOS, and so NSSpeechSynthesizer class is also available on Mac only.
Check this question on SO for the list of some 3rd-party text-to-speach engines available on iPhone
You can find it inside iPhone SDK
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk
/System/Library/PrivateFrameworks/VoiceServices.framework/VoiceServices
This question comes from this other one I asked earlier: Calling custom Objective-C from a pyobjc application?
I want to re-use a small part of the app logic from my iPhone app in its server-side component, which runs on OSX. Based on what I was told in the other question, it looks like I need to compile a "framework" for both iOS and OSX from this little piece of app logic.
If we assume that I am able to isolate all the code that is to be in this framework into a single .h/.m pair of files that has no other non-Cocoa dependencies, what would be the easiest way in XCode to build this framework for each architecture and avoid double-coding all this logic on the server?
I tried adding a new OSX framework build target to my iPhone project, but this doesn't get very far and XCode bails out pretty quickly with:
target specifies product type 'com.apple.product-type.framework', but there's no such product type for the 'iphonesimulator' platform
Any help much appreciated, as I am currently dupe-implementing to keep things moving forward, but this is pretty obviously becoming a huge waste of time and source of errors when the implementations become slightly out-of-sync.
Depends on what you used in your custom class. If you did not use anything from UIKit / AppKit then the class is probably going to live well on either platform, otherwise, you’d have to use target conditionals and include separate code specially written for both platforms.
You can have multiple targets in one Xcode project, their Base SDK set separately for the Mac / iDevices.
Adam's comment to my original question answers this question. Although still interested to see if there is a way to do it all from a single XCode project, the solution I have now is plenty good enough for what I wanted to achieve.
I'm still getting my feet wet with the iPhone SDK, but I'm wondering if it would be possible to get the ConnectionKit framework working for an iPhone app. I know it was developed for the desktop OS, so I'm not sure what sort of dependencies it has and whether or not it could be shoehorned into the iPhone OS.
In my case, I would like to use its FTP functionality, though having access to this entire framework could prove useful for future projects as well.
Any ideas or experience trying this?
In case it helps, here's the official ConnectionKit site: http://opensource.utr-software.com/connection/
The site was a little light on documentation.
The big question is what Cocoa classes it depends on. Since it is doesn't include any UI code, it should be based on Foundation classes. Foundation in Cocoa Touch is similar to, but not exactly the same as on OS X. Just check out what classes it uses.
The other obstacle is building the framework as a static library. Since the iPhone does not support frameworks/dynamic libraries, you have to build a static library to use it in your code.
That should help get you started.
There are two primary issues. One is static library and other is NSHost class that is supported by cocoa - but not cocoa touch. First one is doable - but the second one is doable if and only if you are familiar with Mac OS networking internals.
The error I'm getting:
in /Users/robert/Documents/funWithFrameworks/build/Debug-iphonesimulator/funWithFrameworks.framework/funWithFrameworks, can't link with a main executable
Cliff notes:
trying to include framework
doesn't want to link
More detail:
I'm developing for a mobile device... hint, hint using Xcode and I'm trying to make my
own custom framework which I can include from another application. So far, I've done the following:
Create a new project; an iPhone OS window based app.
Go to target info-> under packaging, change the wrapper extension from app to framework
Go to Action->new build phase -> copy headers. Change roles of headers to 'public'
From my application, I add the framework to the frameworks group.
Apple clearly said that you can not use dynamic libraries on their mobiles. And a private framework is just this.
You can, however, use static libraries.
Egil, that's usually considered as one of the implications of section 3.3.2 of the iPhone developer agreement, which (in part) forbids plug-in architectures or other frameworks. The fact that they don't provide an Xcode project template for an iPhone-compatible framework tends to reinforce the idea, though of course it could just be an oversight or something they're discouraging without actually forbidding.
Whether this is the intended meaning of that section is something you'd have to ask Apple about, and possibly consult a lawyer, but this is where the oft-stated "no frameworks" idea comes from.
For those who have framework code they'd like to use in an iPhone app, an alternative approach is to use the framework code to build a static library. That then gets compiled into the application instead of getting dynamically loaded at run time. The fact that it's part of the application executable avoids any potential concerns about this part of the agreement.
Though dynamic libraries are not allowed, you CAN create a framework (using static libraries and lipo).
Check out: http://accu.org/index.php/journals/1594
I haven't tried it for so called mobile device, but I would guess its very similar to the method for a regular Cocoa application. Check out this tutorial:
Embedded Cocoa Frameworks