NativeScript / ios-jsc

NativeScript for iOS using JavaScriptCore
http://docs.nativescript.org/runtimes/ios
Apache License 2.0
299 stars 59 forks source link

After upgrading to nativescript 1.4, ios build failed #388

Closed Fatme closed 9 years ago

Fatme commented 9 years ago

From @enchev on October 26, 2015 7:28

From @eforth on October 22, 2015 14:34

cocoapods (0.39.0) nativescript@1.4.2

Steps

  1. tns create testapp
  2. cd testapp
  3. tns platform add ios
  4. tns build ios

    Output from tns buid ios

Project successfully prepared Build settings from command line: ARCHS = i386 CONFIGURATION_BUILD_DIR = /Users/ervinforth/Projects/nativescript-apps/testapp2/platforms/ios/build/emulator SDKROOT = iphonesimulator9.0 SHARED_PRECOMPS_DIR = /Users/ervinforth/Projects/nativescript-apps/testapp2/platforms/ios/build/sharedpch VALID_ARCHS = "i386"

=== BUILD TARGET testapp2 OF PROJECT testapp2 WITH CONFIGURATION Debug ===

Check dependencies build-debug.xcconfig line 2: Unable to find included file "Pods/Target Support Files/Pods/Pods.debug.xcconfig"

PhaseScriptExecution NativeScript\ PreBuild build/testapp2.build/Debug-iphonesimulator/testapp2.build/Script-C97FD7AC1ADE5369004DB2A4.sh cd /Users/ervinforth/Projects/nativescript-apps/testapp2/platforms/ios /bin/sh -c /Users/ervinforth/Projects/nativescript-apps/testapp2/platforms/ios/build/testapp2.build/Debug-iphonesimulator/testapp2.build/Script-C97FD7AC1ADE5369004DB2A4.sh ~/Projects/nativescript-apps/testapp2/platforms/ios/internal/metadata-generator/bin ~/Projects/nativescript-apps/testapp2/platforms/ios Generating metadata for i386

~/Projects/nativescript-apps/testapp2/platforms/ios

Ld build/emulator/testapp2.app/testapp2 normal i386 cd /Users/ervinforth/Projects/nativescript-apps/testapp2/platforms/ios export IPHONEOS_DEPLOYMENT_TARGET=7.0 export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/ervinforth/ApacheAnt/bin:/Users/ervinforth/android-sdk/tools:/Users/ervinforth/android-sdk/platform-tools:/Users/ervinforth/android-sdk/build-tools:/Applications/Genymotion\ Shell.app/Contents/MacOS/:/Applications/Genymotion.app/Contents/MacOS/" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk -L/Users/ervinforth/Projects/nativescript-apps/testapp2/platforms/ios/build/emulator -F/Users/ervinforth/Projects/nativescript-apps/testapp2/platforms/ios/build/emulator -F/Users/ervinforth/Projects/nativescript-apps/testapp2/platforms/ios/../../lib/iOS -filelist /Users/ervinforth/Projects/nativescript-apps/testapp2/platforms/ios/build/testapp2.build/Debug-iphonesimulator/testapp2.build/Objects-normal/i386/testapp2.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -mios-simulator-version-min=7.0 -Xlinker -objc_abi_version -Xlinker 2 -ObjC -sectcreate DATA TNSMetadata /Users/ervinforth/Projects/nativescript-apps/testapp2/platforms/ios/build/emulator/metadata-i386.bin -lNativeScript -L/Users/ervinforth/Projects/nativescript-apps/testapp2/platforms/ios/internal/NativeScript/lib -licucore -lz -lc++ -framework Foundation -framework UIKit -framework CoreGraphics -framework MobileCoreServices -fobjc-arc -fobjc-link-runtime -Xlinker -dependency_info -Xlinker /Users/ervinforth/Projects/nativescript-apps/testapp2/platforms/ios/build/testapp2.build/Debug-iphonesimulator/testapp2.build/Objects-normal/i386/testapp2_dependency_info.dat -o /Users/ervinforth/Projects/nativescript-apps/testapp2/platforms/ios/build/emulator/testapp2.app/testapp2 ld: warning: directory not found for option '-F/Users/ervinforth/Projects/nativescript-apps/testapp2/platforms/ios/../../lib/iOS' ld: can't open -sectcreate file: /Users/ervinforth/Projects/nativescript-apps/testapp2/platforms/ios/build/emulator/metadata-i386.bin clang: error: linker command failed with exit code 1 (use -v to see invocation)

