diff --git a/.gitignore b/.gitignore index 3120a0fbb..b33935efb 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,6 @@ gha-creds-*.json # Ignore local `direnv` cache .direnv + +# Ignore build data for sourcekit-lsp (Swift code) +buildServer.json diff --git a/swift/apple/Firezone.xcodeproj/project.pbxproj b/swift/apple/Firezone.xcodeproj/project.pbxproj index 7c120820d..977653f2c 100644 --- a/swift/apple/Firezone.xcodeproj/project.pbxproj +++ b/swift/apple/Firezone.xcodeproj/project.pbxproj @@ -271,7 +271,6 @@ name = FirezoneNetworkExtensioniOS; packageProductDependencies = ( 794C38142970A2660029F38F /* FirezoneKit */, - 8D4087D42D24653B005B2BAF /* Sentry */, ); productName = FirezoneNetworkExtensioniOS; productReference = 05CF1CF0290B1CEE00CF4755 /* dev.firezone.firezone.network-extension.appex */; @@ -293,7 +292,6 @@ name = FirezoneNetworkExtensionmacOS; packageProductDependencies = ( 8D5047F72CE6AA22009802E9 /* FirezoneKit */, - 8D4087D82D246541005B2BAF /* Sentry */, ); productName = FirezoneNetworkExtensionStandalonemacOS; productReference = 8D5047E32CE6A8F4009802E9 /* dev.firezone.firezone.network-extension.systemextension */; @@ -320,7 +318,6 @@ name = Firezone; packageProductDependencies = ( 79756C6529704A7A0018E2D5 /* FirezoneKit */, - 8D4087DC2D246651005B2BAF /* Sentry */, ); productName = Firezone; productReference = 8DCC021928D512AC007E12D2 /* Firezone.app */; @@ -359,7 +356,6 @@ ); mainGroup = 8DCC021028D512AC007E12D2; packageReferences = ( - 8D4087C72D2464D6005B2BAF /* XCRemoteSwiftPackageReference "sentry-cocoa" */, ); productRefGroup = 8DCC021A28D512AC007E12D2 /* Products */; projectDirPath = ""; @@ -968,16 +964,6 @@ }; /* End XCConfigurationList section */ -/* Begin XCRemoteSwiftPackageReference section */ - 8D4087C72D2464D6005B2BAF /* XCRemoteSwiftPackageReference "sentry-cocoa" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/getsentry/sentry-cocoa"; - requirement = { - kind = upToNextMajorVersion; - minimumVersion = 8.42.1; - }; - }; -/* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ 794C38142970A2660029F38F /* FirezoneKit */ = { @@ -988,21 +974,6 @@ isa = XCSwiftPackageProductDependency; productName = FirezoneKit; }; - 8D4087D42D24653B005B2BAF /* Sentry */ = { - isa = XCSwiftPackageProductDependency; - package = 8D4087C72D2464D6005B2BAF /* XCRemoteSwiftPackageReference "sentry-cocoa" */; - productName = Sentry; - }; - 8D4087D82D246541005B2BAF /* Sentry */ = { - isa = XCSwiftPackageProductDependency; - package = 8D4087C72D2464D6005B2BAF /* XCRemoteSwiftPackageReference "sentry-cocoa" */; - productName = Sentry; - }; - 8D4087DC2D246651005B2BAF /* Sentry */ = { - isa = XCSwiftPackageProductDependency; - package = 8D4087C72D2464D6005B2BAF /* XCRemoteSwiftPackageReference "sentry-cocoa" */; - productName = Sentry; - }; 8D5047F72CE6AA22009802E9 /* FirezoneKit */ = { isa = XCSwiftPackageProductDependency; productName = FirezoneKit; diff --git a/swift/apple/Firezone.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/swift/apple/FirezoneKit/Package.resolved similarity index 100% rename from swift/apple/Firezone.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved rename to swift/apple/FirezoneKit/Package.resolved diff --git a/swift/apple/FirezoneKit/Package.swift b/swift/apple/FirezoneKit/Package.swift index 779396825..2d93ee546 100644 --- a/swift/apple/FirezoneKit/Package.swift +++ b/swift/apple/FirezoneKit/Package.swift @@ -12,7 +12,7 @@ let package = Package( .library(name: "FirezoneKit", targets: ["FirezoneKit"]) ], dependencies: [ - .package(url: "https://github.com/getsentry/sentry-cocoa", from: "8.55.0") + .package(url: "https://github.com/getsentry/sentry-cocoa", exact: "8.49.0") ], targets: [ .target( diff --git a/swift/apple/Makefile b/swift/apple/Makefile index 226b63aeb..c885c05d0 100644 --- a/swift/apple/Makefile +++ b/swift/apple/Makefile @@ -9,9 +9,13 @@ export MACOSX_DEPLOYMENT_TARGET=12.4 build-macos: echo "Building debug build for ${PLATFORM}, ${ARCH}" - cd ../../rust/apple-client-ffi && rm -rf ./Connlib.xcframework && ./build-rust.sh && ./build-xcframework-dev.sh @xcodebuild build -scheme Firezone -sdk macosx -destination 'platform=${PLATFORM},arch=${ARCH}' +# Info for sourcekit-lsp (LSP server for other IDEs) +lsp: + @xcode-build-server config \ + -project Firezone.xcodeproj \ + -scheme Firezone .PHONY: install install: diff --git a/swift/apple/README.md b/swift/apple/README.md index f83a38e97..cdea5b6f6 100644 --- a/swift/apple/README.md +++ b/swift/apple/README.md @@ -48,6 +48,10 @@ and configurations without risking your main machine. 1. Build and run the `Firezone` target. +`Firezone` target will orchestrate building `connlib` with Rust as an Xcode +build phase. Xcode build can be triggered both from Xcode UI or via the +`Makefile`. + **Note**: To test the iOS app, you'll need a physical iOS device such as an iPhone or iPad. Network Extensions can't be debugged in the iOS simulator. @@ -89,6 +93,52 @@ iPhone or iPad. Network Extensions can't be debugged in the iOS simulator. scripts/build/macos-standalone.sh ``` +## Developing + +### IDE + +The most obvious and encouraged IDE choice for Firezone macOS/iOS development is +Xcode. It is required for: + +- configuring code signing / provisioning +- performing any project-related changes (editing Xcode project manually can + break it) +- debugging +- analyzing the app in [Instruments](#instruments) + +Note: Although Swift and sourcekit-lsp are technically cross-platform, this +method still relies on Xcode to build the project. However, if you prefer to use +another IDE for code editing, you can use any LSP-compatible editor (such as +Neovim, VSCode, Zed, Emacs etc) with `sourcekit-lsp` support. + +In order to configure your IDE follow these steps: + +```sh +brew install xcode-build-server +make lsp +make build +``` + +Note: Although Swift and sourcekit-lsp are technically cross-platform, this +method still relies on Xcode to build the project. + +### Instruments + +`Instruments` is a powerful performance analyzer and visualizer application +developed by Apple, integrated in Xcode. It helps developers profile, debug, and +optimize their applications by tracking various metrics such as CPU activity, +memory allocation, file and network usage, graphics rendering, and energy +consumption. Instruments uses a timeline view to show events in apps like CPU +usage spikes, memory leaks, and UI responsiveness issues. + +#### What to look for in Instruments + +##### network extension memory usage + +iOS has a 50 MB hard cap on memory usage in the network extension. Whenever we +make changes to our threading model it's a good idea to double-check we don't go +over there. + ## Debugging [This Network Extension debugging guide](https://developer.apple.com/forums/thread/725805)