This is a demonstration for how to create an iterator object in Swift and loop through its contents in C/C++.
- Xcode
- Cocoapods:
Install cocoapods on your Mac via
- Ruby:
$ sudo gem install cocoapods
- Homebrew:
$ brew install cocoapods
- Tested on
go
version 1.19. Could work on earlier versions.
go
module
The go
module is in the iteratormodule
folder. The source files for the compiled cgo
library are in iteratormodule/cmd/iteratormodule/*
. This is where the C iterator function callbacks are passed to and executed.
iOS project
The iOS app can be found inside the Example
folder and can be opened in Xcode by double clicking IteratorPodTest.xcworkspace
.
- Compile
cgo
module
$ cd iteratormodule
$ make ios
- This would compile the
cgo
module and move the library and header files to folders the iOS project will look in for installing thecgo
library.
- Running the
iOS
project.
$ cd Example
$ pod install
This would install the compiled libraries from step 1. You can run the project from simulator by double clicking Example/IteratorPodTest.xcworkspace
and running on Xcode simulator.