\ BUILD FAILED **

The following build commands failed: Ld build/emulator/testapp2.app/testapp2 normal i386 (1 failure) Command xcodebuild failed with exit code 65

I noticed this all happened when I upgraded to version 1.4 of nativescript.

build-debug.xcconfig line 2: Unable to find included file "Pods/Target Support Files/Pods/Pods.debug.xcconfig"

Anybody have a similar issue?

Copied from original issue: NativeScript/NativeScript#978

Copied from original issue: NativeScript/nativescript-cli#1103

Fatme commented 9 years ago

From @enchev on October 26, 2015 7:28

From @fealebenpae on October 22, 2015 15:2

Hi @eforth,

The Unable to find included file "Pods/Target Support Files/Pods/Pods.debug.xcconfig" warning is benign and you can safely ignore it. The real issue here is that for some reason the metadata generation has failed: ld: can't open -sectcreate file: /Users/ervinforth/Projects/nativescript-apps/testapp2/platforms/ios/build/emulator/metadata-i386.bin.

I just performed these steps on my machine, running OS X 10.11.1, Xcode 7.1 from the App Store, nativescript@1.4.2 and CocoaPods 0.39.0, and it built fine. What's your environment like?

Fatme commented 9 years ago

From @enchev on October 26, 2015 7:28

From @eforth on October 22, 2015 15:32

Xcode 7.0.1 Build version 7A1001

OS X El Captain Version 10.11.1

Fatme commented 9 years ago

From @enchev on October 26, 2015 7:28

From @manijak on October 22, 2015 19:52

I had the similar (if not the same) error right after I moved to El Capitan and XCode 7. Try giving your user more permissions to the platforms and/or ios folder (and sub-content). I gave my user read & write permission, plus added myself as the 'owner'. Then rebuild.

Fatme commented 9 years ago

From @enchev on October 26, 2015 7:28

From @eforth on October 22, 2015 21:57

That didn't work but I'm going to upgrade my Xcode.

Fatme commented 9 years ago

From @enchev on October 26, 2015 7:28

From @x4080 on October 22, 2015 22:15

Hello, i also can confirm that i don't have this issue, im using nvm for node versioning

Fatme commented 9 years ago

From @enchev on October 26, 2015 7:28

From @TobiasHennig on October 23, 2015 6:42

I have exactly the same problem with the last Xcode.

Fatme commented 9 years ago

From @enchev on October 26, 2015 7:28

From @ivanbuhov on October 23, 2015 8:32

Hi @eforth, try building your project with the CLI and the standart error stream of metadata generator will be dumped in {YourAppFolder}/platforms/ios/build/emulator/metadata-generation-stderr-i386.txt (if you build the app from Xcode you can find the dumped output in your DeriveData folder). Can you share the contents of the file?

Fatme commented 9 years ago

From @enchev on October 26, 2015 7:28

From @x4080 on October 23, 2015 9:11

Oh maybe I should add I don't have cocoapod installed .maybe that is the issue ?

Fatme commented 9 years ago

From @enchev on October 26, 2015 7:28

From @TobiasHennig on October 23, 2015 9:14

I have the problem with and without cocoapod installed. (I have installed it to solve the problem.)

Fatme commented 9 years ago

From @enchev on October 26, 2015 7:28

From @eforth on October 23, 2015 16:21

Hi @ivanbuhov, the {YourAppFolder}/platforms/ios/build/emulator/metadata-generation-stderr-i386.txt file is empty.

Fatme commented 9 years ago

From @enchev on October 26, 2015 7:28

From @eforth on October 23, 2015 16:57

