Coder Social home page Coder Social logo

stackotter / swift-bundler Goto Github PK

View Code? Open in Web Editor NEW
280.0 6.0 13.0 1.12 MB

An Xcodeproj-less tool for creating cross-platform Swift apps.

Home Page: https://swiftbundler.dev

License: Apache License 2.0

Swift 99.62% Shell 0.38%
swift xcode macos swiftpm hacktoberfest

swift-bundler's Introduction

An Xcodeproj-less tool for creating cross-platform Swift apps.

Supporting Swift Bundler ❤️

If you find Swift Bundler useful, please consider supporting me by becoming a sponsor. I spend most of my spare time working on open-source projects, and each sponsorship helps me focus more time on making high quality tools for the community.

Documentation 📚

The documentation is hosted on the Swift Bundler website.

Installation 📦

Install the latest version of Swift Bundler with mint:

mint install stackotter/swift-bundler

If you have previously installed Swift Bundler via the installation script you must delete the /opt/swift-bundler directory (requires sudo).

For more installation methods, see the documentation.

Getting started 🚦

After installing Swift Bundler, package templates make it quick to get started. The following sections walk you through creating and running a simple 'Hello, World!' SwiftUI app.

Creating a SwiftUI app

# Create a new app from the SwiftUI template.
swift bundler create HelloWorld --template SwiftUI
cd HelloWorld

Running the app

# Build and run the app.
swift bundler run

Using Xcode as your IDE

# Creates the files necessary to get xcode to run the package as an app.
# Only needs to be run once unless you delete the `.swiftpm` directory.
swift bundler generate-xcode-support

# Open the package in Xcode
open Package.swift

Learning more

To learn more about Swift Bundler refer to the documentation.

Contributing 🛠

Contributions of all kinds are very welcome! Just make sure to check out the contributing guidelines before getting started. Read through the open issues for contribution ideas.

Apps made with Swift Bundler 👨‍💻

If you have made an app with Swift Bundler, I'd love to hear about it! Just open an issue or submit a PR to add it to the list.

  • Delta Client: A 'Minecraft: Java Edition' compatible Minecraft client written from scratch in Swift
  • ModularMTL: A modular multiplication visualisation made with Swift Bundler, SwiftUI and Metal

swift-bundler's People

Contributors

alessiodionisi avatar finestructure avatar furby-tm avatar joshuabrest avatar kabiroberai avatar stackotter 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

swift-bundler's Issues

Add option to remove log noise when using Xcode

Xcode is notorious for having a lot of unnecessary log noise which isn't at all useful. To fix this, OS_ACTIVITY_MODE=disable can be added to the Xcode scheme's environment variables. Given that Swift Bundler can generate Xcode schemes, it would be useful to be able to automatically add this environment variable.

[Probably User/OpenSSL Error] Failed to verify provisioning profile

This is more than likely just user error, or something strange in my openssl certificate chain, however when I run:

(if this is the correct usage)
swift bundler -v run -p visionOS --identity $env:DEV_IDENTITY --codesign --provisioning-profile /Path/To/xxx.provisionprofile

I receive the following error:

.../pk7_smime.c:340:Verify error:self signed certificate in certificate chain

Full error in context:

info: Starting debug build
debug: Running command: '/usr/bin/xcrun' with arguments: ["--sdk", "xros", "--show-sdk-path"]
debug: Running command: '/usr/bin/env' with arguments: ["swift", "build", "-c", "debug", "--product", "KrakenApp", "--arch", "arm64", "-Xswiftc", "-sdk", "-Xswiftc", "/Applications/Xcode-beta.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS1.0.sdk", "-Xswiftc", "-target", "-Xswiftc", "arm64-apple-xros1.0", "-Xcc", "--target=arm64-apple-xros1.0", "-Xcc", "-isysroot", "-Xcc", "/Applications/Xcode-beta.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS1.0.sdk"]
Building for debugging...
Build complete! (0.55s)
info: Bundling 'KrakenApp.app'
info: Creating 'KrakenApp.app'
info: Copying executable
info: Creating 'PkgInfo'
info: Creating 'Info.plist'
info: Compiling and copying resource bundle 'KrakenKit_KrakenKit.bundle'
info: Copying dynamic libraries
info: Embedding provisioning profile
debug: Running command: '/usr/bin/openssl' with arguments: ["smime", "-verify", "-in", "/Users/furby/dev/Atmos/KrakenKit/.build/bundler/KrakenApp.app/embedded.mobileprovision", "-inform", "der"]
Verification failure
8127874048:error:21FFF075:PKCS7 routines:CRYPTO_internal:certificate verify error:/AppleInternal/Library/BuildRoots/8f53d7fd-3013-11ee-8ab0-7a03568b17ac/Library/Caches/com.apple.xbs/Sources/libressl/libressl-3.3/crypto/pkcs7/pk7_smime.c:340:Verify error:self signed certificate in certificate chain
error: Failed to verify provisioning profile
debug: Error details: failedToCodesign(swift_bundler.CodeSignerError.failedToVerifyProvisioningProfile(swift_bundler.ProcessError.nonZeroExitStatusWithOutput(0 bytes, 4)))

