I have a macOS app that I wrote years ago; it has been working well on my Mac. Recently I thought it would be nice to have that same app on my iPhone so I added an iOS target to my Xcode project. I have never built for iOS before so I'm on new ground here.Anyway, when I built for iOS, I got an error message: "Cocoa is not available when building for iOS." In Apple's "Cocoa Fundamentals Guide" there is a prominent statement: "Cocoa is a set of object-oriented frameworks that provides a runtime environment for applications running in OS X and iOS."Does that mean I can run an app that uses Cocoa but not build one? I'm at a loss; I have no idea how to get past this one. Can an iOS app be built without Cocoa? How would I even go about doing that? Any suggestions at all will be welcome. I'm running Xcode 12.5 on macOS Big Sur 11.4. My app's UI is written in Objective-C and its muscle is in plain C. Also, my app is only for my own use, not for publication.
Anyway, when I built for iOS, I got an error message: "Cocoa is not available when building for iOS." In Apple's "Cocoa Fundamentals Guide" there is a prominent statement: "Cocoa is a set of object-oriented frameworks that provides a runtime environment for applications running in OS X and iOS."
That's somewhat confusing wording. iOS uses a variation on the Cocoa theme called Cocoa Touch. More specifically, the user interface framework on macOS is called AppKit while the iOS user interface framework is UIKit. If you're comfortable with AppKit, it's not hard to learn enough UIKit to get things done. Other frameworks (Foundation, Core Graphics, Core Data, etc.) are pretty much the same on both platforms.
Does that mean I can run an app that uses Cocoa but not build one?
No. You're going to have to rewrite at least the user interface parts of your app before it'll run on iOS. iOS devices obviously use a somewhat different user interaction model: there's no hardware keyboard, no mouse, a touch screen that can handle multiple simultaneous touches, a much smaller screen, and a variety of sensors that don't exist on the Mac, so a different approach to interacting with the user is different. If you were careful to separate the business logic (model) from the user interface (views) in your Mac app, you'll likely be able to reuse most of that unchanged.
Try to rewrite your code using Cocoa touch or UIKit. I am not good at iOS coding, by the way as I know Cocoa framework is for Mac OS, the framework for touch devices is Cocoa touch.
Related
I have been working with ARKit 3 (the beta with Xcode beta as well). I understand that the ARKit framework is meant to be used on iOS devices, but what I'm wondering is if I can instantiate any of these classes in a macOS project?
I've archived an ARWorldMap object (from ARKit) on an iOS device and have downloaded the app bundle to inspect it on my MacBook.
I am trying to use NSKeyedUnarchiver to unarchive the data that was archived by NSKeyedArchiver and when I try to import ARKit in the MacBook project, I get the error below.
I understand that certain features shouldn't be expected to work outside of iOS devices, but can I not use the classes that hold specific data when I develop in Xcode for programs targeting a MacBook?
Any help would be appreciated.
Here is the error:
"No such module 'ARKit' "
Unfortunately, the ARKit API is only available on iOS 11 and above. At the time of this post. The API relies on hardware features only available on an iPad or iPhone.
You can see Apple's API support in their documentation. See SDK on the right side of their doc. Here's a link to Apple's ARKit API.
There is an iOS app developed in iOS 4.3. Now I want to upgrade this app to iOS 9 and later. I can able to run the application even on iOS 10 devices. But there are lot of deprecated warnings regarding the latest SDK.
The main reason I'm posting this question is, while upgrading the app from lower version to latest version, what are the action items to be consider to make the application perfect on latest SDK?
Here are few points I've noted,
Clear all deprecated warning.
Do analyser for memory leak.
Enable ARC if not enabled yet.
Proper unit testing.
Please advice me some more point.
Note: I'm not converting the app to Swift, using Objective-C only.
Update: I know the basic things like changing the deployment targets, update the used libraries / Frameworks to latest one, etc., I want more high level points those features are available in latest SDK comparing with lower one.
Thanks
Here are some more points you have to consider for latest iOS support,
Change deployment target in general setting.
Check for device compatibility for design constraint. There are new devices.
Change the version of your app in general settings.
If there are any functionality for touch event than check if it is possible to implement 3D touch for newer device.
And go for proper testing of functionality and design.
Hope it will help you.
I have noticed that Xcode is capable of running UIKit code for IBDesignables, without launching the simulator at all. It seems to be using IBDesignablesAgentCocoaTouch tool which is a macOS app. How something like that can be implemented?
iOS apps compiled for x86_64 are actually normal macOS apps, just linked against different frameworks. The simulator framework provides the runtime needed for all those framework to function in a manner similar to how they do on iOS hardware. The IBDesignablesAgentCocoaTouch daemon spins up enough of the iOS subsystem to be able to take a snapshot of your UI every time you make a change in Xcode. Theoretically, it is possible to spin up the iOS subsystem partially or fully in a different manner than how the simulator does, but this is most likely infringes on the developer license agreement you signed when installing, and would certainly not be legal for distribution. Legal or otherwise, it would be quite an undertaking, and very likely to break with each change to the system. It is enough to look at how widely the simulator framework has changed over the recent years to get a feel for how hard this would be for non-Apple developers.
If you need to run non-UI code for testing, for instance, there are far more easier ways to achieve what you need, such as creating a macOS target and including all your non-UI stuff in it, and stubbing out the absolutely minimum necessary UI stuff for testing.
If you want to achieve multiplatform development using iOS frameworks, and then running them using Apple iOS frameworks outside of the simulator, this is not legal (iOS frameworks are not distributed with macOS normally, and require installing Xcode), and is not a good idea, as users expect applications to behave natively on the platform they are running. iOS UI concepts fit best for touch input, but they would be out of place on a precision-pointer input ecosystem.
I am a software engineering student enrolled in a practicum course where a small team of students works with a third-party client to solve a problem. My team has been assigned a project that involves writing an iOS program. None of us have ever done any iOS programming. We are reading voraciously, but need to come up to speed as quickly as possible since the semester is only 15 weeks long.
My question is regarding testing frameworks. Our team plans to use TDD. Our iOS app needs to support iOS 6 and 7. I thought I read somewhere that XCTest only supports iOS 7 and that we will need to use OCUnit in order to support iOS 6. Is that true? How do we write an app that supports both iOS 6 and 7? Is it as simple as setting the deployment target to iOS 6.0 and not using any APIs that were introduced after iOS 6.0?
You can target iOS 6 and up, but if you use XCTest, you will be able to run your tests only on iOS 7.
I believe you can use still use XCTest, but I would urge you to take a look at Kiwi (https://github.com/allending/Kiwi) in your research. It basically wraps whichever framework you choose (xctest/octest) with macros to give you a spec-style testing option. Also, it has extremely powerful mocking/stubbing support which is essential in unit testing.
My team has developed a big social networking app. Now i want to publish it to app store. But the app is not written in Objective C. What is the way to get it published in app store? Or least how can i open in in Xcode simulator for testing and enhancement?
My guess is that you created an app in android and now want to port it to iOS. Unfortunately Xcode isn't able to transform Java to Objective-C and iOS cannot run Java apps, so you will not be able yo submit your app as-is to the App Store.
You will have to do it the hard way and rewrite the entire app in Objective-C. Luckily Google recently launched a translator that might help with part of the work: http://google-opensource.blogspot.com.br/2012/09/j2objc-java-to-ios-objective-c.html
You cannot. Sorry.
I recently worked on an app for iOS and Android launch and we settled for parallel development.
Your Java code is incompatible with iOS and Xcode has no process to convert it to Obj-c.
The only options for cross-platform development that I am aware of are:
1) Heavy use of c/c++ based libraries; these can be utilised in both Android applications and iOS applications (this is what we used). But the entire front end of the apps must be re-implemented.
2) A cross-platform framework such as PhoneGap or Appcelerator, but this would require significant redevelopment from your current code-base.
3) A 'translator' such as the one Breno Gazzola suggested (another option is XMLVM) but these only do some of the work for you, and they're far from perfect.
It's very hard to judge without knowing your code, but if I were you I'd look at combining options 1 and 3 as much as possible, but budget for a complete re-write.