Upgraded to Xcode 7.1 and also completely removed node, npm and all node modules (I know it's a bit drastic but I wanted to see if node or node modules might have caused the error).

system config:

OS X El Captain (version 10.11.1) Xcode 7.1 (Build version 7B91b) nvm (version 0.29.0) node (version v0.12.7) npm (version 2.11.3) nativescript (version 1.4.3)```

I didn't install cocoapods however I will install later once the issue is fixed

The same error still occurs:

ld: can't open -sectcreate file: /Users/ervinforth/Desktop/doula/platforms/ios/build/emulator/metadata-i386.bin

Also a warning:

ld: warning: directory not found for option '-F/Users/ervinforth/Desktop/doula/platforms/ios/../../lib/iOS'

Fatme commented 9 years ago

From @enchev on October 26, 2015 7:28

From @TobiasHennig on October 25, 2015 15:0

I've made a clean OSX install, but i'm still unable to build an ios project.

My system:

And after ...

tns run ios --emulator

... i get these errors:

...
ld: warning: directory not found for option '-F/Users/tobiashennig/Sites/tns-example/platforms/ios/../../lib/iOS'
ld: can't open -sectcreate file: /Users/tobiashennig/Sites/tns-example/platforms/ios/build/emulator/metadata-i386.bin
clang: error: linker command failed with exit code 1 (use -v to see invocation)

** BUILD FAILED **

The following build commands failed:
    Ld build/emulator/tnsexample.app/tnsexample normal i386
(1 failure)
Command xcodebuild failed with exit code 65
Fatme commented 9 years ago

From @ivanbuhov on October 26, 2015 8:46

We tried to reporoduce the issue, but without success. I guess in your case the metadata generator is never called or it is called but crashes too early to produce any output. Try to run metadata generator manually. Depending on the result we can say if it is called at all or it just crashes too early. To run the generator manually:

  1. Create a folder where the generator output will be stored 2. Open a terminal in {AppFolder}/platforms/ios/metadata-generator/bin/ and run the following command:
  2. Open a terminal in {AppFolder}/platforms/ios/internal/metadata-generator/bin/ and run the following command:
./objc-metadata-generator -output-bin "{OutputFolder}/metadata-i386.bin" -output-umbrella "{OutputFolder}/umbrella-i386.h" -output-yaml "{OutputFolder}" Xclang -isysroot "{SimulatorSdkFolder}" -arch i386 -miphoneos-version-min=7.0 -target arm-apple-darwin -std=gnu99 "-I{AppFolder}/platforms/ios/build/emulator/include" "-I{AppFolder}/platforms/ios/internal" "-I{AppFolder}/platforms/ios/internal/NativeScript/include" "-F{AppFolder}/platforms/ios/build/emulator" "-F{AppFolder}/platforms/ios/../../lib/iOS" -DDEBUG=1

Replace {OutputFolder} with the absolute path to previoslly created folder. Replace {AppFolder} with the absolute path to your app folder. Replace {SimulatorSdkFolder} with the absolute path to simulator sdk fodler.

On my machine I set the output folder to be /Users/buhov/Desktop/metadata and run the following command:

./objc-metadata-generator -output-bin "/Users/buhov/Desktop/metadata/metadata-i386.bin" -output-umbrella "/Users/buhov/Desktop/metadata/umbrella-i386.h" -output-yaml "/Users/buhov/Desktop/metadata" Xclang -isysroot "/Applications/Xcode7.0.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk" -arch i386 -miphoneos-version-min=7.0 -target arm-apple-darwin -std=gnu99 "-I/Users/buhov/Desktop/NSTestApp/platforms/ios/build/emulator/include" "-I/Users/buhov/Desktop/NSTestApp/platforms/ios/internal" "-I/Users/buhov/Desktop/NSTestApp/platforms/ios/internal/NativeScript/include" "-F/Users/buhov/Desktop/NSTestApp/platforms/ios/build/emulator" "-F/Users/buhov/Desktop/NSTestApp/platforms/ios/../../lib/iOS" -DDEBUG=1

If everything goes well your output folder should be populated with metadata-i386.bin, umbrella-i386.h and nearly 90 more YAML files (one yaml file per clang module). Please share the output of the command dumped in the console, too.

Fatme commented 9 years ago

From @z0nekill on October 26, 2015 10:55

Hey Ivan,

Thanks for moving my issue to the correct thread.

I'm trying to follow your steps but have ran into a snag.

tns platform add ios 

doesn't create the directory you outlined above in step 2.

However, I searched through the platforms directory and found the folder at the following location:

{AppFolder}/platforms/ios/internal/metadata-generator/bin/

I may just be highlighting a typo, but if I'm not then could this possibly be the reason the metadata isn't being generated?

Cheers, David.

Fatme commented 9 years ago

From @ivanbuhov on October 26, 2015 12:59

Ops, my fault. As @z0nekill noticed the folder is {AppFolder}/platforms/ios/internal/metadata-generator/bin/. I edited the original answer.

Fatme commented 9 years ago

From @eforth on October 27, 2015 16:48

HI @ivanbuhov, when I ran the code below:

./objc-metadata-generator -output-bin "/Users/ervinforth/Desktop/metadata/metadata-i386.bin" -output-umbrella "/Users/ervinforth/Desktop/metadata/umbrella-i386.h" -output-yaml "/Users/ervinforth/Desktop/metadata" Xclang -isysroot "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.1.sdk" -arch i386 -miphoneos-version-min=7.0 -target arm-apple-darwin -std=gnu99 "-I/Users/ervinforth/Projects/nativescript-apps/testa/platforms/ios/build/emulator/include" "-I/Users/ervinforth/Projects/nativescript-apps/testa/platforms/ios/internal" "-I/Users/ervinforth/Projects/nativescript-apps/testa/platforms/ios/internal/NativeScript/include" "-F/Users/ervinforth/Projects/nativescript-apps/testa/platforms/ios/build/emulator" "-F/Users/ervinforth/Projects/nativescript-apps/testa/platforms/ios/../../lib/iOS" -DDEBUG=1

I got the following response:

Illegal instruction: 4

fealebenpae commented 9 years ago

I think this might be because the metadata generator binary was originally built on a Yosemite machine. I built the metadata generator on a machine running El Capitan and I uploaded it here. Please download it and replace it with the old objc-metadata-generator and try building again.

eforth commented 9 years ago

I still receive the same error.

fealebenpae commented 9 years ago

I'll keep looking into this, I believe it must be a wonky compiler/deployment target combo. In the mean time, you can try building the tns-ios npm package from this repo's release branch manually on your machine and perhaps that will work.

eforth commented 9 years ago

ok thanks.

fealebenpae commented 9 years ago

@eforth: I built the metadata generator again (this time rebuilding LLVM and Clang as well) - could you please download it and try executing it again?

eforth commented 9 years ago

I still got the same error.

TobiasHennig commented 9 years ago

I've tried the direct command and downloads and got the same error Illegal instruction: 4 .

hrangel commented 9 years ago

Any news on this issue? I'm getting the same error.

dtopuzov commented 9 years ago

Can you please post your project pacakge.json, it will be usefull to know what plugins, pods and modules you use in your project.

fealebenpae commented 9 years ago

I take it everyone is running OS X 10.11, right? I have El Capitan on an early 2011 MacBook Pro and a 2014 5K iMac and I can't reproduce this problem.

Can you please tell me what's your hardware configuration?

manijak commented 9 years ago

I am also running OS X 10.11.1 With XCode 7.1 on a mid-2011 MacMini (installed all updates). Re-installed nativescript, removed platform ios and re-added it. Added permissions to platforms folder to read-write and owner (my user).

Everything works fine.

hrangel commented 9 years ago

I'm running El Capitan (10.11.1) XCode 7.1 node 0.12.7 npm 2.14.4 nativescript 1.4.3

To reproduce the issue: 1 - Clone the sample-Tasks 2 - Execute run.sh

A workaround so I could continue working: 1 - tns platform remove ios 2 - tns platform add ios@1.3.0 But that's not the ideal scenario, obviously.

eforth commented 9 years ago

Hardware: Mackbook Pro (mid 2010)

system config:

OS X El Captain (version 10.11.1) Xcode 7.1 (Build version 7B91b) nvm (version 0.29.0) node (version v0.12.7) npm (version 2.11.3) nativescript (version 1.4.3)

package.json:

{ "nativescript": { "id": "org.nativescript.testa", "tns-ios": { "version": "1.4.1" } }, "dependencies": { "tns-core-modules": "1.4.0" } }

eforth commented 9 years ago

I can confirm that using @hrangel work-around works. By removing the current ios platform whether version 1.4.0 or 1.4.1 and then adding the older version 1.3.0 will allow for a successful build.

fealebenpae commented 9 years ago

Guys, I've uploaded a new version of the metadata generator. I'm sorry I'm sending out builds like this, but I'm trying to apply blind fixes :disappointed:

In 1.4 we switched to version 3.7 of the Clang compiler so as to be able to support the new Objective-C features in Xcode 7. NativeScript 1.3 uses Clang 3.6 and doesn't support the new stuff like Objective-C generics. I'm guessing that somehow the build of Clang 3.7 that we use fails on older CPUs. This last build of the metadata generator I pushed uses the official build from llvm.org. If the last build doesn't work for you please download Clang for Mac OS X and try to compile a simple hello world program with it. This should help me narrow down the search for the problem.

z0nekill commented 9 years ago

Interesting,

I'm running a macbook pro 15 (Mid 2010) > Which is the intel i7 model I've now reverted my PC from El Captain to Yosemite and am still receiving this error for tns 1.4.3 so it's not OS associated.

But jeeze running

Cheers.

TobiasHennig commented 9 years ago

I'm running a MacBook Pro (Mid 2010) and the following versions:

With the new metadata engine from @fealebenpae i'm able to build an example application. You made my day, thank you very much!

z0nekill commented 9 years ago

Well that works,

I downloaded your latest metadata generator version - gave it the associated permissions and boom tns 1.4.3 ios builds compile successfully! That's exciting.

Solid effort @fealebenpae what ever you did in that build of the metadata generator worked.

However I did notice 200+ warnings that I thought I should point out.

ld: warning: object file (/Users/davidmay/Documents/WS/Test Projects/YosemiteTest/platforms/ios/internal/NativeScript/lib/libNativeScript.a(YarrJIT.o)) was built for newer iOS version (9.0) than being linked (7.0)
ld: warning: object file (/Users/davidmay/Documents/WS/Test Projects/YosemiteTest/platforms/ios/internal/NativeScript/lib/libNativeScript.a(YarrPattern.o)) was built for newer iOS version (9.0) than being linked (7.0)
ld: warning: object file (/Users/davidmay/Documents/WS/Test Projects/YosemiteTest/platforms/ios/internal/NativeScript/lib/libNativeScript.a(YarrSyntaxChecker.o)) was built for newer iOS version (9.0) than being linked (7.0)

So where does this go from here I suppose is my next question.

fealebenpae commented 9 years ago

I'm glad that worked :)

I'll include the fix for the 1.5 release - in the mean time you will have to replace the metadata generator with the one from Google Drive in every new project you create, but 1.5 is due in a couple of weeks so it won't be a long wait.

The was built for newer iOS version (9.0) than being linked (7.0) warning is harmless, you can safely ignore it. It's because we don't pass the -miphoneos-version-min compiler flag when building JavaScriptCore, but JSC doesn't use any high-level APIs that could be affected so it's not an issue. The fix for this warning is also going to be part of the 1.5 release.

@hrangel, @eforth, can you please test using the new build?

eforth commented 9 years ago

I can confirm that the new objc-metadata-generator file works.

victorhugom-zz commented 8 years ago

I`m having the same issue with tns 1.5.1 with a fresh mac installation

fealebenpae commented 8 years ago

@victorhugom: can you please tell me your OS X version and your Mac model identifier? If your machine is newer than ones produced in 2010 it is unlikely you are affected by the same issue. Have you tried invoking the metadata generator directly as @ivanbuhov demonstrated in the beginning of the thread and what's the output?

victorhugom-zz commented 8 years ago

I found the error, I forgot to upgrade the ios platform after update the tns and the core modules.

loint commented 8 years ago

I have same issue with you guys. Android is ok but iOS does not work :( ...

$ tns build ios
screen shot 2016-01-22 at 11 51 28 am
fealebenpae commented 8 years ago

@loint: the following line in your log seems suspect: ld: can't open output file for writing. Googling the error gave me the following result: http://stackoverflow.com/questions/9200521/why-does-the-name-of-a-source-file-affect-compilation. You can't name your project app because there is already an app folder in the iOS bundle that Xcode creates and that condlicts with the name of the executable the linker tries to output, which is also app.

fealebenpae commented 8 years ago

This issue originally dealt with the inability to run the 1.4 metadata generator on 2010 CPUs.