App starts in the background when using "swift bundler run" or VSCode LLDB debugger [Solved with hack]

Problem

When using "swift bundler run" or running the App using VSCode LLDB Debugger, the app starts in the background. This can be tedious when the app is restarted often to see changes. The same does not happen when apps are started using Finder or Xcode.

Solution (Hack)

Explicitly activate the app from within. Here is the SwiftUI code that does this.

import SwiftUI

@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .task { await Activate() }
        }
    }

    // When starting the application using swift-bundler or debugging with LLDB in VSCode,
    // the application launches in the background unless we do this
    private func Activate() async {
        while !NSRunningApplication.current.activate() {
            try? await Task.sleep(for: .milliseconds(100))
        }
    }
}

This is not beautiful because we add unnecessary code into the released app. However, I could not find a way to activate the app from the outside since NSWorkspace.shared.openApplication() seems to do nothing on my M2 MacBook and NSRunningApplication would not attach to the app if it was started using Process.run().

Feel free to add this to the swift-bundler templates.

AppImage support

Started working on this today, this will just act as a tracking issue.

`swift bundler templates list` fails to read manifest for vscode templates

Running

swift bundler templates list

yields the following error

error: Failed to read the contents of the manifest for the 'VSCode' template

MacOS 14.3 (23D56)
swift-bundler v2.0.5 (according to mint, even though the latest github release is v2.0.4)
templates: up-to-date and on branch v3 (843e25997646e75b4365cb3d0f8e5dc6f7ca94bd), runs successfully on the main branch

Implement debugging mode

When using swift bundler run to build and run an app, Swift Bundler simply starts the app's main executable as a child process and waits for it to finish (similar to what swift run does), however, often you need to debug apps and Swift Bundler has no simple way to do so. I often end up running lldb .build/bundler/MyApp.app/Contents/MacOS/MyApp and then typing run in lldb; very cumbersome!

