Post

Replies

Boosts

Views

Activity

Reply to Multi-line mathematical expressions
I tried out your multiline expression in an Xcode playground (Swift 5.1.2). You separate at addition (probably also subtraction), but not at multiplication (probably also for division). Didn't try the comments, but, like C/C++, inline comments should be treated like whitespace during the lexical analysis, so, it should work.
Nov ’19
Reply to How to create an alternative toolchain
This works for me:1 - Create a directory, say, MyToolchain (don't add a file extension, yet)2 - cd to the directory, and create an Info.plist file. I use an application called PListEditor, you can use Xcode, or you can manually edit the XML in a text file. It needs to have, as a minimum, a key called CFBundleIdentifier, as a String, with something that will identify the bundle to Xcode. Typically it's something like a reversed domain name, like, person.jprescott.MyToolchain, or, just MyToolchain, if you want.3 - Put in a usr directory that has all your tools, library, etc, include. It should have all your tools you might need with Xcode (compilers, linkers/loaders, archivers, ) header files to be searched as part of the system header search paths (doesn't have to be all of /usr/include), libraries to be linked, etc.. This is a standard usr layout you would find on any Unix/Linux, but only has the tools necessary to compile, analyze, link your programs.4 - Put in other directories that you might need. Apple, for example, puts in a Developer directory that holds various frameworks that are relevant. If you open Xcode.app with "Show Contents" and go to Developer>Toolchains, and open the default toolchain using "Show Contents," you'll see an example of the organization beyond just usr.5 - When you're done, change the directory filename to "MyToolchain.xctoolchain". You'll be asked to verify that you want to change the name. When you answer yes, the icon for the directory will change to the Xcode toolchain icon, and the directory looks like a single file. If you want to get to the directory contents, you open the toolchain with "Show Contents"6 - Move the new toolchain to either /Library/Developer/Toolchains, for system use, or ~/Library/Developer/Toolchains. It will then be visible in Xcode Preferences as a toolchain option.Each toolchain should address a single version of whatever compiler(s) you are using. You could put clang and gcc in the same toolchain, but, only one version of clang/gcc unless you give the compilers different names. I have LLVM toolchains org.llvm.8.0.0svn, org.llvm.9.0.0svn, org.llvm.10.0.0.git that have only the version of clang/llvm in them. However, Xcode includes a version of gcc along with clang (gcc points to clang, but, it is a separate executable) in the default toolchain.If you are asking for use with Linux, or other IDEs, you'll have to ask elsewhere.Hope this helps.
Dec ’19
Reply to Deleted Function
The following program compiles:#include <thread> void sampler() { } struct Sampler { void operator()() { } }; struct NotASampler { }; int main(int argc, const char* argv[]) { auto lsampler = []() { }; std::thread t1(sampler); std::thread t2((Sampler())); std::thread t3(lsampler); //std::thread t4((NotASampler())); return 0; }Note that trying to create a thread with the "NotASampler" gives the same error you mentioned in your post. You can't create a thread with a non-functional struct/class. Note also the need for an extra pair of parentheses around the call to the functional "Sampler," which is needed because you are not passing a function pointer.Compiled with --std=c++17
Dec ’19
Reply to Execute text field after each letter
You might want to look at the Apple documentation on Key Events to get a general overview of how key events and keyboard processing works. You also need to look at NSResponder keyDown and keyUp methods. A text field is derived from a view which is derived from NSResponder, so, you will override those methods to handle your custom textfield processing.
Jan ’20
Reply to Changing build config for a single included package
You'll have to look at the build settings for this package and figure out what settings are different between Release and Debug. I would concentrate on differences in optimization settings, and, if there are C/C++/Objective-C components, you might want to look at the preprocessor macros, but any differences between the Release and Debug build settings should be investigated.Once you figured out what the significant differences between Release and Debug are for the package in question, you need to change the Debug settings to match the relevant Release settings. I would be careful about this, or give yourself some means by which you can go back to the Debug setting if you ever have to debug this package. Some optimizations commonly used to speed up Release speeds do a lot of code restructuring that makes it extremely difficult to debug, if there is a problem.You can change the settings manually, or you can put the changes in an .xcconfig file. Note that if you ever end up upgrading the package to a new version, you will need to re-apply the build setting changes. If you use an .xcconfig file to record the changes, you can store that .xcconfig in your project workspace, and re-apply it after the package gets updated.I'm assuming that the package manifest is not under your control. If you have control over the manifest file contents, there is potential in the .unsafeFlags methods for the swiftSettings/cSettings/cxxSettings method in the target descriptions, but, as the name applies, these are considered unsafe by the SPM builders and maintainers, and there are restrictions on the use of these methods.
Jan ’20
Reply to Hi. I'm a new developer. This is my first question. I'd like to learn the syntax of Xcode so I can debug my Swift projects? How/where to learn this?
The Xcode debug section is covered at a basic level in the Xcode Help reference accessed via the Xcode Help menu item. The LLDB debugger (the program Xcode shows in the console window when you start debugging) is documented at lldb.llvm.org . There are third party books about Xcode development out there. If you need help with the Swift language, there is swift.org or the "Swift Language Reference" in the Apple bookstore (it's free).
Feb ’20
Reply to How to access preprocessor macros from build script?
You need to omit the braces.When you say "preprocessor macros", are you setting up a user-defined environment build setting, or are you actually assigning values to the "Preprocessor Macros" build setting? If it's the latter, I don't think pre-processor macro definitions are available to run scripts except through the GCC_PREPROCESSOR_MACROS environment variable which is set from the build settings. If you are setting the value for "myflag" in the build settings via the GCC_PREPROCESSOR_MACROS (the "Preprocessor Macros" build setting), you'll have to parse the whole macro definition to find "myflag"You can set user-defined environment variables for Xcode via .xcconfig files (look up "xcconfig" files in Xcode documentation, and/or the Internet).
Feb ’20
Reply to Optional Protocol Type
You probably also have to make Customer and Contractor classes, not structs. This whole architecture looks like it needs reference types, not value types. If you want to assign an instance of Customer to UserData.account, it has to be a sub-class of AProfile.
Feb ’20