Comments (20)
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.
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.
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.
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.
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.
Same here :)
from laurine.
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.
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.
Same here.
I've been running the laurine script in swift 5.
from laurine.
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.
@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.
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.
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.
@PiotrWitczak Did you able to make it work?
from laurine.
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.
@felipenandz Can you post your script please?
from laurine.
@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.
All the best to you , your family and your generations!
It works.. Thank you very much!
from laurine.
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.
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)
- Compiled Script HOT 1
- Xcode 7.3 support HOT 5
- Support for dictionaries HOT 2
- Detect unused keys
- Deprecated homebrew dependencies HOT 3
- Swift 3 Support? HOT 18
- Can't build Laurine with Swift 2.2 on Mac Sierra HOT 2
- How to use this with many languages? HOT 1
- Laurine's younger Sister - Image Generator [name pending] HOT 2
- Generated Localizations file is incomplete if input file contains certain characters HOT 2
- Swift 4 migration HOT 2
- S3, S4 Support + Laurine Rework (announcement) HOT 9
- Question: What about memory? HOT 1
- Objc localization - String with format specifiers HOT 1
- Laurine fails at -d parameter HOT 1
- (Question) Fallback handling
- "Error.Title.General" is not recognized by Laurine
- "\\(variable)" not work HOT 1
- Feature request: use Base translation as comment
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laurine.