I'm trying to use the standard Cocoa library in a swift file in Xcode 6 Beta. I followed this instructions but when I import the library
import Cocoa
XCode complains with the error
No such module 'Cocoa'
I also tried with the REPL and I have no problems at all.
I suppose it's a bug, cause I started different projects and only sometimes I get this error. Any suggestions? I'm using Mavericks (10.9.3)
Replace
import Cocoa
With:
import UIKit
You can't import Cocoa from an iOS playground or application. Make sure your code is running in a Cocoa playground (select OS X > Source in the new file dialog).
From your question, it seems that you are trying to add Cocoa class into your iOS Application instead of Cocoa Touch class. So this is not a bug of Xcode.
Be sure to select template which are under the iOS section shown in the following screenshot, as we are choosing it for an iOS Application.
If you've already created your Playground, you can switch between iOS and OS X platforms in the "File Inspector" dialog; there's no need to create a new Playground. import Cocoa will only work for an OS X Playground.
Go to View > Utilities > Show File Inspector and then it's on the right under "Playground Settings"
you need to get xcode 6.1 (beta) to use Swift with OS X
You can open the Utilities tab (from the top right) and just switch platform from the Playground settings section. If you switch it from iOS to OS X the problem will be resolved.
Framework named Cocoa does not exists
Remove
import Cocoa
and everything must works from the scratch.
If this does not work for some reason you can import Foundation or UIKit frameworks
Related
I tried to disable the fullscreen button (green button) that appears on my app mac window (originally it's an iOS app and I made it available for macOS through the app setting in Xcode - Mac Catalyst feature) using a code like the below in AppDelegate.swift, but it's not working because I am using UIKit not AppKit:
for window in NSApplication.shared.windows {
if let zoomButton = window.standardWindowButton(NSWindow.ButtonType.zoomButton) {
zoomButton.isHidden = true;
}
}
Does anyone have any idea how to disable the fullscreen button using the UIKit library?
Please note that I built an iOS app using an Ionic framework and I want to make it available for macOS, what I did is enable the macOS version on the app setting on the Xcode, so I am using AppDelegate.swift file only on Xcode.
I found how to do it by creating a macOS bundle target and Helper class to use and include AppKit API, then disabling the zoom button on the didFinishLaunchingWithOptions method.
For anyone who faces this issue when enabling Mac Catalyst, please follow the steps on below link:
https://crunchybagel.com/disabling-the-mac-zoom-maximise-button-in-catalyst/
xcode screenshot
How can I create a project with storyboard? I don't see the interface dropdown. Thanks!
Looks like you try to create Multiplatform app:
In this case SwiftUI is used by default but you can add storyboards to your app manually later.
If you don't want to create a multiplatform app just select needed platform: iOS, macOS etc. and you can switch Interface to Storyboard:
Will I be capable of submitting an app with Xcode 7.3.1 while on the macOS 10.12 beta? According to this post, it is possible to run Xcode 7 alongside macOS 10.12.
Yes, you can! But if you're tying to do this, you will find two problems.
no .app file provided in bundle
Build with Xcode 7.3.1 then upload using Xcode 8 [Beta]. This will allow you to upload the archive.
When trying to submit to the store you will be faced with this error message:
New apps and app updates must be built with the public (GM) versions of Xcode 6 or later, OS X, and tvOS SDK. Don't submit apps built with beta software including beta OS X builds.
This is because your archive contain the Sierra's mark! I just solved this problem yesterday.
When you archived your app, find your archive in the Organizer, and then:
"Show in finder";
"Show package contents";
In the "xx.xcarchive" file, find the "Products"-"Applications"-"xx.app"(xx is your app's name), "Show package contents" again;
Finally, you can see there has a file named"Info.plist", open it;
Edit the value with a key named "BuildMachineOSBuild", I just change it to "15F34"(it's "El Capitan 10.11.5" 's version);
After that, you can upload this archive use Xcode or Application Loader, whatever you want!
Decided to try it out myself. Both methods of exporting through Xcode and Application Launcher failed with an error stating there was no .app file provided in bundle. Best to stay away from the macOS 10.12 beta if you want to continue developing for iOS 9.
Okay,
I'm new to xcode development and I'd like to use the
https://github.com/TheLevelUp/ZXingObjC
library in my swift os x app. I followed the instructions from here:
Importing 3rd party library ZXing into Xcode
First I downloaded it from github and added it to my project (right-click on my project->add Files to "myProject"). How described by clicking 'ZXingObjC.xcodeproj'. I added libZXingObjC-osx.a to "linked frameworks and libraries" and the font is red colored. Then I added the path to header and library search paths.
It compiles fine. But I cannot get access to the library. How can I use this library?
Thanks
So, a few days ago I download the new Xcode 6. I'm in the process of learning Swift. But here is the problem: It will only let me make a Swift app for iOS and not Mac OS X.
I start up Xcode and click, "Create New Xcode Project."
Next, I select, "Cocoa Application." But when I try to change the language from Objective-C to Swift, it won't let me! It will only show Objective-C!
Any ideas of why this is happening?
Swift for OS X isn't officially out yet.
Quoted from developer.apple.com/swift/resources:
Swift for OS X is coming with OS X Yosemite later this fall. If you
are using Swift to write Mac apps, you can download Xcode 6.1 GM seed
2 for Yosemite, which also includes the iOS 8.1 beta 2 SDK.
↳ Xcode 6.1 GM seed 2 for Yosemite Download
Xcode6-Beta6 ... if you can still get your hands on it ... will create a swift based project, even if you're running on Mavericks. I've been using it to create projects, and then opening them in Xcode6. Then in Xcode 6, to create a swift file, I hit cmd-N and go to the iOS section and pick the swift file type. Xcode 6 adds the swift file to the OS X project without any problems.