Coder Social home page Coder Social logo

swiftforwindows's Introduction

Swift for Windows is an open source project that provides an easy-to-use development environment for Swift programming for Windows applications.

swiftforwindows's People

Contributors

tinysun212 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swiftforwindows's Issues

'Failed to import bridging header'

[ewing21@2017-01-02]

Hi, I've been doing a lot of work to get Swift usable in a cross-platform way (Mac, iOS, Linux, Android, Raspberry Pi). I heard about this Windows port so I thought I would give it a try.

Using the prebuilt Visual Studio 2015 binaries for the command line swift and swiftc executables provided by the Swift for Windows page, I am able to build and run a trivial Swift program (e.g. print("Hello World").

So my next step is to use a bridging header. The way I'm approaching cross-platform is that I have a bunch of already cross-platform C libraries (e.g. SDL) which I bind to Swift. Then you can write cross-platform Swift code. But for this to work, I need a bridging header.

When I try specifying a bridging header, I get the error "failed to import bridging header".

Any ideas on how to get this working?

Thanks

This work item was migrated from CodePlex

CodePlex work item ID: '11'
Vote count: '2'
Reported on: 2017-01-02
Reported by: ewing21

Can I use import?

Ex: "import Foundation"

This work item was migrated from CodePlex

CodePlex work item ID: '1'
Vote count: '1'
Reported on: 2016-05-03
Reported by: rover2341

Cannot make wx.Frame border fixed

Thank you for Swift for Windows! 😄

I was going through the source of SwiftForWindows and cannot make the window border fixed. I don't want it to be resizable. This line

var frame = wx.Frame(nil, wx.ID_ANY, "Swift for Windows 1.9", size: wx.Size(1000, 600), style: wx.DEFAULT_FRAME_STYLE & ~wx.RESIZE_BORDER)

has

style: wx.DEFAULT_FRAME_STYLE & ~wx.RESIZE_BORDER

but this is being ignored and the border is still resizable.

I have consulted this documentation page and cannot find any other way to fix this. Is this a problem with SwiftForWindows?

Cant compile the program

Whenever I compile the program there is an error occurred:the system can't find specified path "link" is not recognized as internal or external command.

Attachments

Capture.JPG

This work item was migrated from CodePlex

CodePlex work item ID: '9'
Vote count: '5'
Reported on: 2016-11-23
Reported by: Ajaydesai161167

Have Path Error,cannot run,plz help

Hi, I have new installed the Swift for windows, and I have Win 7 X64 Chinese Edition

but the path is error with this OS

the path is not correct , plz see the image

Attachments

QQ截图20160615160317.jpg

This work item was migrated from CodePlex

CodePlex work item ID: '5'
Assigned to: 'vineetchoudhary'
Vote count: '1'
Reported on: 2016-06-15
Reported by: JiaFeiX

DLL Missing problem

Hey, I have some DLL Missing problem after install SwiftForWindows which impeded me to open it.
The Missing DLL are as follows :

libwx.dll
libswiftMinGWXCrt.dll
libswiftSwiftOnoneSupport.dll
libswiftCore.dll

Each message alarm for one times, and do not have any Error Code.
Could you tell me what to do, Thanks! 👍

Unable to compile a simple Win32 application

I copy the winapi headers from tinycc and change typedef wchar_t WCHAR; into typedef __WCHAR_T__ WCHAR; in winnt.h.
Those codes are able to run directly but not able to be compiled into executable binary.

#define NOSERVICE
#define NOMCX
#define NOIME
#include <windows.h>

and

let className = "SwiftWindow"
var classNamePtr: UnsafePointer<Int8>?

_ = className.utf8CString.withUnsafeBufferPointer { ptr in
    classNamePtr = ptr.baseAddress!
}

let windowName = "Learn to Program Windows in Swift"
var windowNamePtr: UnsafePointer<Int8>?

_ = windowName.utf8CString.withUnsafeBufferPointer { ptr in
    windowNamePtr = ptr.baseAddress!
}

let hInstance = GetModuleHandleA(nil)

var wc = WNDCLASSA()
wc.hInstance = hInstance
wc.lpszClassName = classNamePtr
wc.lpfnWndProc = { hwnd, uMsg, wParam, lParam in
    switch Int32(uMsg) {
    case WM_DESTROY:
        PostQuitMessage(0)
    case WM_PAINT:
        var ps = PAINTSTRUCT()
        let hdc = BeginPaint(hwnd, &ps)
        FillRect(hdc, &ps.rcPaint, UnsafeMutablePointer<HBRUSH__>(bitPattern: Int(COLOR_WINDOW) + 1))
        EndPaint(hwnd, &ps)
    default:
        break
    }
    return DefWindowProcA(hwnd, uMsg, wParam, lParam)
}

RegisterClassA(&wc)

let WS_OVERLAPPEDWINDOW = UInt32(WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)

// CW_USEDEFAULT == 0x80000000 == 1 << 31
// Use CW_USEDEFAULT will report integer overflows.
let hwnd = CreateWindowExA(0, classNamePtr, windowNamePtr, WS_OVERLAPPEDWINDOW, 1 << 31, 1 << 31, 1 << 31, 1 << 31, nil, nil, hInstance, nil)
if hwnd != nil {
    ShowWindow(hwnd, SW_SHOWNORMAL)
    var msg = MSG()
    while GetMessageA(&msg, nil, 0, 0) != 0 {
        TranslateMessage(&msg)
        DispatchMessageA(&msg)
    }
}

SwiftForWindows does not open

SwiftForWindows does not open when I double click on it ( windows 10 64-bit ).
swiftfc --version returns: swift version 4.0.3.

any ideas?
thanks

Does Swift for Windows have malware/virus?

I downloaded the file tonight, and when it finished the download I am informed that the file has a virus or malware - s-msft.com. I am now worried I may have an unintended virus/malware on my laptop. Is this true??

This work item was migrated from CodePlex

CodePlex work item ID: '10'
Vote count: '2'
Reported on: 2016-12-22
Reported by: peter314

Error in swift for window

i could't open swift for window compiler . when i dubble click on it it shows 'libswiftcore.dll' is missing on your computer.

How to compile only under i386

If I collected some libraries only under i386, swiftc says:
ld: i386 architecture of input file `File.o' is incompatible with i386:x86-64.

How to compile swift code only under i386?

Could not build C module 'SwiftMinGWCrt'.

every time I import Foundation module, It can't compile:

:26:10: note: in file included from :26:
#include "../../../../../mingw64/include/regex.h"
^
D:\Swift\usr\lib\swift\mingw\x86_64/../../../../../mingw64/include/regex.h:11:10: error: 'tre/tre.h' file not found with include; use "quotes" instead
#include <tre/tre.h>
^
:0: error: could not build C module 'SwiftMinGWCrt'

Incorrect output by String(format:)

import Foundation

let i:Int = 1234,
	d:Double = 12.34

print(String(format: "%d, %f", i, d))

Gives result as:
0, 0.000000

Instead of:
1234, 12.340000

Issue with Date/DateComponents/Calendar

Are Date, DateComponents and Calendar implemented fully?

import Foundation
let calendar:Calendar = Calendar.init(identifier: .gregorian),
		dc:DateComponents = calendar.dateComponents([.year, .month, .day, .hour, .minute, .second], from: Date()),
		year:Int = dc.year!,
		month:Int = dc.month!,
		day:Int = dc.day!,
		hour:Int = dc.hour!,
		minute:Int = dc.minute!,
		second:Int = dc.second!
print("\(year)/\(month)/\(day) \(hour):\(minute):\(second)")

The above code results in Successfully compiled but trying to run the compiled EXE results in test.exe has stopped working with following log:

Problem signature:
  Problem Event Name:	APPCRASH
  Application Name:	test.exe
  Application Version:	0.0.0.0
  Application Timestamp:	5a485d8a
  Fault Module Name:	libswiftCore.dll
  Fault Module Version:	0.0.0.0
  Fault Module Timestamp:	5a1dd963
  Exception Code:	c0000005
  Exception Offset:	00000000002c8a68
  OS Version:	6.1.7601.2.1.0.256.1
  Locale ID:	16393
  Additional Information 1:	2a62
  Additional Information 2:	2a622f736c5aa4a6a3a49c7d1553befd
  Additional Information 3:	4265
  Additional Information 4:	42659591601f777d7a767fdef52146d3

Dictionary access fails

When running this program:

let dic : [String: String?] = ["a": "It is a", "b" : nil]

let a = dic["a"]
// let b = dic["b"]
// let c = dic["c"]

print(a as Any)
//print(b as Any)
//print(c as Any)

A Segmentation fault error happens.

I was expecting:

Optional(Optional("It is a"))

Although did not check behaviour in XCode, yet.

weak references are not working

simple test:

import Foundation
class TestClass {
}

let test = TestClass()
weak var ref = test //Segmentation fault

Backtrace:

EXCEPTION PID=14200 TID=3008 ExceptionCode=0x80000003 dwFirstChance=1
EXIT_THREAD PID=14200 TID=3008 dwExitCode=0x0
EXCEPTION PID=14200 TID=15576 ExceptionCode=0xc0000005 dwFirstChance=0
test.exe caused an Access Violation at location 000000006C6C15B0 in module libatomic-1.dll Reading from location FFFFFFFFFFFFFFFF.

AddrPC           Params
000000006C6C15B0 00000000024BE080 0000000000000010 00000000024BE080  libatomic-1.dll!libat_load
000000006A88A5FF 0000000000000010 0000000000404020 0000000000000000  libswiftCore.dll!swift::HeapObjectSideTableEntry::incrementWeak
000000006A89F2B4 0000000000000008 0000000000401951 00000000004017A0  libswiftCore.dll!swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::formWeakReference
000000006A889F49 FFFFFFFFFFFFFFFF 00000000004019F2 0000000000000001  libswiftCore.dll!swift_weakInit
000000000040164F 0000000000000000 000000000000000B 000000000040D9A0  test.exe!main
00000000004013F8 0000000000000000 0000000000000000 0000000000000000  test.exe!__tmainCRTStartup  [C:/repo/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c @ 334]
000000000040151B 0000000000000000 0000000000000000 0000000000000000  test.exe!mainCRTStartup  [C:/repo/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c @ 212]
00007FF9DFF82774 0000000000000000 0000000000000000 0000000000000000  KERNEL32.DLL!BaseThreadInitThunk
00007FF9E2280D51 0000000000000000 0000000000000000 0000000000000000  ntdll.dll!RtlUserThreadStart

EXIT_THREAD PID=14200 TID=14608 dwExitCode=0xc0000005
EXIT_PROCESS PID=14200 TID=15576 dwExitCode=0xc000000

Perhaps, instead of libatomic, you should use compiler-rt for atomic operations
https://clang.llvm.org/docs/Toolchain.html#compiler-runtime

Cant Compile or Run

When ever i attempt to run the Hello World program that comes with the installation i get the following errors for compile and run..

I also sent a copy of the logs..

Attachments

Compile Error.png

This work item was migrated from CodePlex

CodePlex work item ID: '6'
Vote count: '1'
Reported on: 2016-07-09
Reported by: dnetbandit

Error stdlib ContiguousArrayBuffer

I hit a bug, when I tried some code which runs fine under Mac OS.

Fatal error: Index out of range: file C:/Work/swift_msvc/swift/stdlib/public/cor
e/ContiguousArrayBuffer.swift, line 409

The program reads a csv file, you can find a sample file in archive, if you want to reproduce the error.
Archive.zip

Wrong path in sublime build file

Hi,
I found a small issue with sublime build system shipped in package.
The swift.sublime-build file contains the following code:

{
"cmd": ["C:\Program Files\Swift\bin\swift", "$file_name"],
"path": "C:\Program Files\Swift\bin;%PATH%",
"file_regex": "^(.):([0-9]):([0-9]*):",
"selector": "source.swift"

}
the path to bin here is C:\Program Files\Swift\bin but the default install path is C:\SwiftForWindows\Swift\bin .

This work item was migrated from CodePlex

CodePlex work item ID: '2'
Vote count: '1'
Reported on: 2016-05-09
Reported by: mmvlad

Building DLLs

Thanks for all your work helping to bring Swift to Windows.

Do you plan to support building a DLL instead of an executable? This would help a lot for those of us interested in using Swift to write cross-platform libraries.

easiest way to get libswiftcore.dll

I have Swift For Windows 1.6 installed. I created a swift file with one line of code to test.
print("I have a furry angel in my apartment.")
This file compiles successfully, but when I run it, Windows complains about missing libswiftcore.dll. What is the easiest way to get this .dll? I googled Swift for Windows and this project seemed to be the easiest way to get started with to learn Swift except for missing this one .dll file.

Procedure entry point error executing Swift code

I have Swift 1.6 installed on a 64 bit Win 10 machine. My Swift source compiles successfully but encounters a procedure entry point error when the resulting code is run. The source code compiles and executes fine on a different machine, also with Swift 1.6 on a 64 bit Win 10.

The error message displayed is "The procedure entry point _T0S2ayxGAA12arrayLiterald_tcfCSf_Tgq5 could not be located in the dynamic link library C:\Swift\My Programs\new mm.exe

Any help would be appreciate. Thanks.

Error: use of unresolved identifier 'URLSession'

I've tried to compile this code below, but the compiler says:

error: use of unresolved identifier 'URLSession'
let session = URLSession.shared
              ^~~~~~~~~~
Compilation Failed

The code I am trying to compile:

import Foundation

guard let url = URL(string: "https://jsonplaceholder.typicode.com/users") else { print("url nil") }

let session = URLSession.shared
session.dataTask(with: url) { (data, response, error) in
    if let response = response {
        print(response)
    }
    
    if let data = data {
        print(data)
        do {
            let json = try JSONSerialization.jsonObject(with: data, options: [])
            print(json)
        } catch {
            print(error)
        }
        
    }
}.resume()

Can I use URLSession class with Swift For Windows?

Failed to compile Foundation

I just installed the software, and tried the samples. When I tried to run files with "import Foundation", it won't compile. Any other samples (and my Hello World) works just fine.

Here's the logs:

"C:/Swift/usr/bin/swiftc.exe" -swift-version 4 "D:\Project\Swift\main.swift" -o "D:\Project\Swift\main.exe"

:26:10: note: in file included from :26:
#include "../../../../../mingw64/include/regex.h"
         ^
C:\Swift\usr\lib\swift\mingw\x86_64/../../../../../mingw64/include/regex.h:11:10: error: 'tre/tre.h' file not found with  include; use "quotes" instead
#include 
         ^
:0: error: could not build C module 'SwiftMinGWCrt'


Compilation Failed

String init methods with "contentsOf" parameter not implemented

When I try to load the content of a webpage with the String class, it throws a "not implemented exception" on me. Can I somehow bypass this issue, or upgrade to a newer version?

Details:
Error: Fatal error: init(contentsOf:options:) is not yet implemented: file Foundation/NSData.swift, line 177
Example Code:

import Foundation
let source = "http://rss.cnn.com/rss/edition.rss"
let url = URL(string: source)
let content = try String(contentsOf: url!)
print(content)

Any ideas?

How to read txt file?

Is this possible? How would you do it?

My code:

import Foundation

let path = "file.txt"

do {
    // Get the contents
    let contents = try NSString(contentsOfFile: path, encoding: String.Encoding.utf8.rawValue)
    print(contents)
}
catch let error as NSError {
    print("Ooops! Something went wrong: \(error)")
}

The error:

Fatal error: fileExists(atPath:isDirectory:) is not yet implemented: file Foundation/FileManager.swift, line 580

violação de acesso (access violation)

A downloaded the swift for windows and tried the samples, all of them give the error:

Exceção sem tratamento em 0x000000006A88C12B (libswiftCore.dll) em Hello.exe: 0xC0000005: violação de acesso ao ler o local 0x000000000000003C.
I also tried to code a simple kind of hello world in another folder, and got the same error.

Download and reinstall donst fixed.

Cannot Import Global Modules

error: no such module 'Foundation'
import Foundation

This work item was migrated from CodePlex

CodePlex work item ID: '12'
Vote count: '1'
Reported on: 2017-04-06
Reported by: WitheredAway

One Question (use windows library)

can I compile to use windows libraries?
swiftc main.swift -L. -lwindowslib

Where windowslib it's file: libwindowslib.lib compiled by visual studio.

And if not, how I can compile compatible library written on cpp?
I tried clang++ and ld, but quickly failed...

How compile more files

I'm trying to compile a program consisting of several files:
swiftc main.swift file1.swift file2.swift -o Output.exe

The compilation passes, but during linking problems:
file1-93c003.o:(.text+0x330): multiple definition of swift_rt_swift_retain' main-e1cdbf.o:(.text+0x370): first defined here file1-93c003.o:(.text+0x340): multiple definition of swift_rt_swift_release'
main-e1cdbf.o:(.text+0x380): first defined here
file1-93c003.o:(.rdata+0xd8): multiple definition of __swift_reflection_version' main-e1cdbf.o:(.rdata+0x22): first defined here file2-9c3271.o:(.text+0x3f0): multiple definition of swift_rt_swift_allocObject'
file1-93c003.o:(.text+0x140): first defined here
file2-9c3271.o:(.text+0x800): multiple definition of swift_rt_swift_retain' main-e1cdbf.o:(.text+0x370): first defined here file2-9c3271.o:(.text+0x810): multiple definition of swift_rt_swift_release'
main-e1cdbf.o:(.text+0x380): first defined here
file2-9c3271.o:(.text+0x14e0): multiple definition of swift_rt_swift_slowAlloc' file1-93c003.o:(.text+0x6b0): first defined here file2-9c3271.o:(.text+0x14f0): multiple definition of swift_rt_swift_slowDealloc'
file1-93c003.o:(.text+0x6c0): first defined here
file2-9c3271.o:(.rdata+0x370): multiple definition of `__swift_reflection_version'
main-e1cdbf.o:(.rdata+0x22): first defined here
...

I have not considered?

Init Double from String did not work.

print(Double("42")!) crash
or
print(Float("42")!) crash
but
print(Int("42")!) fine

Creating a floating point value from a string, does not work for me.

UIKit

How to use UIKit in Swift for windows??

Command line interface.

There is no command line interface to call the compiler.
I cannot use a bat file to compile swift code.

This work item was migrated from CodePlex

CodePlex work item ID: '7'
Vote count: '2'
Reported on: 2016-08-24
Reported by: sandeepbagchi

Can't install Swift for Windows

Why I keep getting this "Error 1309" sign always when I try to install the program?
Here is the message.

Attachments

Error 1309.jpg

This work item was migrated from CodePlex

CodePlex work item ID: '8'
Vote count: '1'
Reported on: 2016-09-16
Reported by: JAndrew98

Not for 32 bits?

This is only for x64. You place the file for 32 system?

This work item was migrated from CodePlex

CodePlex work item ID: '3'
Vote count: '1'
Reported on: 2016-06-08
Reported by: rakshasyaka

Can't link module

Do I have to do something else under Windows than mac os to use a module.

C:\Swift\My Programs\SolarField>swiftc -emit-object -emit-module -wmo -module-name SolarField *.swift

C:\Swift\My Programs\SolarField>cd ..

C:\Swift\My Programs>swiftc -I ./SolarField main.swift ./SolarField/SolarField.o  -o SOF
./SolarField/SolarField.o:(.text+0x30): multiple definition of `swift_rt_swift_retain'
C:\Users\DANIEL~1.MUE\AppData\Local\Temp\main-b40e4f.o:(.text+0xcc0): first defined here
./SolarField/SolarField.o:(.text+0x70): multiple definition of `swift_rt_swift_release'
C:\Users\DANIEL~1.MUE\AppData\Local\Temp\main-b40e4f.o:(.text+0xcd0): first defined here
./SolarField/SolarField.o:(.rdata+0x22c0): multiple definition of `__swift_reflection_version'
C:\Users\DANIEL~1.MUE\AppData\Local\Temp\main-b40e4f.o:(.rdata+0x38): first defined here

mac os there were no errors with identical options.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.