I have a simple Swift script that I'd like to step into using LLDB but having a hard time making sense of the documentation. If I run the following inside the REPL:
:target create ./myswiftfile.swift
I get back
error: './test.swift' doesn't contain any 'host' platform architectures: x86_64h, x86_64, i386
Is it possible to either set the arch from inside the REPL or otherwise invoke myswiftfile in a way that gets me into the debugger? I realize I can debug inside Xcode using the Command Line Tool template but it's a shame given how lightweight a simple Swift script can be. Basically looking for pdb for Swift.
lldb does not currently support compiling swift files for you and then loading them into the debugger or the REPL. It wouldn't be all that hard to do. The best thing to do is to file an enhancement request with bugreporter.apple.com.
Related
I'm currently trying to create an executable for my Vapor application, but I just can't run it on my server.
My expectation was that it would be able to create a single application with all my code and the dependencies. My current references are .NET and Go, where you can create a single executable from the code and deploy this standalone file - which makes it amazingly simple to deploy.
I tried compiling and executing it on Docker, but no such luck - it failed with some libSwift something missing.
So, can Swift do something like this?
Looking forward to your answers
You can build a binary that statically links the standard library or build a completely self contained binary using the static linking flags introduced in Swift 5.3.1 - -static-stdlib and -static-executable. See this forum post for more details.
Note that swift still has some dependencies on ICU and libc so aren't completely portable yet
EDIT: Getting negatives for such a detailed and HONEST question? Sometimes I don't really get Stack Overflow. Really.
Hi, I'm trying to create a PoC using Swift 5 (Xcode 10.2.1) and a modern rendition of ncurses (in this case, MacPorts' one, some 6.1.2018XXXX version)
My Poc has no code as of now, as my problems start before being able to add any sensible line to my .swift files.
So far I've done the following things:
1.- I have a proper working MacPorts ncurses library installed: that means "sudo port install htop" can build "htop" application without any problem, proving that way that my ncurses library is correctly installed (.h files seem to be deployed inside /opt/local/include/ directory)
2.- I create an empty CONSOLE APPLICATION swift program (using Xcode 10.2.1 own wizard). It just takes 4 mouse clicks, and you get some "Hello world" silly main.swift file.
3.- I create a bridging header to import my .h files (in this case ncurses.h).
The contents of this bridging header will/should be something like this:
#import "/opt/local/include/ncurses.h"
4.- I compile and run the silly empty "hello world" swift program, and I get tons of somewhat "expected" errors. Something like:
"Darwin/SDK curses.h symbol xxxxxxxxx is also defined inside your /opt/local/ncurses.h file. Bailing out." (it's not the literal error I get, you just get the idea)
So my question is:
Can I disable/remove Darwin/internal/MacOs SDK curses.h from my XCode project definition somewhere, in order my bridging header only sees one copy of my 2 (n)curses.h file (that should be my macports one)?
I've tried many things described in this other thread, but with no luck: How to disable "curses.h" header (a part of "stdio.h in Xcode 6.3 OSX Yosemite) to avoid conflicting function declarations
Specially "Enable Modules" option, which no matter the value you set it to, seems to do nothing.
BTW: I know when I might solve this .h headers issue, I will probably need to add some additional -lib linking option in the "build phase"(?) tab inside Xcode, but I'll try to manage myself when that moment arrives.
As of now my concern is "I wan't to remove Apple Internal Macos SDK curses support/files from my Xcode project". Is it achievable?
PS: I'm using Mojave 10.4.4 with no problem
I'm having the same issues, although trying to use ncurses via the Swift Package Manager. Despite being actively trying to find a solution I've been unsuccessful so far. Check my question just in case: Swift package manager unable to compile ncurses installed through Homebrew
This answer should give you all the information you need to get it working :) https://stackoverflow.com/a/56728436/554972
My steps were:
1) In Xcode, I create a new command-line OS X Swift app and add their example "class Dog" code, plus "import RealmSwift" at the top.
2) I add a Podfile with two lines, "use_frameworks!" and "pod 'RealmSwift'" and then run pod install.
3) I open the workspace, compile, and run. I get this warning:
Not running swift-stdlib-tool: EMBEDDED_CONTENT_CONTAINS_SWIFT is enabled, but the product type 'Command-line Tool' is not a wrapper type.
And this crash:
dyld: Library not loaded: #rpath/libswiftAppKit.dylib
Referenced from: /Users/ys1382/Library/Developer/Xcode/DerivedData/testRealmApp-gxysfwfiirxwddbklmbolznecnld/Build/Products/Debug/RealmSwift.framework/Versions/A/RealmSwift
Reason: image not found
So far googling indicates the warning and crash are related. Any suggestions?
I'm using OS X El Capitan, Xcode 7.2.1, Cocoapods 0.39.0
TiM's comment led me to find out that, as of this writing, it's almost impossible to add frameworks to Swift command-line apps. This blog post describes one way. Starting with step 1, it says:
Create an Objective-C command line tool and change the Search Paths.
Not Swift. You can create a Swift framework for the code you’d put in your command line tool, but the tool itself must not compile any Swift code. Doing so will confuse the linker and make it see duplicate declarations of the Swift library (one in the shipped .dylib, another embedded in the command line tool).
This presentation shows a different approach, starting with creating a Cocoa app, and then coercing it into a command-line app, in 31 steps.
It was at that point I thought, "mmmaybe my command line tool could use some nifty graphics after all" and made a Cocoa OSX Swift Realm Cocoapod app instead, which worked.
I want to read data from GtkListStore and build an excel by phpExcel. First, I build a php file according to the GtkListStore, then I use php and phpexcel lib to compile and build execl file.
In my gtk code (compile in MinGW environment), I use execvp(cmd[0], (const char **)cmd); to call the external command -- php. In fact, cmd[0] is php.exe and cmd[1], cmd[2] ... are the parameters for php. After calling the php command, my gtk main window is closed and it quits my gtk program.
How can I prevent the php command from quitting main program? Should I use something else instead of execvp? Thank you.
execvp() and friends replace the current process with another process, so it's no surprise that your program quits. Use g_spawn_sync() or a related function - that will run your php program, then return control to your original program.
Let me answer my own question. Followed is the summary to what I have googled and tried within the past few days. It has nothing new but maybe is useful to a newbie like me.
First, thank ptomato. To avoid my problem in GTK, it must use g_spawn_sync or related functions. If your command is absolute path, you don't have to use the flag G_SPAWN_SEARCH_PATH, otherwise, make sure to use the flag.
Following are something related in MinGW environment.
-> gspawn-win32-helper.exe
In MinGW, to use g_spawn_sync, it must have gspawn-win32-helper.exe installed. When I installed GTK environment, I only extracted the useful lib or exe file I think it is useful then I missed gspawn-win32-helper.exe and it resulted in the problem -- Failed to execute helper program (No such file or directory) mentioned in the above comments. After extracting gspawn-win32-helper.exe from ftp://ftp.gtk.org/pub/glib/2.10/win32/glib-2.10.0.zip and installing it, g_spawn_sync worked.
-> For canonical Windows paths, both double backslashes and single forward slash work, e.g., c:/foo/bar and c:\foo\bar work.
I have a PySide/Phonon app (developed for and working flawlessly on Windows) that I need to "port" to Mac OSX - where I have no development experience whatsoever.
The app works as expected if I just run the Python file - the problems arise when I try to package it (which I need to do) with py2app.
If I leave the resulting .app as is, Phonon doesn't work, because it fails to load the required phonon_backend ; if I add the plugin path to qt.conf, as various sources suggest, Phonon seems to load (that is, I don't get the corresponding error message anymore), but I start getting the "so-and-so library is loaded twice, one will be used, which one is undefined" error, and the app crashes right away.
Finally, if I try to use the macdeploy_qt tool, I receive a message to the effect of "no external framework" and the results are functionally equivalent to what I get without using the tool, except there are a few more plugins in the relevant directory.
Any ideas/pointers/tutorials/etc? I'm using PySide1.1.1 for Qt4.7, by the way, and Python.org python binaries (otherwise py2app can't even start to build a standalone app, it seems).
I suggest you do it like in this tutorial.
Then you just have to add the following line somewhere at the top of your main module:
QApplication.setLibraryPaths([os.path.join(os.environ['_MEIPASS2'], 'qt4_plugins'), os.environ['_MEIPASS2'] ])
For PyInstaller >1.5 the following code should be used instead:
QApplication.setLibraryPaths([os.path.join(sys._MEIPASS, 'qt4_plugins'), sys._MEIPASS])