Code Monkey home page Code Monkey logo

Comments (20)

mflint avatar mflint commented on August 16, 2024 12

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

from laurine.

 avatar commented on August 16, 2024 4

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.

from laurine.

JiriTrecak avatar JiriTrecak commented on August 16, 2024 4

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! :)

from laurine.

mflint avatar mflint commented on August 16, 2024 2

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. ¯_(ツ)_/¯

from laurine.

emilpedersen avatar emilpedersen commented on August 16, 2024 1

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.

from laurine.

ppth0608 avatar ppth0608 commented on August 16, 2024 1

Same here :)

from laurine.

alecmontgomery avatar alecmontgomery commented on August 16, 2024 1

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...

from laurine.

mflint avatar mflint commented on August 16, 2024 1

@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)

from laurine.

lch88 avatar lch88 commented on August 16, 2024

Same here.

I've been running the laurine script in swift 5.

from laurine.

daaa57150 avatar daaa57150 commented on August 16, 2024

Same here after updating the OS.

It's weird because we tried to debug the script by integrating it in a macos command line project and feeding it the parameters directly, and this worked no problem.
We tried swift version 4, 4.2 and 5, they all worked.

It fails only as a script in the build phases or from the command line
swift LaurineGenerator.swift -i Localizable.strings -c -o Localizations.swift
(our paths are more complicated than that in reality)

from laurine.

 avatar commented on August 16, 2024

@emilpedersen @alecmontgomery Can any of you post you full script here please? I can't get it to work. Thanks.
Meanwhile I have 10.1 version to run Laurine script only and work with 10.2 because my device is already in that version.

from laurine.

pacu avatar pacu commented on August 16, 2024

In my case I got the script running but, the camel casing is broken. the key SomeTestViewController. is generated as Sometestviewcontroller

edit: just remove -c flag and it will be fine

from laurine.

PiotrWitczak avatar PiotrWitczak commented on August 16, 2024

I try to build Laurine in build phrase as above and I have these errors.
`
Showing Recent Messages
👎 + env -i swiftc -emit-executable -o /Users/wikiwiktor/Documents/WorkSpace/iOS/ig-ios/InfoGym/../bin/laurine /Users/wikiwiktor/Documents/WorkSpace/iOS/ig-ios/Libraries/Laurine/LaurineGenerator.swift

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16: while building module 'Darwin' imported from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16:

👎 #include <sys/types.h>

👎 ^

/:29: in file included from :29:

👎 #import "string.h"

👎 ^

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/string.h:180: in file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/string.h:180:

👎 #include "strings.h"

👎 ^

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/strings.h:92: in file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/strings.h:92:

👎 #include <string.h>

👎 ^

/usr/local/include/string.h:25: in file included from /usr/local/include/string.h:25:

👎 #include <plist/Node.h>

👎 ^

/usr/local/include/plist/Node.h:26: 'cstddef' file not found

👎 #include

👎 ^

/:1: in file included from :1:

👎 #import "Headers/CoreFoundation.h"

👎 ^

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16: could not build module 'Darwin'

👎 #include <sys/types.h>

👎 ^

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:20: while building module 'Dispatch' imported from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:20:

👎 #include <dispatch/dispatch.h>

👎 ^

/:1: in file included from :1:

👎 #import "dispatch.h"

👎 ^

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/dispatch/dispatch.h:25: could not build module 'Darwin'

👎 #include <Availability.h>

👎 ^

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:20: while building module 'Dispatch' imported from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:20:

👎 #include <dispatch/dispatch.h>

👎 ^

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/dispatch/dispatch.h:48: while building module 'os_object' imported from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/dispatch/dispatch.h:48:

👎 #include <os/object.h>

👎 ^

/:1: in file included from :1:

👎 #import "os/object.h"

👎 ^

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/os/object.h:25: could not build module 'Darwin'

👎 #include <Availability.h>

👎 ^

/: could not build Objective-C module 'CoreFoundation'

`

I use xcode Version 10.2.1

from laurine.

SandeepAggarwal avatar SandeepAggarwal commented on August 16, 2024

@PiotrWitczak Did you able to make it work?

from laurine.

felipenandz avatar felipenandz commented on August 16, 2024

Hi Guys,

I'm still having such a problem with the script. Using the script you published here the code runs but doesn't modify or add the string. It's not working properly and I don't know why.. I'm still getting the

Segmentation fault 11
Command PhaseScriptExecution failed with a nonzero exit code
I would appreciate if someone could help me.

I've got Xcode 10.1.3
Thank you very much!

from laurine.

mflint avatar mflint commented on August 16, 2024

@felipenandz Can you post your script please?

from laurine.

felipenandz avatar felipenandz commented on August 16, 2024

@mflint
Sure ,

I dowloaded the project Laurine from the Repo and as expected their code is not working in Xcode 10.1.3 giving the same Problem. So I put your script there.

It's giving this error

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/Resources/Localizations/en.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/Classes/Generated/Localizations.swift"

mkdir -p $LAURINE_BIN_PATH

--------- 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

Right Now is giving this error

👎 ld: can't open output file for writing: /Users/fnandz/Downloads/Laurine-master/Example/Laurine/../bin/laurine, errno=21 for architecture x86_64

👎 /Users/fnandz/Library/Developer/Xcode/DerivedData/Laurine-cqayukqhekxkitbikrlrwttefoxo/Build/Intermediates.noindex/Laurine.build/Debug-iphonesimulator/Laurine.build/Script-0BF9E6791BF2375E0055C0D8.sh: line 32: /Users/fnandz/Downloads/Laurine-master/Example/Laurine/../bin/laurine: is a directory

from laurine.

felipenandz avatar felipenandz commented on August 16, 2024

@mflint

All the best to you , your family and your generations!

It works.. Thank you very much!

from laurine.

felipenandz avatar felipenandz commented on August 16, 2024

@mflint

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

Just to know , because I need to explain it. But if you don't it Ok anyway , it's all working good.

from laurine.

MatyasKriz avatar MatyasKriz commented on August 16, 2024

If you're looking for generating assets and others among localizables, consider moving to SwiftGen which is still maintained and under active development.

from laurine.

Related Issues (20)

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.