A good way to implement this would be to add a --lldb flag to the RunCommand struct, and then modify Runner.run to take an extra boolean argument labelled debug. My reason for not calling the --lldb flag --debug is that in many build systems (such as Rust's cargo), --debug affects the optimization of the executable instead of whether the executable should be run in a debugger or not. I'm open to better suggestions! After modifying Runner.run, you'll need to also update all of Runner's other platform specific run... methods to support running in a debugger. If you can't figure out a way to do so for some of the more obscure platforms such as visionOS or iOSSimulator, I'm happy for that to be completed in a future issue.

[Quickie] Possible to tag a new release from the main branch?

Hey there!

I'd like to set a package dependency on swift-bundler from my MetaverseKit Package, so that consumers of my package can transitively use swift-bundler as a swift build tool plugin using swift package plugin bundler. Specifically, I'm looking to use it to bundle visionOS apps, but there is no tagged version incorporating those changes as of yet, and since I expect this package to grow in popularity given it's the central core dependency for powering the initial working support of Pixar's USD for Swift package, I'd like to ensure I'm pulling from the official source, which is you @stackotter!

SwiftPM is quite strict about versioning, so if I were to tag a dependency on the bundler at the main branch, then it would wreak havoc for consumers depending on my package which I'd certainly like to avoid.

Thanks!

Improve configuration deserialisation error messages

Currently the debug description of the deserialisation is just included in the error message for ConfigurationError.failedToDeserializeConfiguration. This is ok for now, but it takes quite a bit of reading to figure out what is wrong with your configuration. Configuration errors are common and they should be as easy to diagnose as possible.

It would be preferable to have some sort of custom error message for each command codable error. This could probably be done by adding LocalizedError conformance to whichever Codable related errors can be thrown. It could also be improved by adding nice error descriptions to all of the errors in TOMLKit.

TOMLKit also doesn't seem to provide a correct coding path (it's always empty from what I've seen).

Provide JSON Schema for Configuration

Discussed this very briefly on Discord, but I think it would be really handy if we could provide a JSON schema document detailing every value supported in the configuration TOML file.

This would allow it to be used with plugins such as this one for VS Code which would provide code completion and validation of configurations improving the developer experience and hopefully reducing the number of issues developers face.

Taplo have stated they're happy for new schemas to be provided for native support, once the API is stabilised some, but even without pushing it upstream users can still utilise it if we host it on the documentation website 🙂

Tries to launch the app despite build errors

Trying to run

swift bundler run

when there are build errors, causes the app to launch and crash.

Building for debugging...
[0/4] Copying ShaderTypes.metal
[0/4] Copying Vertex.metal
[1/4] Copying Fragment.metal
[4/13] Compiling MetalSwiftUI RenderCoordinator.swift
[5/13] Compiling MetalSwiftUI TriangleRenderer.swift
[6/13] Compiling MetalSwiftUI Renderer.swift
[7/13] Emitting module MetalSwiftUI
[8/13] Compiling MetalSwiftUI MetalSwiftUIApp.swift
[9/13] Compiling MetalSwiftUI TriangleView.swift
[10/13] Compiling MetalSwiftUI MetalView.swift
[11/13] Compiling MetalSwiftUI MetalUtil.swift
[12/13] Compiling MetalSwiftUI resource_bundle_accessor.swift
[12/13] Linking MetalSwiftUI
Build complete! (4.34s)
SwiftUI/NSViewRepresentable.swift:246: Fatal error: NSViewRepresentables must be value types: MetalView<TriangleRenderer>
error: Failed to run app executable: The process returned a non-zero exit status (5)
info: Starting debug build
info: Bundling 'MetalSwiftUI.app'
info: Creating 'MetalSwiftUI.app'
info: Copying executable
info: Creating 'PkgInfo'
info: Creating 'Info.plist'
info: Fixing and copying resource bundle 'MetalSwiftUI_MetalSwiftUI.bundle'
info: Compiling metal shaders
info: Copying dynamic libraries
info: Done in 5.20s. App bundle located at './.build/bundler/MetalSwiftUI.app'
info: Running 'MetalSwiftUI.app'
image

Could it be that apple changed the exit code if the build fails with swift build?

swift-driver version: 1.87.3
Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
Target: arm64-apple-macosx14.0
MacOS 14.3 (23D56)
swift-bundler v2.0.5 (according to mint, even though the latest github release is v2.0.4)

Support Asset Catalogs

Developers migrating from Xcode will want Asset Catalogs to behave as they would expect when using Xcode, this is currently not the case. I don't actually know how Asset Catalogs work so I don't know what is involved in implementing this.

iOS build support

This shouldn't be too difficult. Just need to target the build for iOS and then create an ipa instead of a .app (the structure seems pretty similar in some ways.

Init Naming Conflicts

Using the init command uses the directory naming for its content. I initialized under a directory "bundler-testing" which created a compile error with the character -. This exception can be handled with a character substitute such as _ or the init command could include a name and create the associated directory which seems more consistent with existing cli's.

Linux build support

A major goal of this project is to eventually support building apps for Linux. There are many competing file formats that can be used to bundle binaries and resources into a single executable/installable file for distribution. Two major ones are deb and AppImage.

To add Linux build support you'll have to create a LinuxBundler type implementing the Bundler protocol. The architecture of this project is very much based off the functional programming paradigm, so it may take a little getting used to writing relatively pure functions (in this case static methods) and using Result instead of try and throw. The functional style of programming generally has a lot of benefits for build systems and related tools.

I believe that the first format to be implemented should be AppImage as it's generally more cross platform than deb. However there are other formats such as flatpak (which take a bit more setup), so I'm definitely open to discuss the options further! Feel free to choose either deb or AppImage if you're more familiar with one or the other.

Modify this line in Bundler.swift to return LinuxBundler.self once you've created the LinuxBundler type, and you should be able to test out your implementation simply by building a simple test project (which can be created using swift bundler create MyApp).

As always, I'm very happy to help out contributors, do don't hesitate to contact me on Discord (@stackotter), Twitter (@stackotter, or via email ([email protected]).

Add `--version`

Add a way for users to see what version they have installed (semver and commit hash)

The build scheme file (.xcscheme) made by generate-xcode-support can have unescaped spaces in the paths

Sonoma 14.4.1, Xcode 15.3, Swift 5.10, swift-bundler 2.0.3

To see it:

swift bundler create HelloBusted --template SwiftUI && \
cd HelloBusted && \
swift bundler generate-xcode-support && \
open Package.swift

Hit the big blue button to build & run... & it'll fail with the only semi useful error: Executable Path is a Directory.

Cause:

BuildAction & PathRunnable in HelloBusted.xcscheme both have paths to directories in ~/Library/Application Support/, & the space in Application Support isn't escaped.

Workaround:

Edit the file to escape any spaces in paths, eg Application\ Support, restart xCode & all's well. Application Support's likely to be there for everyone.

Fix:

Add another escape in Sources/swift-bundler/Bundler/XcodeSupportGenerator.swift I guess.

Extremely cool project, had it recommended to me yesterday. Thank you!

fails to install

Just tried to install it. Anything I should try?

% mint --version
Version: 0.17.5
% mint install stackotter/swift-bundler
🌱 Finding latest version of swift-bundler
🌱 Cloning swift-bundler v2.0.4
🌱 Resolving package
🌱 Building product swift-bundler
Building for production...
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
[0/9] Compiling Conversion.cpp
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
[1/10] Compiling Date&Time&DateTime.cpp
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
[2/11] Compiling Node.cpp
[3/11] Compiling Array.cpp
[5/11] Compiling ArgumentParserToolInfo ToolInfo.swift
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
[5/12] Compiling Table.cpp
[7/12] Compiling Logging Locks.swift
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
[8/13] Compiling Version Version+Codable.swift
[9/13] Compiling Rainbow BackgroundColor.swift
[10/13] Compiling TOMLKit InternalTOMLDecoder.swift
[11/13] Compiling ArgumentParser BashCompletionsGenerator.swift
[12/13] Compiling Parsing OneOfBuilder.swift
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
[13/14] Compiling swift_bundler Bundler.swift
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Bundler/SwiftPackageManager/SwiftPackageManager.swift:151:17: error: unable to infer type of a closure parameter '_' in the current context
        }.map { _, version, _ in
                ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Bundler/SwiftPackageManager/SwiftPackageManager.swift:151:20: error: unable to infer type of a closure parameter 'version' in the current context
        }.map { _, version, _ in
                   ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Bundler/Templater/IndentationStyle.swift:41:11: error: ambiguous use of 'parser(of:radix:)'
          Int.parser()
          ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/.build/checkouts/swift-parsing/Sources/Parsing/Parsers/Int.swift:37:22: note: found this candidate
  public static func parser(
                     ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/.build/checkouts/swift-parsing/Sources/Parsing/Parsers/Int.swift:59:22: note: found this candidate
  public static func parser(
                     ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Bundler/Templater/TemplaterError.swift:45:38: error: ambiguous use of 'buildBlock'
          Section("Troubleshooting") {
                                     ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Utility/OutputBuilder/OutputBuilder.swift:3:15: note: found this candidate
  static func buildBlock(_ components: OutputComponent...) -> String {
              ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Utility/OutputBuilder/OutputBuilder.swift:23:15: note: found this candidate
  static func buildBlock(_ components: OutputComponent...) -> [String] {
              ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Commands/CreateCommand.swift:104:48: error: ambiguous use of 'buildEither(first:)'
                  if let packages = value.brew {
                                               ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Utility/OutputBuilder/LineBuilder.swift:15:15: note: found this candidate
  static func buildEither(first component: OutputComponent) -> String {
              ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Utility/OutputBuilder/LineBuilder.swift:35:15: note: found this candidate
  static func buildEither(first component: OutputComponent) -> [String] {
              ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Commands/GenerateXcodeSupportCommand.swift:33:48: error: ambiguous use of 'buildBlock'
      Section("Opening your project in Xcode") {
                                               ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Utility/OutputBuilder/OutputBuilder.swift:3:15: note: found this candidate
  static func buildBlock(_ components: OutputComponent...) -> String {
              ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Utility/OutputBuilder/OutputBuilder.swift:23:15: note: found this candidate
  static func buildBlock(_ components: OutputComponent...) -> [String] {
              ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Commands/Templates/TemplatesInfoCommand.swift:42:32: error: ambiguous use of 'buildBlock'
      Section("Template info") {
                               ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Utility/OutputBuilder/OutputBuilder.swift:3:15: note: found this candidate
  static func buildBlock(_ components: OutputComponent...) -> String {
              ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Utility/OutputBuilder/OutputBuilder.swift:23:15: note: found this candidate
  static func buildBlock(_ components: OutputComponent...) -> [String] {
              ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Commands/Templates/TemplatesListCommand.swift:33:28: error: ambiguous use of 'buildBlock'
      Section("Templates") {
                           ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Utility/OutputBuilder/OutputBuilder.swift:3:15: note: found this candidate
  static func buildBlock(_ components: OutputComponent...) -> String {
              ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Utility/OutputBuilder/OutputBuilder.swift:23:15: note: found this candidate
  static func buildBlock(_ components: OutputComponent...) -> [String] {
              ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Configuration/ExpressionEvaluator.swift:22:9: error: ambiguous use of 'init()'
        End()
        ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/.build/checkouts/swift-parsing/Sources/Parsing/Parsers/End.swift:43:10: note: found this candidate
  public init() {}
         ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/.build/checkouts/swift-parsing/Sources/Parsing/Parsers/End.swift:49:10: note: found this candidate
  public init() {}
         ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Utility/OutputBuilder/List.swift:7:29: error: ambiguous use of 'buildBlock'
    for element in elements {
                            ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Utility/OutputBuilder/OutputBuilder.swift:3:15: note: found this candidate
  static func buildBlock(_ components: OutputComponent...) -> String {
              ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Utility/OutputBuilder/OutputBuilder.swift:23:15: note: found this candidate
  static func buildBlock(_ components: OutputComponent...) -> [String] {
              ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Utility/OutputBuilder/Section.swift:9:26: error: ambiguous use of 'buildOptional'
    if let title = title {
                         ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Utility/OutputBuilder/OutputBuilder.swift:11:15: note: found this candidate
  static func buildOptional(_ component: OutputComponent?) -> String {
              ^
/private/var/folders/qz/__f_gp0139d9172gy5lhx5f40000gp/T/mint/github.com_stackotter_swift-bundler/Sources/swift-bundler/Utility/OutputBuilder/OutputBuilder.swift:31:15: note: found this candidate
  static func buildOptional(_ component: OutputComponent?) -> [String] {
              ^
🌱 Encountered error during "swift build -c release --product swift-bundler -Xswiftc -target -Xswiftc arm64-apple-macosx13.3". Use --verbose to see full output
🌱  Failed to build swift-bundler v2.0.4 with SPM

Templates come without Bundler.toml

Running the following command

swift bundler create Test --template MetalSwiftUI

results in a folder that does not contain a Bundler.toml (regardless of template choice).

As a result, doing

cd Test 
swift bundler run

yields the following error

error: Failed to read the configuration file at './Bundler.toml'. Are you sure that it exists?

MacOS 14.3 (23D56)
swift-bundler v2.0.5 (according to mint, even though the latest github release is v2.0.4)
templates: up-to-date and on branch v3 (843e25997646e75b4365cb3d0f8e5dc6f7ca94bd), works perfectly on the main branch

Support for Swift 5.9 (Swift Syntax)

Hey @stackotter!

Hope your holidays have been treating you well!

I have made some small revisions to support Swift 5.9 (bumping swift-syntax and swift-format to Swift 5.9). It required very little changes (though I did not run the formatter across the codebase) as seen from my revision here: furby-tm@42d095f. I was curious if supporting Swift 5.9 at this time is something that you are interested in, if so - I can submit a PR for this, but I also know you are careful to support very specific versioning requirements in your efforts to allow clean Xcode archives for code signing within regards to app store submissions.

The main reason for the requirement to bump to Swift 5.9, at least in my use case, is to be able to add the swift-syntax dependency to my own package for use with Swift 5.9's macros, while still allowing to add the swift-bundler dependency to my package (else there are SwiftPM errors by using swift-syntax from: "509.0.0" since it conflicts with swift-bundler's exact: "0.50800.0-SNAPSHOT-2022-12-29-a".

Just let me know your thoughts! Thank you.

Create string descriptions for all errors

The error enums themselves are quite descriptive, but it would improve developer experience if those errors could be converted into more human readable strings. This would also involve ensuring that ArgumentParser displays the string descriptions of errors.

Gate macOS-only subcommands and arguments to macOS

At the moment commands such as list-identities and simulators are still available on Linux even though they don't work on Linux. If they ever work on Linux in the future we can add them back.

Simply disabling the subcommands on Linux is easy enough and not necessarily issue worthy, but I think this is a good opportunity to architect how Swift Bundler will handle host-platform specific bundler features (at the moment it only has to deal with target-platform specific features cause it mostly assumes that it's running on macOS).

Support sandboxing and code signing

Currently all Swift Bundler apps are non-sandboxed and aren't code signed. As Swift Bundler gets more users it would be useful to support such distribution features because code signing and sandboxing are important parts of shipping production-grade applications.

Support for bundling XPC Services

I would like to use swift-bundler to create an app that includes an XPC Service. For that the resulting .app directory needs to contain a directory Contents/XPXServices which in turn contains .xpc bundles.

A first step to make this possible would be to support dictionaries dictionaries as additional plist entries:

[apps.ServiceProvider]
product = "ServiceProvider"
version = "0.0.1" # The apps can specify separate versions
[apps.ServiceProvider.extra_plist_entries]
CFBundleIdentifier = "com.my.ServiceProviderXPC"
CFBundlePackageType = "XPC!"
XPCService = { ServiceType = "Application" }

results in

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleIdentifier</key>
    <string>com.my.ServiceProviderXPC</string>
    <key>CFBundlePackageType</key>
    <string>XPC!</string>
    <key>XPCService</key>
    <dict>
        <key>ServiceType</key>
        <string>Application</string>
    </dict>
</dict>
</plist>

Given this I could already add a manual step that adds my ServiceProvider to the already created bundle.

Fix log glitches when building

It seems like when Swift Bundler runs swift build, swift doesn't get given access to the interactive terminal, and its interactive output gets printed as separate lines and sometimes the lines get joined together for some reason.

Error when running MetalSwiftUI Template: NSViewRepresentables must be value types: MetalView<TriangleRenderer>

Creating a new app using swift bundler create MetalTest --template MetalSwiftUI and running the app without modification (swift bundler run) yields the following terminal output.

info: Bundling 'MetalTest.app'
info: Creating 'MetalTest.app'
info: Copying executable
info: Creating 'PkgInfo'
info: Creating 'Info.plist'
info: Fixing and copying resource bundle 'MetalTest_MetalTest.bundle'
info: Compiling metal shaders
info: Copying dynamic libraries
info: Done in 6.30s. App bundle located at './.build/bundler/MetalTest.app'
info: Running 'MetalTest.app'
SwiftUI/NSViewRepresentable.swift:246: Fatal error: NSViewRepresentables must be value types: MetalView<TriangleRenderer>
error: Failed to run app executable: The process returned a non-zero exit status (5)

Platform: M2 Max MacBook, macOS Sonoma 14.2.1
swift-bundler version: v2.0.3

Command Not Found via Xcode

Hi there 👋

Running into a little bit of an issue with using Xcode where it can't seem to find the Swift Bundler executable.

I installed the tool using mint (mint install stackotter/swift-bundler), created a new project following the commands on the README, and generated the Xcode support files.

If I run swift bundler run in Terminal it works as expected, and just for sanity, so does swift-bundler run.

However, if I build my project in Xcode, it compiles correctly ("Build Succeeded") but then throws an error.

Could not launch “HelloWorld”
The executable is missing. Please check your project settings and ensure that they produce a valid product.

If I check the logs, then it's clear the it's failing to run Swift Bundler:

/var/folders/54/7cl_0jq16sl8bg5xvn20skwm0000gn/T/SchemeScriptAction-SR1x7H.sh: line 2: swift-bundler: command not found

I've tried the standard lark of restarting Xcode and all that jazz to no avail.

Using Xcode 13.3.1 (latest non-beta), and bundler version 2.0.2 (latest).

Looking forward to giving this tool a try out. Thanks 🙂

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.