I've used the gomobile bind tool to build my Go library for use in an iOS app. I've wrapped my library into a Cocoapods .podspec. It works nicely in the simulator (via a local development pod), but when I try to do pod lib lint (part step, part of releasing a cocoapod) I run into errors:
Error:
ld: illegal text-relocation to 'runtime.rodata' in /Users/matti/src/foobar-sdk-ios/Frameworks/Client.framework/Client(go.o) from 'sync/atomic.(*Value).Store' in /Users/matti/src/foobar-sdk-ios/Frameworks/Client.framework/Client(go.o) for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Warning:
- NOTE | [iOS] [FooBarSDK/Go] xcodebuild: ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in sync/atomic.(*Value).Store from /Users/matti/src/foobar-sdk-ios/Frameworks/Client.framework/Client(go.o). To fix this warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie
It seems to link for other architectures. I couldnt figure out how to skip i386 - even though I override VALID_ARCHS - and I guess it wouldnt be the proper solution anyway.
So instead I'd like to know how to build a proper binary out of my Go code - I tried supplying -ldflags="-extldflags=-pie" to the gomobile bind command but I am assuming its more of a compilation issue. I know there is -buildmode=pie available for go build, but only for main packages and also not for gomobile bind.
Apparently this fixes (suppresses) the error:
spec.pod_target_xcconfig = {
"OTHER_LDFLAGS[arch=i386]" => "-Wl,-read_only_relocs,suppress"
}
I still get the PIE warning but the error is gone and the pod is pushed to the repository ok.
I wonder if Apple will have a beef with a binary missing PIE when pushing to App Store?
Related
I am getting a strange error where it appears one pods information is being duplicated by the addition of a completely separate pod. For clarification I am running 'MobileVLCKit' and 'box-ios-sdk' cocoapods. Running either by itself works fine but when both are included in the Podfile I get 'ld: 253 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)'.
enter image description here
For those of you that want to install the MobileVLCKit to help and run into issues you can use this link to set it up https://forum.videolan.org/viewtopic.php?f=32&t=137065#p453804
I am having one apple - o link error in my project, I have searched in Google but it's not helping me, below is my error
ld: building for iOS Simulator, but linking against dylib built for MacOSX file '/Applications/Xcode 2.app/Contents/Developer/Library/Frameworks/SenTestingKit.framework/SenTestingKit' for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
what is this error and how to fix it, please any one help me.
1.Try avoid arm64 from valid architecture.
2.Try Set Build for Active Architecture to "NO"
3.Also check framework search path
# build settings.
You can solve this by following this steps:
Select the Pods project
Click on build settings
Change Build Active Architecture Only to 'No'
I have been facing this lingering issue. When I try to Build the project by selecting iOS device in my Xcode it builds the code with out any error but when I trying the same with iOS simulator it shows me the following error. Is there any way to avoid this library file when I build in Simulator? I have tried the following Link as well but i couldn't figure the exact solution.
Thanks In Advance.
6 duplicate symbols for architecture i386
ld: warning: ignoring file /Users/iOS-MobileTeam/Downloads/iOS/LibraryFiles/libANMobilePaymentLib.a, missing required architecture i386 in file /Users/iOS-MobileTeam/Downloads/iOS/LibraryFiles/libANMobilePaymentLib.a (2 slices)
duplicate symbol _des_set_key in:
/Users/iOS-MobileTeam/Downloads/iOS/LineaSDK/libdtdev.a(des-524F6BE9122BCA82.o)
/Users/iOS-MobileTeam/Downloads/iOS/LineaSDK/libdtdev.a(des-D9CE0CBEE0B3BA81.o)
duplicate symbol _des_encrypt in:
/Users/iOS-MobileTeam/Downloads/iOS/LineaSDK/libdtdev.a(des-524F6BE9122BCA82.o)
/Users/iOS-MobileTeam/Downloads/iOS/LineaSDK/libdtdev.a(des-D9CE0CBEE0B3BA81.o)
duplicate symbol _des_decrypt in:
/Users/iOS-MobileTeam/Downloads/iOS/LineaSDK/libdtdev.a(des-524F6BE9122BCA82.o)
/Users/iOS-MobileTeam/Downloads/iOS/LineaSDK/libdtdev.a(des-D9CE0CBEE0B3BA81.o)
ld: 3 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Ignoring file /Users/iOS-MobileTeam/Downloads/iOS/LibraryFiles/libANMobilePaymentLib.a, missing required architecture i386 in file /Users/iOS-MobileTeam/Downloads/iOS/LibraryFiles/libANMobilePaymentLib.a (2 slices)
The static library is broken as it contains two separate object files containing the same symbols (functions).
It must be rebuilt, or if you don't have the source you could unpack it, remove the offending file, and then re-pack it (untested):
$ mv libdtdev.a libdtdev-old.a
$ mkdir xxx
$ cd xxx
$ ar x ../libdtdev-old.a
$ rm des-D9CE0CBEE0B3BA81.o
$ ar cr ../libdtdev.a *.o
$ cd ..
$ rm -rf xxx
However if the static library contains multiple architectures, this becomes much more complicated.
The issue is that your libANMobilePaymentLib.a static archive was not built properly. If that is a 3rd party library, you should ask the author to provide an updated version which addresses this issue, and trojanfoe's instructions on unpacking and repacking the archive without one of the des implementations is probably your best bet for a temporary workaround.
If you built the library yourself or want to pass on information to the author, the issue is that the library's i386 slice contains duplicates of the des_set_key, des_encrypt, and des_decrypt symbols. I suspect that this was caused by accidentally including des.c twice when building libANMobilePaymentLib.a. Another possibility is that the author of libANMobilePaymentLib.a intended those functions to be static and not exported.
Finally I found the fix for the above issue. all credit goes to #Khanh
How to ignore some static library for iOS simulator
The above link helped me to fix the issue.
Steps to Fix The Issue:
Go to Project Build Settings and search for other linker flags.
2.Expand The other linker flags section. There will be two modes Debug and Release
Place the cursor over Debug Mode a + symbol will appear.
Click the plus Symbol.
A new option will be added like Any Architecture | Any SDK.
Change that Any SDK to Any iOS Simulator SDK
Set -objC Value for Any iOS Simulator SDK
I encounter the following errors
ld: warning: directory not found for option '- L/Users/andrecowardjr/Desktop/Parley/Parley/Google Analytics
ld: library not found for -lGoogleAnalytics
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Cant find out what the error is. Help needed.
Go into your project settings, check out the field 'Library Search Paths', and edit it so that it reflects where you moved your code/libraries. The error you're running into here is the linker can't find the Google Analytics library that your app is set up to link against (because you moved it).
Here's the error:
Undefined symbols for architecture armv7:
"___udivmodsi4", referenced from:
_sqlite3BitvecSet in libmergDropboxSync.a(sqlite3.o)
_sqlite3BitvecClear in libmergDropboxSync.a(sqlite3.o)
_sqlite3BitvecTest in libmergDropboxSync.a(sqlite3.o)
ld: symbol(s) not found for architecture armv7
collect2: ld returned 1 exit status
lipo: can't open input file: /var/folders/np/1scdfrdd7kx64bbykn22wj200000gn/T//ccvBM79H.out (No such file or directory)
error: linking step of external dylib build failed, probably due to missing framework or library references - check the contents of the mergDropboxSync.ios file
Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure
When I build for the simulator it builds fine. My library is compiling fine. It's only at the linking stage for the dylib that is documented in lclink.sh as only for a dependency check for device builds that there's an issue:
# Build the 'dylib' form of the external - this is used by simulator builds, and as
# a dependency check for device builds.
"$PLATFORM_DEVELOPER_BIN_DIR/g++" -dynamiclib $ARCHS -isysroot "$SDKROOT" -o "$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.dylib" "$BUILT_PRODUCTS_DIR/$EXECUTABLE_NAME" $SYMBOL_ARGS $SYMBOLS $DEPS
if [ $? != 0 ]; then
echo "error: linking step of external dylib build failed, probably due to missing framework or library references - check the contents of the $PRODUCT_NAME.ios file"
exit $?
fi
I tried skipping this step using the following:
if [ "$EFFECTIVE_PLATFORM_NAME" == "-iphonesimulator" ]; then
# Build the 'dylib' form of the external - this is used by simulator builds, and as
# a dependency check for device builds.
"$PLATFORM_DEVELOPER_BIN_DIR/g++" -dynamiclib $ARCHS -isysroot "$SDKROOT" -o "$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.dylib" "$BUILT_PRODUCTS_DIR/$EXECUTABLE_NAME" $SYMBOL_ARGS $SYMBOLS $DEPS
if [ $? != 0 ]; then
echo "error: linking step of external dylib build failed, probably due to missing framework or library references - check the contents of the $PRODUCT_NAME.ios file"
exit $?
fi
fi
This allowed the script to continue on and build the object files for static linking in the device builds. They built fine but then when I went to build the standalone the dependency check blocked it. Is there any workaround anyone can recommend?
Note that I use a slightly modified lclink.sh which adds weak linking support and optional framework inclusion depending on the SDK you're building against. It can be found here if that helps:
http://repo.goulding.ws/livecodeiossdk/src/b570507fe48274cc4c0f90102809194eafe5225d/lclink.sh?at=master
EDIT
Given that the error was clearly armv7 related I tried a build against armv7s and it builds fine. I'm coming to the conclusion that the the new dropbox sync sdk may have some armv7s only code. It appears to be sqlite related based on the error. Not sure what else to try at this stage...
EDIT
It appears to be a toolchain issue caused by the Dropbox sync api being compiled with Apple LLVM and LiveCode externals and device builds being compiled with Apple GCC.
Does this help any? I wrote this up when I was having a somewhat similar problem.
runrev lesson on linking to a dylib library