Generator lacks necessary write permissions
Description
Problem:
It looks like this is failing when the generator tries to write code to disk. I didn't see any documentation surrounding any custom commands to allow write permissions here. Some additional context here is that this is my first using this package so it's also highly likely that I'm overlooking some step here.
Steps to reproduce: I really just followed the steps in WWDC 23 Meet Swift OpenAPI Generator:
- start an Xcode project
- add package dependencies: this generator, openapi-runtime, openapi-urlsession
- added a
openapi.yamland aopenapi-generator-config.yaml
I added boilerplate code to both of the those files just to get up and running:
Then when I try to compile I run into this error:
Actual error:
PhaseScriptExecution Running\ swift-openapi-generator /Users/sergiobost/Library/Developer/Xcode/DerivedData/ArabicCompanion-gnmdkprcrvllgsfpsajpeqkvsbob/Build/Intermediates.noindex/ArabicCompanion.build/Debug-iphonesimulator/ArabicCompanion.build/Script-092C41A72C630A2A00E9275D.sh (in target 'ArabicCompanion' from project 'ArabicCompanion')
cd /Users/sergiobost/Developer/ArabicCompanion
/bin/sh -c /Users/sergiobost/Library/Developer/Xcode/DerivedData/ArabicCompanion-gnmdkprcrvllgsfpsajpeqkvsbob/Build/Intermediates.noindex/ArabicCompanion.build/Debug-iphonesimulator/ArabicCompanion.build/Script-092C41A72C630A2A00E9275D.sh
/Users/sergiobost/Library/Developer/Xcode/DerivedData/ArabicCompanion-gnmdkprcrvllgsfpsajpeqkvsbob/Build/Intermediates.noindex/ArabicCompanion.build/Debug-iphonesimulator/ArabicCompanion.build/Script-092C41A72C630A2A00E9275D.sh: line 20: 3301 Segmentation fault: 11 /usr/bin/sandbox-exec -p "(version 1)
(deny default)
(import \"system.sb\")
(allow file-read*)
(allow process*)
(allow mach-lookup (global-name \"com.apple.lsd.mapdb\"))
(allow file-write*
(subpath \"/private/tmp\")
(subpath \"/private/var/folders/78/yjpmxwh95132drb2ql_fvxym0000gn/T\")
)
(deny file-write*
(subpath \"/Users/sergiobost/Developer/ArabicCompanion\")
)
(allow file-write*
(subpath \"/Users/sergiobost/Library/Developer/Xcode/DerivedData/ArabicCompanion-gnmdkprcrvllgsfpsajpeqkvsbob/SourcePackages/plugins/ArabicCompanion.output/ArabicCompanion/OpenAPIGenerator\")
(subpath \"/private/var/folders/78/yjpmxwh95132drb2ql_fvxym0000gn/T/TemporaryItems\")
(subpath \"/private/var/folders/78/yjpmxwh95132drb2ql_fvxym0000gn/T/TemporaryItems/NSIRD_Xcode_K2tNy8\")
)
" "/${BUILD_DIR}/${CONFIGURATION}/swift-openapi-generator" generate /Users/sergiobost/Developer/ArabicCompanion/ArabicCompanion/openapi.yaml --config /Users/sergiobost/Developer/ArabicCompanion/ArabicCompanion/openapi-generator-config.yaml --output-directory /Users/sergiobost/Library/Developer/Xcode/DerivedData/ArabicCompanion-gnmdkprcrvllgsfpsajpeqkvsbob/SourcePackages/plugins/ArabicCompanion.output/ArabicCompanion/OpenAPIGenerator/GeneratedSources --plugin-source build
Command PhaseScriptExecution failed with a nonzero exit code
Reproduction
openapi.yaml looks like this:
openapi: '3.1.0'
info:
title: GreetingService
version: 1.0.0
servers:
- url: https://example.com/api
description: Example service deployment.
paths:
/greet:
get:
operationId: getGreeting
parameters:
- name: name
required: false
in: query
description: The name used in the returned greeting.
schema:
type: string
responses:
'200':
description: A success response with a greeting.
content:
application/json:
schema:
$ref: '#/components/schemas/Greeting'
components:
schemas:
Greeting:
type: object
description: A value with the greeting contents.
properties:
message:
type: string
description: The string representation of the greeting.
required:
- message
the openapi-generator-config.yaml looks like this:
generate:
- types
- client
accessModifier: internal
Package version(s)
MacOS version: Version 15.1 Beta (24B5009l)
Xcode version: Version 16.0 beta 5 (16A5221g) - same issue in beta 4 as well
swift-openapi-generator 1.3.0
swift-openapi-runtime 1.5.0
swift-openapi-urlession 1.0.2
Expected behavior
Just for this to compile and get started using this package.
Environment
Apple Swift version 6.0 (swiftlang-6.0.0.6.8 clang-1600.0.23.1)
Target: arm64-apple-darwin24.1.0
Additional information
I believe it's hiding a crash, can you confirm what macOS version you're running? If there's a crash log, can you share the crashing thread's backtrace?
Yes, I've updated the original post with the Mac version (Version 15.1 Beta (24B5009l) and provided a txt file with the full stack trace under Additional information
You might need to update to 15 beta 5 (24A5309e), the same beta drop that matches the Xcode one.
I'll give it a shot.
Got it working, thanks for the support. Feel free to close this issue.