Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apple Mach-O Linker Error Group #2

Closed
fatesinger opened this issue Jun 24, 2017 · 6 comments
Closed

Apple Mach-O Linker Error Group #2

fatesinger opened this issue Jun 24, 2017 · 6 comments

Comments

@fatesinger
Copy link

fatesinger commented Jun 24, 2017

Xcode8.3 编译报错 Apple Mach-O Linker Error Group ,clang: error: linker command failed with exit code 1 (use -v to see invocation)

@qiuxiang
Copy link
Owner

有用的信息太少了。
是编译 example 还是新项目出的错?

@fatesinger
Copy link
Author

fatesinger commented Jun 24, 2017

example 和新建的项目 用Xcode 编译都会报错
image

ld: warning: directory not found for option '-L/Users/user/Library/Developer/Xcode/DerivedData/Example-hkwtfydlvudojzengfoqzkoemvmx/Build/Products/Debug-iphonesimulator/React'
ld: warning: directory not found for option '-L/Users/user/Library/Developer/Xcode/DerivedData/Example-hkwtfydlvudojzengfoqzkoemvmx/Build/Products/Debug-iphonesimulator/Yoga'
ld: warning: directory not found for option '-L/Users/user/Library/Developer/Xcode/DerivedData/Example-hkwtfydlvudojzengfoqzkoemvmx/Build/Products/Debug-iphonesimulator/react-native-amap3d'
ld: library not found for -lreact-native-amap3d
clang: error: linker command failed with exit code 1 (use -v to see invocation)

example run-ios 会提示 BUILD SUCCEEDED 但是运行会报错
image

@qiuxiang
Copy link
Owner

qiuxiang commented Jun 24, 2017

如果你要用 xcode 运行的话,要打开 Example.xcworkspace,而不是 Example.xcodeproj。

实际上没必要打开 xcode,npm run ios 编译成功的话说明配置是没有问题的,之所以会打包错误是因为 npm install 的时候没有把 file:.. 复制,而是进行链接,这会导致路径错误,所以我特地写了 init 脚本来处理这个问题。你应该是没有运行 npm run init

如果是新项目,通过 npm i react-native-amap3d 的方式进行安装是不会出现打包错误的。

@fatesinger
Copy link
Author

解决了,react-native 0.45 执行 pod install 后 会提示 jschelpers/JavaScriptCore.h file not found
Ship third-party-podspecs in the npm package #13922

我把Podfile修改了下编译成功

platform :ios, '8.0'

target 'App' do
  pod 'Yoga', path: '../node_modules/react-native/ReactCommon/yoga/'
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
  'BatchedBridge',
  'Core',
]
  pod 'react-native-amap3d', path: '../node_modules/react-native-amap3d/'
end

@qiuxiang
Copy link
Owner

我还没试过 0.45

@qiuxiang
Copy link
Owner

qiuxiang commented Jun 28, 2017

我新建项目试了下,0.45 确实会出现 jschelpers/JavaScriptCore.h file not found 的错误,那是因为 default_subspec "Core" 不再依赖 cxxreact,而这个库间接依赖 jschelpers。

你上面提到的 issue 虽然不是直接关联,但提供了线索:facebook/react-native@5aca739cc25949eebc04a0309c2944f92b5b5391。

那么解决的方法其实不是添加 subspaces => ['BatchedBridge', 'Core'],而是 subspaces => ['jschelpers_legacy'],BatchedBridge 只是因为依赖 jschelpers_legacy 而恰巧解决了问题 。

还有另一种方法,就是使用新的 jschelpers,但这样 Podfile 写起来就很麻烦,因为要依赖 Folly、DoubleConversion、GLog、boost,而且还不能直接引用 third-party-podspecs(或者是我的方法不对?)。不管怎么样,Podfile 大概会写成这样:

platform :ios, '8.0'

target 'Your Target' do
  pod 'Folly', path: '...'
  pod 'DoubleConversion', path: '...'
  pod 'GLog', path: '...'
  pod 'Yoga', path: '../node_modules/react-native/ReactCommon/yoga/'
  pod 'React', path: '../node_modules/react-native/', :subspecs => [
    'jschelpers',
  ]
  pod 'react-native-amap3d', path: '../node_modules/react-native-amap3d/'
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants