Laurine: Xcode 10.2 error

I get this error when running in Xcode 10.2 - Swift 4.2

0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret /Users/emil/Virksomheder/Projekter/sense-ios/Sense/Sense/Libraries/LaurineGenerator.swift -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -module-name LaurineGenerator -- -i /Users/emil/Virksomheder/Projekter/sense-ios/Sense/Sense/Assets/en.lproj/Localizable.strings -o /Users/emil/Virksomheder/Projekter/sense-ios/Sense/Sense/Helpers/Localizations.swift -c true 0 swift 0x00000001080cfee3 PrintStackTraceSignalHandler(void*) + 51 1 swift 0x00000001080cf6bc SignalHandler(int) + 348 2 libsystem_platform.dylib 0x00007fff71114b5d _sigtramp + 29 3 libsystem_platform.dylib 000000000000000000 _sigtramp + 2398008512 4 libswiftCore.dylib 0x00007fff70959c09 _swift_updateClassMetadataImpl(swift::TargetClassMetadata<swift::InProcess>*, swift::ClassLayoutFlags, unsigned long, swift::TypeLayout const* const*, unsigned long*, bool) + 265 5 libswiftCore.dylib 0x00007fff70959c4b swift_updateClassMetadata2 + 27 6 libswiftCore.dylib 0x000000010b1d14ce swift_updateClassMetadata2 + 2592569502 7 libswiftCore.dylib 0x00007fff70961b77 swift::MetadataCacheEntryBase<(anonymous namespace)::SingletonMetadataCacheEntry, int>::doInitialization(swift::ConcurrencyControl&, swift::MetadataCompletionQueueEntry*, swift::MetadataRequest) + 215 8 libswiftCore.dylib 0x00007fff709573f3 swift_getSingletonMetadata + 579 9 libswiftCore.dylib 0x000000010b1b01af swift_getSingletonMetadata + 2592444415 10 libswiftCore.dylib 0x000000010b1b013c swift_getSingletonMetadata + 2592444300 11 swift 0x000000010496719d llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) + 365 12 swift 0x000000010496d572 llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, char const* const*) + 1090 13 swift 0x0000000103f365d1 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 58913 14 swift 0x0000000103f246de swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6862 15 swift 0x0000000103ec27be main + 1246 16 libdyld.dylib 0x00007fff70f2f3d5 start + 1 /Users/emil/Library/Developer/Xcode/DerivedData/Sense-amrxbuahpzprwaepprxlnxrnivph/Build/Intermediates.noindex/Sense.build/Debug-iphoneos/Sense.build/Script-FD357AEE20B807A500F1DB2E.sh: line 27: 6297 Segmentation fault: 11 "$LAURINE_PATH" -i "$SOURCE_PATH" -o "$OUTPUT_PATH" -c true Command PhaseScriptExecution failed with a nonzero exit code

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 20 (1 by maintainers)

Most upvoted comments

Hello, this seems to be because Laurine is being run as a script; if you compile it to an executable in a separate step, then it’s fine:

Here’s my updated Run Script build phase:

set -x

# Get base path to project
BASE_PATH="$PROJECT_DIR/$PROJECT_NAME"

#--------- START OF YOUR CONFIGURATION (change Path_To_.. to fit)

# Get path to Laurine Generator script its the binary
LAURINE_PATH="$BASE_PATH/../scripts/LaurineGenerator.swift"
LAURINE_BIN_PATH="$BASE_PATH/../bin/laurine"

# Get path to main localization file (usually english).
SOURCE_PATH="$BASE_PATH/Base.lproj/Localizable.strings"

# Get path to output. If you use ObjC version of output, set implementation file (.m), as header will be generated automatically
OUTPUT_PATH="$BASE_PATH/Localizations.swift"

#--------- END OF YOUR CONFIGURATION

# Build laurine binary if necessary
if [ ! -f $LAURINE_BIN_PATH ]; then
env -i swiftc -emit-executable -o$LAURINE_BIN_PATH $LAURINE_PATH
fi

