Page MenuHomePhabricator

[Nix] Add cocoapods for ios build
ClosedPublic

Authored by jon on Jul 7 2022, 8:46 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 22, 11:27 AM
Unknown Object (File)
Fri, Nov 22, 11:27 AM
Unknown Object (File)
Fri, Nov 22, 11:27 AM
Unknown Object (File)
Fri, Nov 22, 11:27 AM
Unknown Object (File)
Fri, Nov 22, 11:26 AM
Unknown Object (File)
Oct 26 2024, 1:37 AM
Unknown Object (File)
Oct 23 2024, 5:15 PM
Unknown Object (File)
Oct 23 2024, 5:15 PM

Details

Summary

Add cocoapods to allow for pod installs

Test Plan

Install XCode

nix develop 
cd native/ios && pod install && xcodebuild -workspace Comm.xcworkspace -scheme Comm -destination generic/platform=iOS -allowProvisioningUpdates

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

nix develop && cd native/ios && pod install && xcodebuild -workspace Comm.xcworkspace -scheme Comm -destination generic/platform=iOS -allowProvisioningUpdates

Once nix develop finishes it prints "Welcome to Comm dev environment! :)" and puts me "inside the nix shell." Is there a way I can get the rest (cd native/ios && pod install...) to run "inside" the nix shell after nix-develop in a single command?

atul requested changes to this revision.EditedJul 7 2022, 9:30 AM

Getting the following when I try running the test plan on an aarch64 Mac:

(could definitely be doing something wrong, so let me know if there's a step I'm missing etc)

clang-11: error: unknown argument: '-index-store-path'
clang-11: error: cannot specify -o when generating multiple output files
clang-11: warning: using sysroot for 'iPhoneOS' but targeting 'MacOSX' [-Wincompatible-sysroot]

...

The following build commands failed:
	CompileC /Users/atul/Library/Developer/Xcode/DerivedData/Comm-fkiywtbjesejrkccwlrvafeymilk/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/libevent.build/Objects-normal/arm64/strlcpy.o /Users/atul/comm/native/ios/Pods/libevent/strlcpy.c normal arm64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'libevent' from project 'Pods')
	CompileC /Users/atul/Library/Developer/Xcode/DerivedData/Comm-fkiywtbjesejrkccwlrvafeymilk/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/libevent.build/Objects-normal/arm64/listener.o /Users/atul/comm/native/ios/Pods/libevent/listener.c normal arm64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'libevent' from project 'Pods')
	CompileC /Users/atul/Library/Developer/Xcode/DerivedData/Comm-fkiywtbjesejrkccwlrvafeymilk/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/libevent.build/Objects-normal/arm64/libevent-dummy.o /Users/atul/comm/native/ios/Pods/Target\ Support\ Files/libevent/libevent-dummy.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'libevent' from project 'Pods')
	CompileC /Users/atul/Library/Developer/Xcode/DerivedData/Comm-fkiywtbjesejrkccwlrvafeymilk/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/libevent.build/Objects-normal/arm64/log.o /Users/atul/comm/native/ios/Pods/libevent/log.c normal arm64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'libevent' from project 'Pods')
	CompileC /Users/atul/Library/Developer/Xcode/DerivedData/Comm-fkiywtbjesejrkccwlrvafeymilk/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/libevent.build/Objects-normal/arm64/kqueue.o /Users/atul/comm/native/ios/Pods/libevent/kqueue.c normal arm64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'libevent' from project 'Pods')
	CompileC /Users/atul/Library/Developer/Xcode/DerivedData/Comm-fkiywtbjesejrkccwlrvafeymilk/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/libevent.build/Objects-normal/arm64/signal.o /Users/atul/comm/native/ios/Pods/libevent/signal.c normal arm64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'libevent' from project 'Pods')
	CompileC /Users/atul/Library/Developer/Xcode/DerivedData/Comm-fkiywtbjesejrkccwlrvafeymilk/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/libevent.build/Objects-normal/arm64/http.o /Users/atul/comm/native/ios/Pods/libevent/http.c normal arm64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'libevent' from project 'Pods')
	CompileC /Users/atul/Library/Developer/Xcode/DerivedData/Comm-fkiywtbjesejrkccwlrvafeymilk/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/libevent.build/Objects-normal/arm64/select.o /Users/atul/comm/native/ios/Pods/libevent/select.c normal arm64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'libevent' from project 'Pods')
	CompileC /Users/atul/Library/Developer/Xcode/DerivedData/Comm-fkiywtbjesejrkccwlrvafeymilk/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/libevent.build/Objects-normal/arm64/poll.o /Users/atul/comm/native/ios/Pods/libevent/poll.c normal arm64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'libevent' from project 'Pods')
	CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'lottie-ios' from project 'Pods')
(10 failures)
This revision now requires changes to proceed.Jul 7 2022, 9:30 AM

Is there a way I can get the rest (cd native/ios && pod install...) to run "inside" the nix shell after nix-develop in a single command?

This is what ended up working (as in the command ran after entering the shell, build still failed) :

cd native/ios && nix develop --command pod install && xcodebuild -workspace Comm.xcworkspace -scheme Comm -destination generic/platform=iOS -allowProvisioningUpdates
atul accepted this revision.EditedJul 7 2022, 9:57 AM

Just kidding, it worked 2-3 times after retrying... not sure what happened the first time around


edit:

Running nix develop --command pod install && xcodebuild -workspace Comm.xcworkspace -scheme Comm -destination generic/platform=iOS -allowProvisioningUpdates works

Running nix-develop and then running pod install && xcodebuild -workspace Comm.xcworkspace -scheme Comm -destination generic/platform=iOS -allowProvisioningUpdates "inside the nix shell" doesn't work?

Don't know enough about the subtleties of nix to know why, but I think it has something to do with differences in how Xcode config is being picked up

This revision is now accepted and ready to land.Jul 7 2022, 9:57 AM

Restore /usr/bin on PATH for pod compatibility

@atul yea, this is a bit of an awkward area for nix, as the apple_sdk usually lags behind what mac is currently providing.

I've updated the diff to include /usr/bin as the first PATH entry, I was able to do a pod install without issue.

Unfortunately until I get setup with a Apple developer account, I can't really make use of XCode directly yet

@atul it should "just work" now

nix/dev-shell.nix
83–84 ↗(On Diff #14292)

This feels super impure but unfortunately is probably the right decision for us in order to move forward here.

To be clear, will this make the Nix shell always include /usr/bin in $PATH, or is it somehow scoped just to the XCode build? (Fine if it's universal, I just want to make sure)

This revision is now accepted and ready to land.Jul 8 2022, 8:03 AM
jon added inline comments.
nix/dev-shell.nix
83–84 ↗(On Diff #14292)

will this make the Nix shell always include /usr/bin in $PATH

For macs, yes.

stdenv.mkDerivation and by extension mkShell will bring in the GNU version of many commands, including sed, base64, and gnu-make which have significant command-line differences.

The other option would be to provide an "ios shell", which would just be focused on ios development. E.g. nix develop .#devShells.iOS. This would have the benefit of downloading less things, but a bit of a pain if you want to switch between them.

Makes sense to me, thanks for explaining!

nix/dev-shell.nix
79 ↗(On Diff #14292)

Observation unrelated to this diff – this line is >80 chars long. Can we find a way to keep it within the 80 chars limit?

jon added inline comments.
nix/dev-shell.nix
79 ↗(On Diff #14292)

I've been good about that in the past week, but only really keeping myself to under ~100 before then. I can remedy this in another diff

This revision was automatically updated to reflect the committed changes.