swift-playground

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

我的未来我决定 提交于 2019-11-27 04:19:45
问题 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 回答1: 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

Can I import my project code into the Swift REPL?

拜拜、爱过 提交于 2019-11-27 03:23:00
问题 The Swift REPL is great, but it would be even better if I could import the classes from an Xcode project. I tried switching to my project directory and running $ swift > import ProjectName but I got: error: no such module 'ProjectName' Is it possible to do this? 回答1: The Swift REPL includes a number of different options. Use swift -help to see them. For your case, if you've defined ProjectName as a framework target and in the target you've declared 'Defines Module' then you can access it with

Xcode: Any way to refresh/re-run the playground?

元气小坏坏 提交于 2019-11-27 03:01:28
问题 The Playground in Xcode automatically updates as you type, but I can't figure out how to get the Playground to "re-compile". In many cases this wouldn't matter, but if you're writing code that generates or uses random values it can be useful to run it a few times to make sure it's working. Is there any way to get the playground to reset / refresh / re-run? Seen a few questions asking how to stop the Playground from auto-updating, but nothing for the opposite. Easiest way to do this seems to

How to reference Swift Playground itself?

♀尐吖头ヾ 提交于 2019-11-27 02:18:41
问题 from How to create a button programmatically? self doesn't work in swift playground : button.addTarget(self, action: "buttonAction:", forControlEvents: UIControlEvents.TouchUpInside) error : Playground execution failed: error: :42:13: error: use of unresolved identifier 'self' I also tried to create a class with buttonAction method inside it compiles but when I click on the button nothing prints in console import UIKit class myself { func buttonAction(sender:UIButton!) { println("Button

How to create and send the json data to server using swift language

ぃ、小莉子 提交于 2019-11-27 01:25:03
问题 I'm new to IOS development and I have started with the swift language. I'm trying to get the value from two text fields and convert those two text fields into json and send that json to the server receive.php. lets concider that tow text fields are - name - pass how do i create a Json & send that to server when a button is clicked ? 回答1: By using http POST method with NSURLSession. Let's say you are calling submitAction method on the press of the login button Swift 3 @IBAction func

Playground Import: No Such Module 'Foo'

≯℡__Kan透↙ 提交于 2019-11-26 22:47:25
问题 I've diligently followed the Apple instructions to import a custom module into a playground, including the instructions here. And yet I get: Playground execution failed: /var/folders/z3/kd0nj4ln1rgcpm8bdz7067wh0000gs/T/./lldb/1874/playground1.swift:7:8: error: no such module 'Foo' import Foo How can I recover to a working Playground import? [Edit: Note, two answers have produced detailed instructions to associate a playground with a framework; I have followed those instructions but no luck.

Type does not have a member

不羁的心 提交于 2019-11-26 21:01:57
I'm playing around with a Swift playground working on a new class. For some reason I keep getting an error that the class "does not have a member type" with the name of a constant defined three lines earlier. Here is the code: import Foundation class DataModel { let myCalendar = NSCalendar.autoupdatingCurrentCalendar() var myData = [NSDate : Float]() let now = NSDate() let components = myCalendar.components(.CalendarUnitYear | .CalendarUnitMonth, fromDate: now) } Xcode Beta6 keeps give me an error on the second to last line, saying that "DataModel.Type does not have a member named 'myCalendar'

Add a method to Card that creates a full deck of cards, with one card of each combination of rank and suit

妖精的绣舞 提交于 2019-11-26 20:18:04
问题 So I have been doing the experiments that are in the Apple Swift Book. I have been able to do all of them, except for this one so far. Below is what I have tried, but I can't figure out how to get it working. Add a method to Card that creates a full deck of cards, with one card of each combination of rank and suit. // Playground - noun: a place where people can play enum Rank: Int { case Ace = 1 case Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten case Jack, Queen, King func

iOS Playground doesn't show UI preview

眉间皱痕 提交于 2019-11-26 19:17:27
问题 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

Swift playgrounds with UIImage

拈花ヽ惹草 提交于 2019-11-26 19:14:11
问题 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? 回答1: Open the .playground file in Finder. Create a folder called Resources next to it. Add any images you