# Actually generate output. -- CUSTOMIZE -- parameters to your needs (see documentation).
# Will only re-generate script if something changed
if [ "$OUTPUT_PATH" -ot "$SOURCE_PATH" ]; then
"$LAURINE_BIN_PATH" -i "$SOURCE_PATH" -c -o "$OUTPUT_PATH"
fi

(env -i forces swiftc to run without Xcode environment variables - otherwise it tries to build an ARM binary)

cc @emilpedersen @lch88 @daaa57150 @ppth0608

Hey guys - Very long time no see. I have been helming my startup, https://supernova.io/ and it has been absolutely crazy - though it is something you might be interested in. That being said, I have definitely didn’t stop to observe this project and I have recently started fixing the issues and improving laurine in general. I expect that I could have the fixed version done and released within few days, so don’t lose hope - I’ll do my best to catch up.

Hope it helps some of you! 😃

Just to be clear, and based on @mflint and @alecmontgomery comments, here is the complete code:

set -x

# Get base path to project
BASE_PATH="$PROJECT_DIR/$PROJECT_NAME"

#--------- START OF YOUR CONFIGURATION (change Path_To_.. to fit)

# Get path to Laurine Generator script its the binary
LAURINE_PATH="$BASE_PATH/LaurineGenerator.swift"
LAURINE_BIN_PATH="$BASE_PATH/../bin/laurine"

# Get path to main localization file (usually english).
SOURCE_PATH="$BASE_PATH/App/Base.lproj/Localizable.strings"

# Get path to output. If you use ObjC version of output, set implementation file (.m), as header will be generated automatically
OUTPUT_PATH="$BASE_PATH/App/Localizations.swift"

#--------- END OF YOUR CONFIGURATION

mkdir -p $LAURINE_BIN_PATH

# Build laurine binary if necessary
if [ ! -f $LAURINE_BIN_PATH ]; then
env -i swiftc -emit-executable -o$LAURINE_BIN_PATH $LAURINE_PATH
fi

# Actually generate output. -- CUSTOMIZE -- parameters to your needs (see documentation).
# Will only re-generate script if something changed
if [ "$OUTPUT_PATH" -ot "$SOURCE_PATH" ]; then
"$LAURINE_BIN_PATH" -i "$SOURCE_PATH" -c -o "$OUTPUT_PATH"
fi

Just make sure the paths are ok. In my case, I have the app inside the “App” folder and so the paths have that. The mkdir command uses the variable $LAURINE_BIN_PATH created above.

I hope its clear for everyone.

Do you have any idea why it is executed like this and not the old way as it was working in xcode 10.1.1

I don’t know. I guess something has changed with the Swift interpreter, which means it cannot successfully parse/execute the Laurine script. But luckily it is able to compile the script into a binary, which we can then execute. ¯_(ツ)_/¯

@felipenandz

Your problem is that mkdir -p $LAURINE_BIN_PATH is making a directory with the name bin/laurine/, when it should just be making the directory bin/.

I’d change the script like this:

LAURINE_PATH="$BASE_PATH/../../LaurineGenerator.swift"
BIN_PATH="$BASE_PATH/../bin"
LAURINE_BIN_PATH="$BIN_PATH/laurine"

… and further down:

mkdir -p $BIN_PATH

Then the script will make bin/ directory, then compile the laurine binary into bin/laurine.

(You’ll also need to manually delete the directory bin/laurine/, before building for the first time)

Thanks mflint! It worked. I added mkdir -p $PROJECT_DIR/../Tools/Laurine/bin/ before # Build laurine binary if necessary to suppress an error about the bin directory not existing…

Same here 😃

I downloaded Xcode 10.1. In Xcode changed Command Line Tools to Xcode 10.1. With that setting I can run swift LaurineGenerator.swift -i Localizable.strings -c -o Localizations.swift in Terminal and it creates the Localizations.swift file fine. I use that as a workaround right now.