Skip to content

Commit

Permalink
Append Command line app
Browse files Browse the repository at this point in the history
  • Loading branch information
florentmorin committed Aug 10, 2022
1 parent 6e2363d commit 830d828
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
xcuserdata/
.build/
.DS_Store
.DS_Store
/CommandLineApp/build
20 changes: 20 additions & 0 deletions CommandLineApp/Hello.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// Hello.swift
// InternalFramework
//
// Created by Florent Morin on 19/07/2022.
//

import Foundation

public final class Hello {
public let name: String

public init(name: String) {
self.name = name
}

public func printHello() {
print("Hello \(name)!")
}
}
11 changes: 11 additions & 0 deletions CommandLineApp/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

if [[ -d "build" ]]; then
rm -rf build
fi

mkdir build
mkdir build/lib

swiftc Hello.swift -g -Onone -emit-module -emit-library -static -o build/lib/libHello.a
swiftc main.swift -g -Onone -L ./build/lib/ -I ./build/lib/ -lHello -o build/app
8 changes: 8 additions & 0 deletions CommandLineApp/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Foundation
import Hello

public func printHelloFlo() {
Hello(name: "Florent").printHello()
}

printHelloFlo()
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,49 @@ The project can be tested by opening `AppWithInternalFramework/AppWithInternalFr

If you run the app on a simulator, a shared breakpoint will be triggered.

### In command line

In a Terminal:

```sh
cd ./CommandLineApp
./compile.sh

```

In another Terminal:

```sh
lldb
```

In LLDB:

```lldb
(lldb) process attach -n 'app' --waitfor
```


Then, in first Terminal:

```sh
./build/app
```

Back to LLDB, once detected:

```lldb
(lldb) breakpoint set -f Hello.swift -l 18
(lldb) continue
```

Wait for breakpoint to be called...

```lldb
(lldb) po name
```


## Tests results

| Xcode version | Result |
Expand Down

0 comments on commit 830d828

Please sign in to comment.