swift-playground

error: module file's minimum deployment target is ios8.3 v8.3

感情迁移 提交于 2019-11-27 18:54:22
All attempts to import a dynamic framework in an Xcode playground yield the following error: error: module file's minimum deployment target is ios8.3 v8.3 alreadytaken You might have created a target after updating Xcode, which made 8.3 the iOS Deployment Target in Build Settings for that target. I fixed this by: Setting the iOS Deployment Target to 8.0 (Which is the same as the rest of the project) Note iOS version mismatch in this screenshot (one is 10.0, other is 9.3) Note iOS versions now match (make sure they all match) Doing a clean (Command+Shift+k) and build If a clean+build doesn't

iOS Playground doesn't show UI preview

心不动则不痛 提交于 2019-11-27 18:16:56
I've created a simple playground with XCode 7.1 and I've typed this simple code: import UIKit import XCPlayground var str = "Hello, playground" let color = UIColor (red: 1 , green: 1 , blue: 0 , alpha: 0 ) let view = UIView() view.backgroundColor = UIColo (colorLiteralRed: 1 , green: 0 , blue: 0 , alpha: 0 ) view.frame = CGRect (x: 0 ,y: 0 ,width: 100 ,height: 100 ) let label = UILabel (frame: CGRect (x: 5 , y: 5 , width: 50 , height: 20 )) label.text = str view.addSubview(label) When the playground runs, it doesn't show UIKit object preview, but only debug information: What am I doing wrong?

Swift playgrounds with UIImage

橙三吉。 提交于 2019-11-27 17:57:31
I am working with Xcode 6, and I'm trying to recreate the code demoed during session 401 "What's new in Xcode 6". I've added an image to Images.xcassets (called Sample) and within the playground file I'm trying to access this image, as demoed. My code is as follows (like the demo): var sample = UIImage(named: "Sample") However, I can't get it to work like the demo. Am I missing something? Open the .playground file in Finder. Create a folder called Resources next to it. Add any images you want to this folder. In the playground press opt-cmd-1 to open the File Inspector. You should see the

Using Alamofire within a Playground

假如想象 提交于 2019-11-27 16:07:20
问题 I'm new to iOS development and using Xcode and I'm having trouble getting Alamofire to work within a Playground. There's some functionality I'd like to test out for proof of concept but the library is not linked to the Playground and I've tried getting it to play nicely. I have Alamofire set up to work within an iOS (not in a Playground) project before the installation instructions in the Github Alamofire repo were recently updated. Any suggestions on how to get Alamofire to import properly

Convert Character to Int in Swift 2.0

大兔子大兔子 提交于 2019-11-27 12:41:11
I just want to convert a character into an Int . This should be simple. But I haven't found the previous answers helpful. There is always some error. Perhaps it is because I'm trying it in Swift 2.0. for i in (unsolved.characters) { fileLines += String(i).toInt() print(i) } In Swift 2.0, toInt() , etc., have been replaced with initializers. (In this case, Int(someString) .) Because not all strings can be converted to ints, this initializer is failable , which means it returns an optional int ( Int? ) instead of just an Int . The best thing to do is unwrap this optional using if let . I'm not

Swift Playground - Files are not readable

蹲街弑〆低调 提交于 2019-11-27 09:13:53
Files are not readable in Swift Playground . How to make files readable? Same code runs well on Xcode terminal app, but fails on Swift Playground. Demo code below. import Foundation println("Hello, World!") var fname:String = "/Users/holyfield/Desktop/com.apple.IconComposer.plist" var fm:NSFileManager = NSFileManager.defaultManager() if(fm.fileExistsAtPath(fname)){ println("File Exists") if(fm.isReadableFileAtPath(fname)){ println("File is readable") var fd:NSData? = NSData(contentsOfFile: fname) println(fd?.length) let pl = NSDictionary(contentsOfFile: fname) println(pl?.count) println(pl?

My Swift 4 UIScrollView with autolayout constraints is not scrolling

守給你的承諾、 提交于 2019-11-27 09:10:54
I have created a small demo playground to get this working before adding the view to my app. I have a scroll view that is going to contain a number of buttons to scroll through horizontally. I know that these buttons need to go into a container view within the scroll view and have created this as well. I was initially using autolayout constraints to create all of this, but have now tried using constants to ensure the content view is bigger than the scroll view. However, the buttons still will not scroll... have I missed something? Do scroll views not work with auto layout? I am doing this all

Working with Live Photos in Playground

放肆的年华 提交于 2019-11-27 08:03:58
I've done a fair amount of searching the web, but I'm currently attempting to work with "Live Photos" in Playground. I'm aware of the framework (PHLivePhoto), I just have no clue if working with them in Playground is possible due to that fact that there's not much to "import" as there doesn't seem to be any "Live Photos" available for download online. Any ideas? It's possible to make and view a PHLivePhoto in the Playground from the elements of an actual Live Photo . In OS X's Photos app, select a Live Photo and go to menu File > Export > Export original... It will create a .JPG and a .mov .

what are the rules for spaces in swift

╄→гoц情女王★ 提交于 2019-11-27 05:28:48
I practicing in swift's playground and I couldn't figure out why swift is too specific about where programmer should provide spaces and where not. I asked this question on many sites and chatrooms but didn't got any answer. var j: Int = 34 // Right var j:Int=23 //Wrong Also, In class self.variable-= 5 //Wrong. Error: Consecutive statements must be followed by ; self.variable-=5 // Right self.variable -= 5 // Right ; Even this ":" creates some issues with spaces sometimes. I think spaces should have absolutely no effect on the code. It's usually just for a programmer's benefit. It just makes

Iterate through a String Swift 2.0

旧巷老猫 提交于 2019-11-27 04:35:05
I am trying to do a very simple piece of code in Swift playgrounds. var word = "Zebra" for i in word { print(i) } However, I always get an error on line 3. 'String' does not have a member named 'Generator' Any ideas on why this doesn't work? Note: I am working in Xcode 7, with Swift 2.0 ( Strings and Characters). As of Swift 2, String doesn't conform to SequenceType . However, you can use the characters property on String . characters returns a String.CharacterView which conforms to SequenceType and so can be iterated through with a for loop: let word = "Zebra" for i in word.characters { print